Skip to main content

Library and command line interface to interact with Drink Management System of Fachschaft TF Uni Freiburg.

Project description

Python3 library with command line interface to interact with the Drink Management System (DMS) of the student council TF Uni Freiburg.

Getting Started

Prerequisites

You need python 3.5 or newer and pip. For development you also need git installed on your machine.

Installation

Install the dmsclient library and command line interface simply from PyPi:

pip3 install dmsclient

For developers it’s recommended to install from source vie develop. Then all changes in code are automatically available in the library and command line without reinstallation.

git clone git@<git url>:<user>/dmsclient.git
cd dmsclient

python3 setup.py develop

Command Line

The installation of dmsclient provides a command line interface dms. For authentication you have to generate a token key in your dms profile settings. Add your token to a .dmsrc file in your home folder.

[DEFAULT]
Token = XxxxxXXXxxxxxXXXXxxxxxxxXXX

Then you can start using dms. You’ll find all available commands via

dms --help

User and product names don’t have to be added exactly, but are estimated from what you type. E.g.:

$ dms buy apfel -u must
Buy Apfelschorle (0.70€) for Max Mustermann? [Y/n]

Library

For communication with the DMS via REST you can use the DmsClient class provided by this library. Authentication is provided via a token key which you can generate in the DMS profile settings. The DmsClient usually returns deep objects where ids were replaced by the corresponding object.

Example code:

from random import sample
from dmsclient import DmsClient


def order_random_stuff_for_last_customer(dms):
    available_products = (p for p in dms.products if p.quantity > 0)
    random_product = sample(available_products, 1)[0]
    last_sale = dms.sale_history(num_days=1)[0]

    dms.add_order(random_product.id, last_sale.profile.id)


token = 'XxxxxXXXxxxxxXXXXxxxxxxxXXX'
api_endpoint = 'https://dms.fachschaft.tf/api'
dms = DmsClient(token, api_endpoint)
order_random_stuff_for_last_customer(dms)

Authors

Initiated by David-Elias Künstle <kuenstld[at]tf.uni-freiburg> / Github but see contributors for a full list of contributions.

License

dmsclient is available under the MIT License

Acknowledgements

Big thanks to the DMS and DMS-API developers!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dmsclient-1.5.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

dmsclient-1.5.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file dmsclient-1.5.1.tar.gz.

File metadata

  • Download URL: dmsclient-1.5.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dmsclient-1.5.1.tar.gz
Algorithm Hash digest
SHA256 99ce7c37e1a9b97dcdae64fb397904ae39fdb60afa8abdc4145eba9c6c8df439
MD5 8ef822c111cbd72b2b6bd606dded5824
BLAKE2b-256 c1e707f37534b00d6eb17b00ea13daab4dd1c16bb541ab694ceb37caef079deb

See more details on using hashes here.

File details

Details for the file dmsclient-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: dmsclient-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

File hashes

Hashes for dmsclient-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1f2046348e9adc13017149c352fa90e72ab8983e8072e8fea57cf22c7ee78d9c
MD5 56479c7bb0d4c0b28e12bfe47b33c73e
BLAKE2b-256 0c6f6d4cde59f4295cdd0430b722adfb3d861552e96d6c1bb414df593b74c8f5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page