pyade
A minimal Python class to use ADE Web API for ADE Planning from Adesoft.
This is an unofficial development. I am in no way related to this company. Use it at your own risk.
WORK IN PROGRESS
Usage
Command Line Interface script
You might first define 3 environment variables.
export ADE_WEB_API_URL="https://server/jsp/webapi" export ADE_WEB_API_LOGIN="user_login" export ADE_WEB_API_PASSWORD="user_password"
Than you can run sample using:
$ python sample/main.py
You can also pass url, login, password as optional parameters of command line interface using:
$ python sample/main.py --url https://server/jsp/webapi --user user_login --password user_password
Interactive usage
Run IPython using:
$ ipython
You can use interactively this class
In [1]: from pyade import ADEWebAPI, Config
Import logging module and set level to logging.DEBUG
In [2]: import logging In [3]: logging.basicConfig(level=logging.DEBUG)
Get a config (etiher from environment variables)
In [4]: config = Config.create()
or passing parameter to Config.create method
In [4]: config = Config.create(url='server', login='user_login', password='user_password')
You can safely display config in a console, your password will not appear.
In [5]: config
Out[5]:
<Config {'url': 'https://server/jsp/webapi', 'login': 'user_login', 'password': '*********'}>
But you can access to any key like a dict. For example:
In [6]: config['url'] Out[6]: 'https://server/jsp/webapi'
So caution, your password is not in a safe place, as it’s in memory.
Config can be unpacked using ** operator and use as parameter for ADEWebAPI constructor.
In [7]: myade = ADEWebAPI(**config)
You can display methods of ADEWebAPI using “.” and tab key
In [8]: myade. myade.connect myade.getActivities myade.getProjects myade.opt_params myade.create_list_of_objects myade.getCaracteristics myade.getResources myade.password myade.disconnect myade.getCosts myade.hide_dict_values myade.sessionId myade.exception_factory myade.getDate myade.logger myade.setProject myade.factory myade.getEvents myade.login myade.url
Method signature, docstring, … can be printed using “?”
In [8]: ?myade.connect Signature: myade.connect() Docstring: Connect to server File: ~/pyade/pyade/__init__.py Type: instancemethod
Let’s connect to server (using url, login and password saved in myade instance of ADEWebAPI)
In [9]: myade.connect()
DEBUG:ADEWebAPI:send {'function': 'connect', 'login': 'user_login', 'password': '*********', 'sessionId': '14cef8679e2'}
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): server
DEBUG:requests.packages.urllib3.connectionpool:"GET /jsp/webapi?function=connect&login=user_login&password=user_password&sessionId=14cef8679e2 HTTP/1.1" 200 None
DEBUG:ADEWebAPI:<Response [200]>
DEBUG:ADEWebAPI:<?xml version="1.0" encoding="UTF-8"?>
<session id="14cef878c17"/>
Out[9]: True
A list of dict describing projects can be returned using:
In [10]: myade.getProjects()
DEBUG:ADEWebAPI:send {'function': 'getProjects', 'sessionId': '14cef8679e2'}
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): server
DEBUG:requests.packages.urllib3.connectionpool:"GET /jsp/webapi?function=getProjects&sessionId=14cef8679e2 HTTP/1.1" 200 None
DEBUG:ADEWebAPI:<Response [200]>
DEBUG:ADEWebAPI:<?xml version="1.0" encoding="UTF-8"?>
<projects>
<project id="6"/>
<project id="5"/>
</projects>
Out[10]: [{'id': '6'}, {'id': '5'}]
You can also use optional parameters such as detail to get more details about each project.
In [11]: myade.getProjects(detail=4)
DEBUG:ADEWebAPI:send {'function': 'getProjects', 'sessionId': '14cef8679e2', 'detail': 4}
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): server
DEBUG:requests.packages.urllib3.connectionpool:"GET /jsp/webapi?function=getProjects&sessionId=14cef8679e2&detail=4 HTTP/1.1" 200 None
DEBUG:ADEWebAPI:<Response [200]>
DEBUG:ADEWebAPI:<?xml version="1.0" encoding="UTF-8"?>
<projects>
<project id="6" name="2015-2016" uid="1428406688761" version="600" loaded="true"/>
<project id="5" name="2014-2015" uid="1364884711514" version="520" loaded="true"/>
</projects>
Out[11]:
[{'id': '6',
'loaded': 'true',
'name': '2015-2016',
'uid': '1428406688761',
'version': '600'},
{'id': '5',
'loaded': 'true',
'name': '2014-2015',
'uid': '1364884711514',
'version': '520'}]
You can set myade instance of class ADEWebAPI in order methods output list of objects instead of list of dictionaries
In [12]: myade.create_list_of_objects(True)
In [13]: myade.getProjects()
DEBUG:ADEWebAPI:send {'function': 'getProjects', 'sessionId': '14cef8679e2'}
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): server
DEBUG:requests.packages.urllib3.connectionpool:"GET /jsp/webapi?function=getProjects&sessionId=14cef8679e2 HTTP/1.1" 200 None
DEBUG:ADEWebAPI:<Response [200]>
DEBUG:ADEWebAPI:<?xml version="1.0" encoding="UTF-8"?>
<projects>
<project id="6"/>
<project id="5"/>
</projects>
Out[13]:
[Project({'id': '6'}),
Project({'id': '5'})]
You need to set current project. You probably won’t be able to call most of methods without this.
In [14]: myade.setProject(5) Out[14]: True
…
Don’t forget to disconnect from server before quitting.
In [15]: myade.disconnect()
DEBUG:ADEWebAPI:send {'function': 'disconnect', 'sessionId': '14cef8679e2'}
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): server
DEBUG:requests.packages.urllib3.connectionpool:"GET /jsp/webapi?function=disconnect&sessionId=14cef8679e2 HTTP/1.1" 200 None
DEBUG:ADEWebAPI:<Response [200]>
DEBUG:ADEWebAPI:<?xml version="1.0" encoding="UTF-8"?>
<disconnected sessionId="14cef8679e2"/>
Out[15]: True
Metadata
Release files for pyade 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyade-0.0.2.tar.gz | 10.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyade-0.0.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 23.0 kB
Release files / pyade-0.0.2.tar.gz
| Download URL | pyade-0.0.2.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31302541fa80abb850c3b4c378d25d47a90fb2cfdc8176321f1ea4231d0d6cb4
|
|
BLAKE2b-256 checksum How to use checksums |
5ca0797c7a8947fd51c5ea9c5e7297dc246f6f6d3f0b3d1348d840302654123f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pyade-0.0.2-py2.py3-none-any.whl
| Download URL | pyade-0.0.2-py2.py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
7805c6fac912af5c5b3ad69ea68b3a303a7e57bade90558dcfb4e28b43e8cbd2
|
|
BLAKE2b-256 checksum How to use checksums |
edb8d8cc372660c178fb15d66c0e1920078ce451f66c13ecc05a492e2f4db9a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pyade 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.