• Stars
    star
    14
  • Rank 1,438,076 (Top 29 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created over 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Unofficial Python library to use ADE Web API for ADE Planning from Adesoft

Latest Version Supported Python versions Wheel format License Development Status Downloads monthly Requirements Status Documentation Status Sourcegraph Code Health Build Status

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

Dependencies

Install

$ pip install pyade

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

Development

$ git clone https://github.com/scls19fr/pyade.git

More Repositories

1

pandas_degreedays

A Python package to calculate degree days (DD or in french DJU - degré jour unifié) from measured outdoor temperatures and to make it possible to quantify drift of energy consumption for heating (or cooling)
Python
12
star
2

pandas-helper-calc

Helper methods for Pandas Series and DataFrames to calculate numerically derivative and integral
Python
9
star
3

ExtensibleScheduler.jl

An advanced and extensible Julia events scheduler. https://scls19fr.github.io/ExtensibleScheduler.jl/dev/
Julia
8
star
4

numpy-buffer

A Python NumPy implementation of ring buffer (aka circular buffer)
Python
7
star
5

python-lms-tools

Python library to manage quiz format(s) used by differents Learning management system (LMS) especially Moodle (currently only Aiken format is supported)
Python
6
star
6

openweathermap_requests

Python package to fetch data from OpenWeatherMap.org with requests and requests-cache
Python
5
star
7

pycondor

Python script to manage Condor Soaring files such as tasks (flight plans)
Python
5
star
8

GPX.jl

A Julia GPX parser (ie reader) and creator (ie writer). GPX (GPS eXchange Format) is an XML based file format for GPS tracks.
Julia
5
star
9

Pushover.jl

A simple Pushover client for Julia https://scls19fr.github.io/Pushover.jl/dev
Julia
4
star
10

Sched.jl

A Julia event scheduler inspired by Python sched. https://scls19fr.github.io/Sched.jl/dev/
Julia
4
star
11

pandas-anonymizer

Some functions to anonymize data with Python Pandas
Python
4
star
12

wnb

Weight and balance progressive web application for light aircrafts (SEP, gliders...)
TypeScript
2
star
13

morse-listen

[WIP] Decoding morse code using Python, Machine Learning...
Python
2
star
14

arduino_libraries_search

Python Pandas script to search for Arduino libraries matching some keywords and to output to Excel file
Python
2
star
15

KMLTracks.jl

A Julia library to parse KML files or strings (ie read them) with gx:Track extension
Julia
2
star
16

simulator_keypad

C++
1
star
17

CakeLocale

Project containing a translation effort for the CakePHP core
1
star
18

python-airac

Python library to deal with AIRAC cycle dates
Python
1
star
19

AIRAC.jl

Julia library to deal with AIRAC cycle dates
Julia
1
star
20

openphysic

PHP
1
star
21

polaires_excel

Fichier Excel polaire des vitesses (planeur)
1
star
22

email-verif

A Python email validator. Verify if an email address is valid and really exists.
Python
1
star
23

tkinter_matplotlib_sample

A Python Tkinter example with Matplotlib integration
Python
1
star
24

JuliaVagrant

A Vagrant environment for Julia development (Linux Ubuntu host)
1
star
25

BulkSMS.jl

A Julia package to send SMS (Short Message Service) using BulkSMS API https://scls19fr.github.io/BulkSMS.jl/dev
Julia
1
star
26

web_scraping_sia_python

Unofficial Python library to scrape SIA (Service de l'information aéronautique) website
Python
1
star
27

sia_lua

Unofficial Lua library to download VAC from SIA (Service de l'information aéronautique) website
Lua
1
star
28

Nextion.jl

An unofficial Julia library to communicate with Itead Nextion display
Julia
1
star