restructure code and use frappy.client for SECoP
- separation of SECoP part from webserver - use frappy client instead of own code for SECoP communication
This commit is contained in:
36
base.py
Normal file
36
base.py
Normal file
@ -0,0 +1,36 @@
|
||||
import time
|
||||
import logging
|
||||
|
||||
|
||||
class Logger(object):
|
||||
def __init__(self, logpath):
|
||||
self.terminal = sys.stdout
|
||||
self.log = open(logpath, "a")
|
||||
|
||||
def write(self, message):
|
||||
self.terminal.write(message)
|
||||
self.log.write(message)
|
||||
|
||||
def flush(self):
|
||||
pass
|
||||
|
||||
|
||||
class Instrument:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def remove(self, client):
|
||||
try:
|
||||
del self.clients[client.id]
|
||||
except KeyError:
|
||||
logging.warning('client already removed %s', client.id)
|
||||
|
||||
def register(self, client):
|
||||
self.clients[client.id] = client
|
||||
return client
|
||||
|
||||
|
||||
def get_abs_time(times):
|
||||
now = int(time.time() + 0.999)
|
||||
oneyear = 365 * 24 * 3600
|
||||
return [t + now if t < oneyear else t for t in times]
|
Reference in New Issue
Block a user