Skip to content

Commit

Permalink
Merge pull request #269 from org-arl/pythongw-cleanup
Browse files Browse the repository at this point in the history
Python Gateway cleanup
  • Loading branch information
notthetup committed Feb 3, 2023
2 parents 0ea073a + f26f13e commit 76c57e0
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 27 deletions.
3 changes: 3 additions & 0 deletions gateways/python/.gitignore
@@ -0,0 +1,3 @@
dist/
*.egg-info/
README.rst
16 changes: 16 additions & 0 deletions gateways/python/Makefile
@@ -0,0 +1,16 @@
.PHONY: install clean

docs:
@sed '/^\.\. highlight.*/d' ../../src/sphinx/pythongw.rst > README.rst

testupload: docs
python setup.py sdist bdist_wheel
twine upload --repository testpypi dist/*

upload: docs
python setup.py sdist
twine upload --repository pypi dist/*

clean:
find . -name *.pyc -exec rm {} \;
rm -rf build fjagepy.egg-info dist
8 changes: 4 additions & 4 deletions gateways/python/README.md
@@ -1,15 +1,15 @@
# fjåge Python gateway (fjagepy)

## Installing via Pip
## Requirements

Python comes with an inbuilt package management system, [pip](https://pip.pypa.io/en/stable/). Pip can install, update, or delete any official package.
- [Python3](https://www.python.org/downloads/)

You can install fjagepy package via the command line by entering:
## Installing via [Pip](https://pip.pypa.io/en/stable/)

```bash
pip install fjagepy
```

## Documentation

The documentation is available at [fjagepy](https://pypi.org/project/fjagepy/).
The documentation is available at [fjagepy](https://pypi.org/project/fjagepy/)
3 changes: 2 additions & 1 deletion gateways/python/fjagepy/__init__.py
Expand Up @@ -718,7 +718,8 @@ def __del__(self):
try:
self.socket.close()
except Exception as e:
self.logger.critical("Exception: " + str(e))
if (hasattr(self, 'logger') and self.logger != None):
self.logger.critical("Exception: " + str(e))

def close(self):
"""Closes the gateway. The gateway functionality may not longer be accessed after this method is called.
Expand Down
20 changes: 8 additions & 12 deletions gateways/python/setup.py
@@ -1,21 +1,11 @@
from setuptools import setup, find_packages

with open('../../src/sphinx/pythongw.rst') as f:
with open('README.rst', 'w') as f1:
for line in f:
if ".. highlight" not in line:
f1.write(line)

with open('README.rst') as f:
readme = f.read()

# with open('../../../VERSION') as f:
# ver = f.read()
# ver = ver.split('-')[0]

setup(
name='fjagepy',
version='1.7.2',
version='1.7.4',
description='Python Gateway',
long_description=readme,
author='Prasad Anjangi, Mandar Chitre, Chinmay Pendharkar, Manu Ignatius',
Expand All @@ -27,9 +17,15 @@
'Development Status :: 5 - Production/Stable',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11'
],
packages=find_packages(exclude=('tests', 'docs')),
packages=find_packages(),
install_requires=[
'numpy>=1.11'
],
license_files = ('LICENSE',)
)
20 changes: 10 additions & 10 deletions src/test/groovy/org/arl/fjage/test/BasicTests.py
Expand Up @@ -61,23 +61,23 @@ def test_send_GenericMessage(self):

def test_parameters(self):
"""Test: Should be able to set and get parameter values"""
self.assertEquals(self.g.agent('S').y, 2) # should get the value of a single parameter
self.assertEquals(self.g.agent('S').k, None) # should return None if asked to get the value of unknown parameter
self.assertEqual(self.g.agent('S').y, 2) # should get the value of a single parameter
self.assertEqual(self.g.agent('S').k, None) # should return None if asked to get the value of unknown parameter
self.g.agent('S').a = 42 # should set the value of a single parameter and return the new value
self.assertEquals(self.g.agent('S').a, 42)
self.assertEqual(self.g.agent('S').a, 42)
self.g.agent('S').a = 0
self.assertEquals(self.g.agent('S').a, 0)
self.assertEqual(self.g.agent('S').a, 0)
self.g.agent('S').k = 42 # should return None if asked to set the value of unknown parameter
self.assertEquals(self.g.agent('S').k, None)
self.assertEqual(self.g.agent('S').k, None)
self.g.agent('S')[1].z = 4 # should get the value of a single indexed parameter
self.assertEquals(self.g.agent('S')[1].z, 4)
self.assertEquals(self.g.agent('S')[1].k, None) # should return None if asked to get the value of unknown indexed parameter
self.assertEqual(self.g.agent('S')[1].z, 4)
self.assertEqual(self.g.agent('S')[1].k, None) # should return None if asked to get the value of unknown indexed parameter
self.g.agent('S')[1].z = 42 # should set the value of a single indexed parameter and return the new value
self.assertEquals(self.g.agent('S')[1].z, 42)
self.assertEqual(self.g.agent('S')[1].z, 42)
self.g.agent('S')[1].z = 4
self.assertEquals(self.g.agent('S')[1].z, 4)
self.assertEqual(self.g.agent('S')[1].z, 4)
self.g.agent('S')[1].k = 1
self.assertEquals(self.g.agent('S')[1].k, None) # should return None if asked to set the value of unknown indexed test_parameters
self.assertEqual(self.g.agent('S')[1].k, None) # should return None if asked to set the value of unknown indexed test_parameters

@classmethod
def tearDownClass(cls):
Expand Down

0 comments on commit 76c57e0

Please sign in to comment.