Commit 5b19e20c authored by Roland Koller's avatar Roland Koller
Browse files

Initial MVP

parents
{
"python.pythonPath": "/home/rk/Repos/ecmind_blue_client_workflow/env/bin/python3.9",
"python.testing.unittestArgs": [
"-v",
"-s",
".",
"-p",
"test*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.unittestEnabled": true
}
\ No newline at end of file
MIT License
Copyright (c) 2020 Roland Koller
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
# ECMind blue client: Workflow
Helper modules for the `ecmind_blue_client` to ease the work with workflows, models and organisations. See discussion here: https://hub.ecmind.ch/t/119
## Installation
`pip install ecmind_blue_client.workflow`
from ecmind_blue_client_workflow import *
\ No newline at end of file
from ecmind_blue_client import Job
from ecmind_blue_client import Client
from XmlElement import XmlElement
def get_organisations(client:Client, only_active:bool=True):
result_get_organisations = client.execute(Job(jobname='wfm.GetOrganisations'))
if not result_get_organisations.return_code == 0:
raise RuntimeError(result_get_organisations.error_message)
organisations = XmlElement.from_string(result_get_organisations.values['Organisations']).to_dict()['Organisation']
if not isinstance(organisations, list):
organisations = [ organisations ]
if only_active:
return { o['@Id']: o['@Name'] for o in organisations if o['@Active'] == 1 }
else:
return { o['@Id']: o['@Name'] for o in organisations }
environment:
python3 -m venv env
package-test:
python3 setup.py sdist bdist_wheel
python3 -m twine upload --repository testpypi dist/*
package:
python3 setup.py sdist bdist_wheel
python3 -m twine upload --repository pypi dist/*
ecmind_blue_client>=0.3.6
xmlelement>=0.3.0
\ No newline at end of file
import setuptools
with open('README.md', 'r') as fh:
long_description = fh.read()
setuptools.setup(
name='ecmind_blue_client_workflow',
version='0.0.1',
author='Roland Koller',
author_email='info@ecmind.ch',
description='A client wrapper for blue',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://gitlab.ecmind.ch/open/ecmind_blue_client_workflow',
packages=setuptools.find_packages(),
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
],
python_requires='>=3.9',
install_requires=[
'ecmind_blue_client>=0.3.6',
'XmlElement>=0.3.0'
],
extras_require = { }
)
\ No newline at end of file
import unittest
from ecmind_blue_client.tcp_client import TcpClient as Client
import ecmind_blue_client_workflow as wf
class TestMethods(unittest.TestCase):
client = Client(hostname='enaio-rk-2021', port=4000, appname='unittest', username='root', password='optimal')
def test_get_active_organisations(self):
orgs = wf.get_organisations(self.client, only_active=True)
self.assertTrue('Organisation' in orgs.values())
if __name__ == '__main__':
unittest.main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment