pax_global_header00006660000000000000000000000064140306635560014522gustar00rootroot0000000000000052 comment=cfddaddee9a2fde21f7e2c4fbf72c60ba7783958 siridb-connector-2.0.8/000077500000000000000000000000001403066355600147755ustar00rootroot00000000000000siridb-connector-2.0.8/.gitignore000066400000000000000000000002021403066355600167570ustar00rootroot00000000000000__pycache__/ *.pyc *.pyo *.module-cache* .project .pydevproject .idea checklist.txt test/ build/ dist/ siridb_connector.egg-info/ siridb-connector-2.0.8/ChangeLog000066400000000000000000000014751403066355600165560ustar00rootroot000000000000002021.03.17, Version 2.0.7 (BETA) - Using `siridb.connector` logger. 2021.03.15, Version 2.0.6 (BETA) - Added `connected` property to client. - Added time precision constants. 2017.03.09, Version 2.0.5 (BETA) - Raise Authentication Errors on connect. 2017.02.27, Version 2.0.4 (BETA) - Check for correct types using assert in query method. - Changed timeouts for insert and query method. - Changed callback functions 2016.10.22, Version 2.0.3 (BETA) - Fixed handling authentication errors correctly. (issue #2) 2016.10.21, Version 2.0.2 (BETA) - Added is_closed property to client. - New and closed connections logging is set from info to debug. (issue #1) 2016.10.03, Version 2.0.1 (BETA) - Fixed bug in setup.py - Initial version for communication with SiriDB 2.0.x siridb-connector-2.0.8/LICENSE.txt000066400000000000000000000021021403066355600166130ustar00rootroot00000000000000Copyright (c) 2017 Jeroen van der Heijden / Transceptor Technology 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.siridb-connector-2.0.8/README.md000066400000000000000000000161061403066355600162600ustar00rootroot00000000000000SiriDB - Connector ================== The SiriDB Connector is a self-contained Python driver for communicating with SiriDB servers. This manual describes how to install and configure SiriDB Connector for Python 3, and how to use it to develop database applications. --------------------------------------- * [Installation](#installation) * [Quick usage](#quick-usage) * [SiriDBClient](#siridbclient) * [connect](#siridbclientconnect) * [insert](#siridbclientinsert) * [query](#siridbclientquery) * [close](#siridbclientclose) * [Exception codes](#exception-codes) * [Version info](#version-info) --------------------------------------- ## Installation ------------ From PyPI (recommended) ``` pip install siridb-connector ``` From source code ``` python setup.py install ``` ## Quick usage ------- ```python import asyncio import time import random from siridb.connector import SiriDBClient async def example(siri): # Start connecting to SiriDB. # .connect() returns a list of all connections referring to the supplied # hostlist. The list can contain exceptions in case a connection could not # be made. await siri.connect() try: # insert ts = int(time.time()) value = random.random() await siri.insert({'some_measurement': [[ts, value]]}) # query resp = await siri.query('select * from "some_measurement"') print(resp) finally: # Close all SiriDB connections. siri.close() siri = SiriDBClient( username='iris', password='siri', dbname='dbtest', hostlist=[('localhost', 9000)], # Multiple connections are supported keepalive=True) loop = asyncio.get_event_loop() loop.run_until_complete(example(siri)) ``` ## SiriDBClient Create a new SiriDB Client. This creates a new client but `.connect()` must be used to connect. ```python siri = SiriDBClient( username=, password=, dbname=, hostlist=[(, , {weight: 1}, {backup: False})], loop=None, keepalive=True, timeout=10, inactive_time=30, max_wait_retry=90) ``` Arguments: * __username__: User with permissions to use the database. * __password__: Password for the given username. * __dbname__: Name of the database. * __hostlist__: List with SiriDB servers (all servers or a subset of servers can be in this list). *Example:* ```python hostlist=[ ('server1.local', 9000, {'weight': 3}), ('server2.local', 9001), ('backup1.local', 9002, {'backup': True}) ] ``` Each server should at least have a hostname and port number. Optionally you can provide a dictionary with extra options. Available Options: - __weight__ : Should be a value between 1 and 9. A higher value gives the server more weight so it will be more likely chosen. (default 1) - __backup__ : Should be either True or False. When True the server will be marked as backup server and will only be chosen if no other server is available. (default: False) Keyword arguments: * __loop__: Asyncio loop. When 'None' the default event loop will be used. * __keepalive__: When 'True' keep-alive packages are send every 45 seconds. * __timeout__: Maximum time to complete a process, otherwise it will be cancelled. * __inactive_time__: When a server is temporary unavailable, for example the server could be paused, we mark the server as inactive after x seconds. * __max_wait_retry__: When the reconnect loop starts, we try to reconnect in 1 second, then 2 seconds, 4, 8 and so on until max_wait_retry is reached and then use this value to retry again. ****************************************************************************** ### SiriDBClient.connect Start connecting to SiriDB. `.connect()` returns a list of all connections referring to the supplied hostlist. The list can contain exceptions in case a connection could not be made. Optionally the keyword argument `timeout` can be set. This will constrain the search time for a connection. Exceeding the timeout will raise an `.TimeoutError`. ```python siri.connect(timeout=None) ``` ### SiriDBClient.insert Insert time series data into SiriDB. Requires a 'dictionary' with at least one series. Optionally the `timeout` can be adjusted (default: 300). ```python siri.insert(data, timeout=300) ``` ### SiriDBClient.query Query data out of the database. Requires a string containing the query. More about the query language can be found [here](https://siridb.net/documentation/). The documentation about the query language will inform you about a number of useful aggregation and filter functions, different ways of visualizing and grouping the requested data, and how to make changes to the set up of the database. Optionally a `time_precision` (`SECOND`, `MICROSECOND`, `MILLISECOND`, `NANOSECOND`) can be set. The default `None` sets the precision to seconds. Futhermore the `timeout` can be adjusted (default: 60). ```python from siridb.connector import (SECOND, MICROSECOND, MILLISECOND, NANOSECOND) siri.query(query, time_precision=None, timeout=60) ``` ### SiriDBClient.close Close the connection. ```python siri.close() ``` Check if the connection is closed. ```python siri.is_closed ``` ## Exception codes The following exceptions can be returned: - `AuthenticationError`: *Raised when credentials are invalid or insufficient.* - `IndexError`: *Raised when the database does not exist (anymore).* - `InsertError` (can only be raised when using the `.insert()` method): *Make sure the data is correct because this only happens when SiriDB could not process the request.* - `OverflowError` (can only be raised when using the `.insert()` method): *Raised when integer values cannot not be packed due to an overflow error (integer values should be signed and not more than 63 bits).* - `PoolError`: *SiriDB has no online server for at least one required pool. Try again later after some reasonable delay.* - `QueryError` (can only be raised when using the `.query()` method): *Make sure the query is correct because this only happens when SiriDB could not process the query. Consult the [documentation](https://siridb.net/documentation/#help_select) about the query language can be found.* - `RuntimeError`: *Raised when a general error message is received. This should no happen unless a new bug is discovered.* - `ServerError`: *Raised when a server could not perform the request, you could try another server if one is available. Consult the [documentation](https://siridb.net/documentation/#help_list_servers) how to get additional status information about the servers.* - `TimeoutError`: *Raised when a process lasts longer than the `timeout` period* - `TypeError`: *Raised when an unknown package is received (might be caused by running a different SiriDB version).* - `UserAuthError`: *The user as no rights to perform the insert or query. Consult the [documentation](https://siridb.net/documentation/#help_access) how to change the access rights.* siridb-connector-2.0.8/setup.cfg000066400000000000000000000000471403066355600166170ustar00rootroot00000000000000[metadata] description-file = README.mdsiridb-connector-2.0.8/setup.py000066400000000000000000000031561403066355600165140ustar00rootroot00000000000000""" Upload to PyPI python setup.py sdist twine upload --repository pypitest dist/siridb-connector-X.X.X.tar.gz twine upload --repository pypi dist/siridb-connector-X.X.X.tar.gz """ from distutils.core import setup import setuptools from siridb import __version__ VERSION = __version__ with open('README.md', 'r') as f: long_description = f.read() setup( name='siridb-connector', packages=[ 'siridb', 'siridb.connector', 'siridb.connector.lib'], version=VERSION, description='SiriDB Connector', long_description=long_description, long_description_content_type='text/markdown', author='Jeroen van der Heijden', author_email='jeroen@transceptor.technology', url='https://github.com/SiriDB/siridb-connector', download_url='https://github.com/SiriDB/' 'siridb-connector/tarball/{}'.format(VERSION), keywords=['siridb', 'connector', 'database', 'client'], classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Other Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3 :: Only', 'Topic :: Database', 'Topic :: Software Development' ], install_requires=['qpack'] ) siridb-connector-2.0.8/siridb/000077500000000000000000000000001403066355600162515ustar00rootroot00000000000000siridb-connector-2.0.8/siridb/__init__.py000066400000000000000000000002461403066355600203640ustar00rootroot00000000000000__version_info__ = (2, 0, 8) __version__ = '.'.join(map(str, __version_info__)) __maintainer__ = 'Jeroen van der Heijden' __email__ = 'jeroen@transceptor.technology' siridb-connector-2.0.8/siridb/connector/000077500000000000000000000000001403066355600202435ustar00rootroot00000000000000siridb-connector-2.0.8/siridb/connector/__init__.py000066400000000000000000000044501403066355600223570ustar00rootroot00000000000000import os import sys import asyncio from .lib.protocol import _SiriDBProtocol from .lib.protocol import _SiriDBInfoProtocol from .lib.connection import SiriDBConnection from .lib.defaults import DEFAULT_CLIENT_PORT from .lib.client import SiriDBClient from .lib.constants import SECOND from .lib.constants import MICROSECOND from .lib.constants import MILLISECOND from .lib.constants import NANOSECOND __all__ = [ 'async_connect', 'async_server_info', 'connect', 'SiriDBClient', 'SiriDBProtocol', 'SECOND', 'MICROSECOND', 'MILLISECOND', 'NANOSECOND' ] class SiriDBProtocol(_SiriDBProtocol): def on_connection_made(self): pass def on_authenticated(self): pass def on_connection_lost(self, exc): pass def connect(username, password, dbname, host='127.0.0.1', port=DEFAULT_CLIENT_PORT, loop=None, timeout=10, protocol=SiriDBProtocol): return SiriDBConnection( username, password, dbname, host=host, port=port, loop=loop, timeout=timeout, protocol=protocol) async def async_connect(username, password, dbname, host='127.0.0.1', port=DEFAULT_CLIENT_PORT, loop=None, timeout=10, keepalive=False, protocol=SiriDBProtocol): connection = SiriDBAsyncConnection() await connection.connect( username, password, dbname, host=host, port=port, loop=loop, timeout=timeout, keepalive=keepalive, protocol=protocol) return connection async def async_server_info(host='127.0.0.1', port=DEFAULT_CLIENT_PORT, loop=None, timeout=10): loop = loop or asyncio.get_event_loop() client = loop.create_connection( lambda: _SiriDBInfoProtocol(None, None, None), host=host, port=port) transport, protocol = \ await asyncio.wait_for(client, timeout=timeout) result = await protocol.future transport.close() return result siridb-connector-2.0.8/siridb/connector/lib/000077500000000000000000000000001403066355600210115ustar00rootroot00000000000000siridb-connector-2.0.8/siridb/connector/lib/__init__.py000066400000000000000000000002051403066355600231170ustar00rootroot00000000000000'''SiriDB Connector - Communication with SiriDB :copyright: 2017, Jeroen van der Heijden (Transceptor Technology) :license: MIT ''' siridb-connector-2.0.8/siridb/connector/lib/client.py000066400000000000000000000267571403066355600226620ustar00rootroot00000000000000'''SiriDB Client SiriDB Client for python => 3.5 using asyncio. :copyright: 2016, Jeroen van der Heijden (Transceptor Technology) ''' import asyncio import functools import random from .protocol import _SiriDBProtocol from .connection import SiriDBAsyncConnection from .exceptions import AuthenticationError from .exceptions import ServerError from .exceptions import PoolError from .logging import logger as logging class _SiriDBClientProtocol(_SiriDBProtocol): _is_available = False def __init__(self, *args, trigger_connect, inactive_time): super().__init__(*args) self._trigger_connect = trigger_connect self._inactive_time = inactive_time def on_authenticated(self): self._is_available = True def on_connection_lost(self, exc): self._is_available = False self._trigger_connect() def set_available(self): if self._connected: self._is_available = True def set_not_available(self, loop): if self._is_available: self._is_available = False loop.call_later(self._inactive_time, self.set_available) # never wait more than x seconds before trying to connect again DEFAULT_MAX_WAIT_RETRY = 90 # default timeout used while connecting to a SiriDB server DEFAULT_CONNECT_TIMEOUT = 10 # when a SiriDB server is marked as inactive, wait x seconds before releasing # the inactive status. DEFAULT_INACTIVE_TIME = 30 class SiriDBClient: ''' Exception handling: - InsertError (can only be raised when using the insert() method) Make sure the data is correct because this only happens when SiriDB could not process the request. Its likely to fail again on a retry. - QueryError (can only be raised when using the query() method) Make sure the query is correct because this only happens when SiriDB could not process the query. Its likely to fail again. - PoolError SiriDB has no online server for at least one required pool Try again later after some reasonable delay. - AuthenticationError Raised when credentials are invalid or insufficient - IndexError Raised when the database does not exist (anymore) - TypeError Raised when an unknown package is received. (might be caused by running a different SiriDB version) - RuntimeError Raised when a general error message is received. This should not happen unless a new bug is discovered. - OverflowError (can only be raised when using the insert() method) Raise when integer values cannot not be packed due to an overflow error. (integer values should be signed and not more than 63 bits) - UserAuthError The user as no rights to perform the insert or query. ''' def __init__(self, username, password, dbname, hostlist, loop=None, keepalive=True, timeout=DEFAULT_CONNECT_TIMEOUT, inactive_time=DEFAULT_INACTIVE_TIME, max_wait_retry=DEFAULT_MAX_WAIT_RETRY): '''Initialize. Arguments: username: User with permissions to use the database. password: Password for the given username. dbname: Name of the database. hostlist: List with SiriDB servers. (all servers or a subset of servers can be in this list.) Example: [ ('server1.local', 9000, {'weight': 3}), ('server2.local', 9000), ('backup1.local', 9000, {'backup': True}) ] Each server should at least has a hostname and port number. Optionally you can provide a dictionary with extra options. Available Options: - weight : Should be a value between 1 and 9. A higher value gives the server more weight so it will be more likely chosen. (default 1) - backup : Should be either True or False. When True the server will be marked as backup server and will only be chosen if no other server is available. (default: False) Keyword arguments: loop: Asyncio loop. When None the default event loop will be used. keepalive: SiriDB Version >= 0.9.35 supporting keep-alive packages timeout: Timeout used when reconnecting to a SiriDB server. inactive_time: When a server is temporary not available, for example the server could be paused, we mark the server inactive for x seconds. max_wait_retry: When the reconnect loop starts, we try to reconnect in a seconds, then 2 seconds, 4, 8 and so on until max_wait_retry is reached and then use this value to retry again. ''' self._username = username self._password = password self._dbname = dbname self._connection_pool = [] self._keepalive = keepalive for host, port, *config in hostlist: config = config.pop() if config else {} client = SiriDBAsyncConnection() client.host = host client.port = port client.is_backup = config.get('backup', False) client.weight = config.get('weight', 1) assert 0 < client.weight < 10, \ 'weight should be value between 1 and 9' for _ in range(client.weight): self._connection_pool.append(client) self._connections = set(self._connection_pool) self._loop = loop or asyncio.get_event_loop() self._timeout = timeout self._connect_task = None self._max_wait_retry = max_wait_retry self._protocol = \ functools.partial(_SiriDBClientProtocol, trigger_connect=self._trigger_connect, inactive_time=inactive_time) @property def is_closed(self): '''Can be used to check if close() has been called.''' return not self._retry_connect @property def connected(self): '''Can be used to check the client has any active connections''' return any(connection.connected for connection in self._connections) @staticmethod def _log_connect_result(result): for r in result: if r: logging.error(r) async def connect(self, timeout=None): self._retry_connect = True result = await self._connect(timeout) if result and set(result) - {None} and self._connect_task is None: self._connect_task = asyncio.ensure_future(self._connect_loop()) return result def close(self): self._retry_connect = False if self._connect_task is not None: self._connect_task.cancel() self._connect_task = None for connection in self._connections: if connection.connected: connection.close() async def insert(self, data, timeout=300): while True: connection = self._get_random_connection() try: result = await connection.insert(data, timeout) except (ConnectionError, ServerError) as e: logging.debug('Insert failed with error {!r}, trying another ' 'server if one is available...'.format(e)) if connection._protocol: connection._protocol.set_not_available(self._loop) else: return result async def query(self, query, time_precision=None, timeout=60): assert isinstance(query, (str, bytes)), \ 'query should be of type str, unicode or bytes' assert time_precision is None or isinstance(time_precision, int), \ 'time_precision should be None or an int type.' try_unavailable = True while True: connection = self._get_random_connection(try_unavailable) try: result = await connection.query(query, time_precision=time_precision, timeout=timeout) except (ConnectionError, ServerError) as e: logging.debug('Query failed with error {!r}, trying another ' 'server if one is available...'.format(e)) if connection._protocol: connection._protocol.set_not_available(self._loop) else: return result # only try unavailable once try_unavailable = False async def _connect(self, timeout=None): # the one that actually connects tasks = [ connection.connect( self._username, self._password, self._dbname, host=connection.host, port=connection.port, loop=self._loop, keepalive=self._keepalive, timeout=timeout or self._timeout, protocol=self._protocol) for connection in self._connections if not connection.connected] if not tasks: return logging.debug('Trying to connect to {} servers...' .format(len(tasks))) result = await asyncio.gather(*tasks, return_exceptions=True) self._log_connect_result(result) return result async def _connect_loop(self): # the one that looks for connections sleep = 1 try: while [connection for connection in self._connections if not connection.connected]: logging.debug('Reconnecting in {} seconds...'.format(sleep)) await asyncio.sleep(sleep) if self._connect_task is None: break await self._connect() if self._connect_task is None: break sleep = min(sleep * 2, self._max_wait_retry) except asyncio.CancelledError: pass finally: self._connect_task = None def _trigger_connect(self): if self._retry_connect and self._connect_task is None: self._connect_task = asyncio.ensure_future(self._connect_loop()) def _get_random_connection(self, try_unavailable=False): available = \ [connection for connection in self._connection_pool if connection._protocol and connection._protocol._is_available] non_backups = \ [connection for connection in available if not connection.is_backup] if non_backups: return random.choice(non_backups) if available: return random.choice(available) if try_unavailable: connections = \ [connection for connection in self._connection_pool if connection.connected] if connections: return random.choice(connections) raise PoolError('No available connections found') siridb-connector-2.0.8/siridb/connector/lib/connection.py000066400000000000000000000145031403066355600235250ustar00rootroot00000000000000import asyncio import time from .defaults import DEFAULT_CLIENT_PORT from .protocol import _SiriDBProtocol from .protomap import CPROTO_REQ_QUERY from .protomap import CPROTO_REQ_INSERT from .protomap import CPROTO_REQ_REGISTER_SERVER from .protomap import CPROTO_REQ_PING from .protomap import FILE_MAP from .constants import SECOND from .constants import MICROSECOND from .constants import MILLISECOND from .constants import NANOSECOND from .logging import logger as logging class SiriDBConnection(): def __init__(self, username, password, dbname, host='127.0.0.1', port=DEFAULT_CLIENT_PORT, loop=None, timeout=10, protocol=_SiriDBProtocol): self._loop = loop or asyncio.get_event_loop() client = self._loop.create_connection( lambda: protocol(username, password, dbname), host=host, port=port) self._transport, self._protocol = self._loop.run_until_complete( asyncio.wait_for(client, timeout=timeout)) self._loop.run_until_complete(self._wait_for_auth()) async def _wait_for_auth(self): try: res = await self._protocol.auth_future except Exception as exc: logging.debug('Authentication failed: {}'.format(exc)) self._transport.close() raise exc else: self._protocol.on_authenticated() def close(self): if hasattr(self, '_protocol') and hasattr(self._protocol, 'transport'): self._protocol.transport.close() def query(self, query, time_precision=None, timeout=30): result = self._loop.run_until_complete( self._protocol.send_package(CPROTO_REQ_QUERY, data=(query, time_precision), timeout=timeout)) return result def insert(self, data, timeout=600): result = self._loop.run_until_complete( self._protocol.send_package(CPROTO_REQ_INSERT, data=data, timeout=timeout)) return result def _register_server(self, server, timeout=30): '''Register a new SiriDB Server. This method is used by the SiriDB manage tool and should not be used otherwise. Full access rights are required for this request. ''' result = self._loop.run_until_complete( self._protocol.send_package(CPROTO_REQ_REGISTER_SERVER, data=server, timeout=timeout)) return result def _get_file(self, fn, timeout=30): '''Request a SiriDB configuration file. This method is used by the SiriDB manage tool and should not be used otherwise. Full access rights are required for this request. ''' msg = FILE_MAP.get(fn, None) if msg is None: raise FileNotFoundError('Cannot get file {!r}. Available file ' 'requests are: {}' .format(fn, ', '.join(FILE_MAP.keys()))) result = self._loop.run_until_complete( self._protocol.send_package(msg, timeout=timeout)) return result class SiriDBAsyncConnection(): _protocol = None _keepalive = None async def keepalive_loop(self, interval=45): sleep = interval while True: await asyncio.sleep(sleep) if not self.connected: break sleep = \ max(0, interval - time.time() + self._last_resp) or interval if sleep == interval: logging.debug('Send keep-alive package...') try: await self._protocol.send_package(CPROTO_REQ_PING, timeout=15) except asyncio.CancelledError: break except Exception as e: logging.error(e) self.close() break async def connect(self, username, password, dbname, host='127.0.0.1', port=DEFAULT_CLIENT_PORT, loop=None, timeout=10, keepalive=False, protocol=_SiriDBProtocol): loop = loop or asyncio.get_event_loop() client = loop.create_connection( lambda: protocol(username, password, dbname), host=host, port=port) self._timeout = timeout _transport, self._protocol = \ await asyncio.wait_for(client, timeout=timeout) try: res = await self._protocol.auth_future except Exception as exc: logging.debug('Authentication failed: {}'.format(exc)) _transport.close() raise exc else: self._protocol.on_authenticated() self._last_resp = time.time() if keepalive and (self._keepalive is None or self._keepalive.done()): self._keepalive = asyncio.ensure_future(self.keepalive_loop()) def close(self): if self._keepalive is not None: self._keepalive.cancel() del self._keepalive if self._protocol is not None: self._protocol.transport.close() del self._protocol async def query(self, query, time_precision=None, timeout=3600): assert time_precision in ( None, SECOND, MICROSECOND, MILLISECOND, NANOSECOND), 'time_precision must be either None, 0, 1, 2, 3' result = await self._protocol.send_package( CPROTO_REQ_QUERY, data=(query, time_precision), timeout=timeout) self._last_resp = time.time() return result async def insert(self, data, timeout=3600): result = await self._protocol.send_package( CPROTO_REQ_INSERT, data=data, timeout=timeout) self._last_resp = time.time() return result @property def connected(self): return self._protocol is not None and self._protocol._connected siridb-connector-2.0.8/siridb/connector/lib/constants.py000066400000000000000000000000721403066355600233760ustar00rootroot00000000000000SECOND = 0 MILLISECOND = 1 MICROSECOND = 2 NANOSECOND = 3 siridb-connector-2.0.8/siridb/connector/lib/datapackage.py000066400000000000000000000017401403066355600236120ustar00rootroot00000000000000'''Data Package. This class is used for unpacking a received data package. :copyright: 2016, Jeroen van der Heijden (Transceptor Technology) ''' import struct import qpack from . import protomap class DataPackage(object): __slots__ = ('pid', 'length', 'tipe', 'checkbit', 'data') struct_datapackage = struct.Struct('