- separation of SECoP part from webserver - use frappy client instead of own code for SECoP communication
37 lines
772 B
Python
37 lines
772 B
Python
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]
|