This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
# bayeosgatewayclient
A Python package to transfer client (sensor) data to a BayEOS Gateway.

![basic concept](

## Installation
You can either use the script, the Python Package Index (PIP) or a Linux binary to install the package.

Do the following steps to install the package via the script:
- git clone request ```git clone git://```
- find the right directory ```cd bayeosgatewayclient```
- run ```python install``` as root

### PIP
- run ```pip install bayeosgatewayclient```

### Linux Binary (for Debian)
- add the following repositories to /etc/apt/sources.list ```deb wheezy main```
- install key ```wget -O - | apt-key add -```
- ```apt-get update```
- ```apt-get install python-bayeosgatewayclient```

- run ```dpkg -i python-bayeosgatewayclient_*_all.deb``` as root

## Example usage
Import the package ```import bayeosgatewayclient```.

### Writer
A simple writer looks like this:
from time import sleep
from bayeosgatewayclient import BayEOSWriter

writer = BayEOSWriter('/tmp/bayeos-device1/')
writer.save_msg('BayEOS Writer was started.')

while True:
print 'adding frame\n'[2.1, 3, 20.5])

A BayEOSWriter constructor takes the following arguments:
PATH = '/tmp/bayeos-device1/' # directory to store .act and .rd files
MAX_CHUNK = 2000 # file size in bytes
MAX_TIME = 60 # time when a new file is started in seconds
writer = BayEOSWriter(path=PATH, max_chunk=MAX_CHUNK, max_time=MAX_TIME)

The following methods could also be of interest:
- save integer values: ```[1,2,3], value_type=0x22)```
- save with channel indices: ```[[1,2.1], [2,3], [3,20.5]], value_type=0x41)``` or
```{1: 2.1, 2: 3, 3: 20.5}, value_type=0x41)```
- save with channel offset: ```[2.1, 3, 20.5], value_type=0x02, offset=2)```
- save origin: ```[2.1, 3, 20.5], origin='Writer-Example')```
- save error message: ```writer.save_msg('error message', error=True)```
- close current .act file and start a new one: ```writer.flush()```

### Sender
A simple sender looks like this:
from time import sleep
from bayeosgatewayclient import BayEOSSender

sender = BayEOSSender('/tmp/bayeos-device1/',

while True:
res = sender.send()
if res > 0:
print 'Successfully sent ' + str(res) + ' frames.'

A BayEOSSender constructor takes the following arguments:
PATH = '/tmp/bayeos-device1/' # directory to look for .rd files
NAME = 'Test-Device'
URL = ''
USER = 'import' # user name to access the BayEOS Gateway
PASSWORD = 'import' # password to access the BayEOS Gateway
BACKUP_PATH = '/home/.../' # backup path to store file if a) sending does not work
or b) sending was successful but files but files
shall be kept (renamed from .rd to .bak extension)

sender = BayEOSSender(path=PATH,
absolute_time=True, # if true writer, else sender time is used
remove=True, # .rd files deleted after successfully sent

The following methods could also be of interest:
- substitute the loop: ``````
- start sender as a separate thread ```sender.start(sleep_sec=5)```
- start sender as a separate process ```sender.start(sleep_sec=5, thread=False)```

### Connect writer and sender
Usually, the writer and sender are operating concurrently, although they are not
linked directly, i. e., they only share the same directory.

A simple script to connect one writer-sender pair looks like this:
from bayeosgatewayclient import BayEOSWriter, BayEOSSender

PATH = '/tmp/bayeos-device/'
NAME = 'Writer-Sender-Example'
URL = ''

writer = BayEOSWriter(PATH)
writer.save_msg('Writer was started.')

sender = BayEOSSender(PATH, NAME, URL)
sender.start() # sender runs in a concurrent thread

while True:
print 'adding frame'[2.1, 3, 20.5])

Another way to combine writer-sender pairs is using the BayEOSGatewayClient class:
from bayeosgatewayclient import BayEOSGatewayClient

OPTIONS = {'bayeosgateway_url' : ''
'bayeosgateway_password' : 'import',
'bayeosgateway_user' : 'import'}

NAMES = ['PythonTestDevice1', 'PythonTestDevice2', 'PythonTestDevice3']

class PythonTestDevice(BayEOSGatewayClient):
"""Creates both a writer and sender instance for every NAME in NAMES. Implements BayEOSGatewayClient."""
def read_data(self):
"""Must be overwritten."""
if == 'PythonTestDevice1':
return (2.1, 3, 20.5)
return (42)

def save_data(self, data=0, origin=''):
"""Can be overwritten."""
if == 'PythonTestDevice1':, origin='origin')
self.writer.save_msg('Overwritten method.')
elif == 'PythonTestDevice2':

client = PythonTestDevice(NAMES, OPTIONS)

### Parsing command line arguments
Constructor arguments can be passed as command line arguments:

long option | short option | description
−−name |-n |name to appear in Gateway
−−path |-p |path to store writer files before they are sent
−−max-chunk |-m |maximal file size [bytes] before a new file is started
−−writer-sleep |-ws |writer sleep time [seconds]
−−sender-sleep |-ss |sender sleep time [seconds]
−−password |-pw |password to access BayEOS Gateway
−−user |-un |user name to BayEOS Gateway
−−url |-u |URL to access BayEOS Gateway

from bayeosgatewayclient import BayEOSWriter, bayeos_argparser
args = bayeos_argparser('This text appears on the command line.')

WRITER_SLEEP = float(args.writer_sleep)
MAX_CHUNK = float(args.max_chunk)
writer = BayEOSWriter(max_chunk=MAX_CHUNK)

while True:[42, 20.5], value_type=0x21)

That is what could appear on the command line:
```python2.7 -m 2560 -ws 5```

### Parsing config files
First, a config file has to be created, e.g.:
; Sample Config file for bayeosgatewayclient

name = Test-Device
path = /tmp/bayeos-device

max_time = 100
max_chunk = 2000
writer_sleep_time = 1

sender_sleep_time = 10
url =
bayeosgateway_user = import
bayeosgateway_pw = import
absolute_time = True
remove = False
backup_path = /home/pi/backup/

Second, the Python script needs to invoke the ```bayeos_confparser(config_file)``` method.

from bayeosgatewayclient import BayEOSWriter, BayEOSSender, bayeos_confparser
config = bayeos_confparser('config')

writer = BayEOSWriter(config['path'], config['max_chunk'])
sender = BayEOSSender(config['path'])
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
bayeosgatewayclient-0.2.6.tar.gz (18.1 kB) Copy SHA256 Checksum SHA256 Source Feb 8, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting