def __init__(self, config): ApplicationSession.__init__(self, config) # ZLMDB database configuration # self._dbpath = os.path.abspath( config.extra.get('dbpath', './.xbrnetwork')) self._db = zlmdb.Database(dbpath=self._dbpath, maxsize=2**30, readonly=False, sync=True) self._db.__enter__() self._schema = Schema.attach(self._db) self._pubkey_by_session = {} self._member_by_session = {} self._sessions_by_member = {} with self._db.begin() as txn: cnt_user_keys = self._schema.user_keys.count(txn) self.log.info( 'Database opened from {dbpath} (cnt_user_keys={cnt_user_keys})', dbpath=self._dbpath, cnt_user_keys=cnt_user_keys)
def __init__(self, config=None): ApplicationSession.__init__(self, config) self.connection = mysql.connector.connect(mysqlConfig) self.oldState = {} self.elapsedTime = 0 self.errorNotificationInterval = 12 # hours' self.timestampOld = 0
def __init__(self, config): ApplicationSession.__init__(self, config) self.vtkWebProtocols = [] self.authdb = None self.secret = None self.Application = self.initApplication() self.initialize()
def __init__(self, *args, **kwargs): log.msg("__xinit__") self.db = {} self.svar = {} log.msg("got args {}, kwargs {}".format(args, kwargs)) # reap init variables meant only for us for i in ( 'command', 'action', 'action_args', 'debug', 'authinfo', 'topic_base', ): if i in kwargs: if kwargs[i] is not None: self.svar[i] = kwargs[i] del kwargs[i] log.msg("sending to super.init args {}, kwargs {}".format( args, kwargs)) ApplicationSession.__init__(self, *args, **kwargs)
def __init__(self, config = None): """ Constructor. """ conn = sqlite3.connect(CONFIG_FILE) cur = conn.cursor() cur.execute("""SELECT value FROM Frequency""") row = cur.fetchone() if row != None: frequency = row[0] if frequency == 0: self.delta = datetime.timedelta(days=1) elif frequency == 1: self.delta = datetime.timedelta(hours=1) elif frequency == 2: self.delta = datetime.timedelta(minutes=1) else: ## If a measurement is not found, default to hours self.delta = datetime.timedelta(hours=1) conn.close() self.networkDevices = [socket.gethostname() + ".local"] ApplicationSession.__init__(self, config)
def __init__(self, config=None): ApplicationSession.__init__(self, config) global live live = self self.logger = logging.getLogger('Live') self.logger.info("Config: %s", config) self.account_id = config.extra['authid'] self.secret = config.extra['secret'] if '-' not in self.account_id: self.account_id = "local-%s" % self.account_id self.authid = '%s:%s' % (self.account_id, self.secret[-7:]) self.joined = False self.lock = DeferredLock() self.checks = {} self.workers = {} self.CallOptions = CallOptions()
def __init__(self, config=None): ApplicationSession.__init__(self, config) # FIXME self._default_gas = 100000 self._chain_id = 4 profile = config.extra['profile'] if 'ethkey' in config.extra and config.extra['ethkey']: self._ethkey_raw = config.extra['ethkey'] else: self._ethkey_raw = profile.ethkey self._ethkey = eth_keys.keys.PrivateKey(self._ethkey_raw) self._ethadr = web3.Web3.toChecksumAddress(self._ethkey.public_key.to_canonical_address()) self._ethadr_raw = binascii.a2b_hex(self._ethadr[2:]) self.log.info('Client Ethereum key loaded, public address is {adr}', func=hltype(self.__init__), adr=hlid(self._ethadr)) if 'cskey' in config.extra and config.extra['cskey']: cskey = config.extra['cskey'] else: cskey = profile.cskey self._key = cryptosign.SigningKey.from_key_bytes(cskey) self.log.info('Client WAMP authentication key loaded, public key is {pubkey}', func=hltype(self.__init__), pubkey=hlid('0x' + self._key.public_key())) self._running = True
def __init__(self, config): # Cannot use super() here. # We must explicitly call both parent constructors. ApplicationSession.__init__(self) service.AsyncMultiService.__init__(self) self.leaving = False self.setServiceParent(config.extra['parent'])
def __init__(self, config=None): ApplicationSession.__init__(self, config) self._ethkey_raw = config.extra['ethkey'] self._ethkey = eth_keys.keys.PrivateKey(self._ethkey_raw) self._ethadr = web3.Web3.toChecksumAddress(self._ethkey.public_key.to_canonical_address()) self._key = cryptosign.SigningKey.from_key_bytes(config.extra['cskey']) self._running = True
def __init__(self, config=None): self.log.info('{klass}.__init__(config={config})', klass=self.__class__.__name__, config=config) ApplicationSession.__init__(self, config) # FIXME self._default_gas = 100000 self._ethkey_raw = config.extra['ethkey'] self._ethkey = eth_keys.keys.PrivateKey(self._ethkey_raw) self._ethadr = web3.Web3.toChecksumAddress( self._ethkey.public_key.to_canonical_address()) self._ethadr_raw = binascii.a2b_hex(self._ethadr[2:]) self.log.info("Client (delegate) Ethereum key loaded (adr=0x{adr})", adr=self._ethadr) self._key = cryptosign.SigningKey.from_key_bytes(config.extra['cskey']) self.log.info( "Client (delegate) WAMP-cryptosign authentication key loaded (pubkey=0x{pubkey})", pubkey=self._key.public_key()) self._running = True
def __init__(self, config=None): print("__init__(config={})".format(config)) ApplicationSession.__init__(self, config) # load the client private key (raw format) self._key = cryptosign.Key.from_raw(config.extra[u'key']) print("Client public key loaded: {}".format(self._key.public_key()))
def __init__(self, config, max_points=None): ApplicationSession.__init__(self, config) self.max_points = max_points # Here we set the name of this data node server. self.name = "ucsc_radiometer" self.description = "PWV readings from the UCSC radiometer."
def __init__(self, config=None): ApplicationSession.__init__(self, config) self.pfcIp = '192.168.1.52' self.modbusTcpPort = '502' self.client = ModbusClient(self.pfcIp, self.modbusTcpPort) self.oldState = {} self.elapsedTime = 0
def __init__(self, config): ApplicationSession.__init__(self, config) self._connected_nodes = {} # public keys of superusers self._superusers = [] if 'CROSSBAR_FABRIC_SUPERUSER' in os.environ: superuser_keyfile = os.environ['CROSSBAR_FABRIC_SUPERUSER'].strip() if superuser_keyfile: pubkey_file = os.path.abspath( os.environ['CROSSBAR_FABRIC_SUPERUSER']) if not os.path.exists(pubkey_file): raise Exception( 'superuser public key file {} (set from CROSSBAR_FABRIC_SUPERUSER env var) does not exist' .format(pubkey_file)) with open(pubkey_file, 'r') as f: data = f.read() pubkey_hex = None for line in data.splitlines(): if line.startswith('public-key-ed25519'): pubkey_hex = line.split(':')[1].strip() break if pubkey_hex is None: raise Exception( 'no public key line found in super user public key file {}' .format(pubkey_file)) self._superusers.append(pubkey_hex) self.log.info( hl('SUPERUSER public key {} loaded from {}'.format( pubkey_hex, pubkey_file), color='green', bold=True))
def __init__(self, config=None): ApplicationSession.__init__(self, config) txaio.start_logging() if os.environ.get("LA4_CONFIG_PATH"): path = os.environ.get("LA4_CONFIG_PATH") self.log.info("config file: specified in environ @ %s" % path) self._handle_loading_config_from_file(path) else: parser = argparse.ArgumentParser() parser.add_argument("--config", help="A config file to read from") args = parser.parse_args() self.log.info("config file: passed in via args @ %s" % args.config) self._handle_loading_config_from_file(args.config) # pull built-in machines from a config file if specified # get redis from config # check for passed in config file # if no redis/config, try and find the default config file # start the tick runner(s). There is one for each of the speeds # The tick runner will iterate through all machines and find machines set to the specific enum # and step them along ever X seconds self._init_timers()
def __init__(self, config, max_points=None): ApplicationSession.__init__(self, config) self.max_points = max_points # Here we set the name of this data node server. self.name = "apex_weather" self.description = "Weather station information from APEX."
def __init__(self, config=None): ApplicationSession.__init__(self, config) self.connection = mysql.connector.connect(**mysqlConfig) #============================================================================== # A notification email will be send every errorNotificationInterval hours #============================================================================== self.pfc = 'SWITCH_Relays' self.errorNotificationInterval = 12 # hours' self.timestampOld = 0 # need for initial comparison #=====================is========================================================= # mySQLStructure defined since the readout is published as dict-objects and those are not ordered in Python #============================================================================== self.mySQLStructure = ['TimestampSYS', 'TimestampPFC', 'K_001', 'K_002', 'K_003', 'K_004', 'K_005', 'K_006', 'K_007', 'K_008', 'K_009', 'K_010', 'K_011', 'K_012', 'K_013', 'K_014', 'K_015', 'Frei_001', 'Frei_002', 'Frei_003']
def __init__(self, node): ApplicationSession.__init__(self) self.debug = False self._node = node self._node_name = node._node_name self._management_session = None self._processes = {}
def __init__(self, config=None): ApplicationSession.__init__(self, config=config) self.node = config.extra['node'] if 'domain' in config.extra: self.domain = config.extra['domain'] else: # TODO deprecate pdid self.domain = config.extra['pdid'] self.pdid = config.extra['pdid'] self.authid = config.extra.get('authid', self.pdid) # Need some idea of top level domain so we know which bouncer to call self.topLevelDomain = config.extra.get('topLevelDomain', 'xs.demo') # extra overrides the environment variable self.token = config.extra.get('token', None) if self.token is None: self.token = EXIS_TOKEN keySource = config.extra.get('key', None) if keySource is None: keySource = EXIS_KEY if keySource is None: self.key = None else: self.key = getPrivateKey(keySource) # Set by the start class method. self.dee = None
def __init__(self, config=None): ApplicationSession.__init__(self, config) print("component created") self.zeroconf = Zeroconf() self.listener = self self.browser = ServiceBrowser(self.zeroconf, "_ws2812._udp.local.", self.listener) self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
def __init__(self, config): ApplicationSession.__init__(self) self.config = config r_server = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB) self.redis = r_server
def __init__(self, config): ApplicationSession.__init__(self) self.t_account = config.extra["twilio-account"] self.t_token = config.extra["twilio-token"] self.t_number = config.extra["twilio-number"] urltmpl = "https://api.twilio.com/2010-04-01/Accounts/%s/Messages" self.t_url = (urltmpl % self.t_account).encode("utf-8")
def __init__(self, config): ApplicationSession.__init__(self, config) self._subs = {} self._regs = {} self._exclude_authid = None self._exclude_authrole = None
def __init__(self, kernel_key, conda_env=conda_env, env_path=env_path, pkg_path=pkg_path, config=ComponentConfig(realm=u"jupyter")): ApplicationSession.__init__(self, config=config) self._kernel_key = kernel_key self._conda_env = conda_env self._env_path = env_path self._pkg_path = pkg_path self._conda_env = conda_env self._lock = DeferredLock()
def __init__(self, config): # Cannot use super() here. # We must explicitly call both parent constructors. ApplicationSession.__init__(self) service.AsyncMultiService.__init__(self) self.config = config self.leaving = False self.setServiceParent(config.extra['parent'])
def __init__(self, config): self.ident = '{}:{}'.format(os.getpid(), threading.get_ident()) self.log.info('{klass}[{ident}].__init__(config={config})', klass=self.__class__.__name__, ident=self.ident, config=str(config)) ApplicationSession.__init__(self, config)
def __init__(self, config): ApplicationSession.__init__(self, config) self._subs = {} # registration-id's of remote registrations from an rlink self._regs = {} self._exclude_authid = None self._exclude_authrole = None
def __init__(self, config): ApplicationSession.__init__(self, config) self.cluster_state = ClusterState(self) try: self.node_id = (open('/cygnus/node', 'r')).read() except IOError: self.node_id = str(uuid.uuid1()) f = open('/cygnus/node', 'w') f.write(self.node_id) f.close()
def __init__(self, config): ApplicationSession.__init__(self, config) self._manager = None self._management_realm = None self._node_id = None self._regs = {} self._authrole = u'trusted' self._authmethod = u'trusted' self._sub_on_mgmt = None self._sub_on_reg_create = None self._sub_on_reg_delete = None
def __init__(self, config, management_session): """ :param config: Session configuration. :type config: instance of `autobahn.wamp.types.ComponentConfig` :param management_session: uplink session. :type management_session: instance of `autobahn.wamp.protocol.ApplicationSession` """ ApplicationSession.__init__(self, config) self._management_session = management_session self._regs = {}
def __init__(self, config=None): ApplicationSession.__init__(self, config) self.connection = mysql.connector.connect(**mysqlConfig) #============================================================================== # A notification email will be send every errorNotificationInterval hours #============================================================================== self.pfc = 'SWITCH_DI' self.errorNotificationInterval = 12 # hours' self.timestampOld = 0 # need for initial comparison
def __init__(self, config): ApplicationSession.__init__(self, config) self.vtkWebProtocols = [] self.authdb = None self.secret = None self.Application = self.initApplication() self.initialize() # Init Binary WebSocket image renderer global imageCapture imageCapture = protocols.vtkWebViewPortImageDelivery() imageCapture.setApplication(self.Application)
def __init__(self, config=None): self.log.info("initializing component: {config}", config=config) ApplicationSession.__init__(self, config) # load the client private key (raw format) try: self._key = cryptosign.SigningKey.from_raw_key(config.extra[u'key']) except Exception as e: self.log.error("could not load client private key: {log_failure}", log_failure=e) self.leave() else: self.log.info("client public key loaded: {}".format(self._key.public_key()))
def __init__(self, config, router, schemas=None): """ :param config: WAMP application component configuration. :type config: Instance of :class:`autobahn.wamp.types.ComponentConfig`. :param router: The router this service session is running for. :type: router: instance of :class:`crossbar.router.session.CrossbarRouter` :param schemas: An (optional) initial schema dictionary to load. :type schemas: dict """ ApplicationSession.__init__(self, config) self._router = router self._schemas = {} if schemas: self._schemas.update(schemas) self.log.info( 'initialized schemas cache with {entries} entries', entries=len(self._schemas), ) # the service session can expose its API on multiple sessions # by default, it exposes its API only on itself, and that means, on the # router-realm the user started self._expose_on_sessions = [] enable_meta_api = self.config.extra.get( 'enable_meta_api', True) if self.config.extra else True if enable_meta_api: self._expose_on_sessions.append((self, None, None)) # optionally, when this option is set, the service session exposes its API # additionally on the management session to the local node router (and from there, to CFC) bridge_meta_api = self.config.extra.get( 'bridge_meta_api', False) if self.config.extra else False if bridge_meta_api: management_session = self.config.extra.get( 'management_session', None) if self.config.extra else None if management_session is None: raise Exception( 'logic error: missing management_session in extra') bridge_meta_api_prefix = self.config.extra.get( 'bridge_meta_api_prefix', None) if self.config.extra else None if bridge_meta_api_prefix is None: raise Exception( 'logic error: missing bridge_meta_api_prefix in extra') self._expose_on_sessions.append( (management_session, bridge_meta_api_prefix, u'-'))
def __init__(self, config=None): ApplicationSession.__init__(self, config) QtWidgets.QMainWindow.__init__(self) # Setup logger log = Logger() # Initialize the pages self.predictor = PredictorVM(self) # Initialize the window self.main_window_init()
def __init__(self, config=None): ApplicationSession.__init__(self, config) QtWidgets.QMainWindow.__init__(self) # Setup logger log = Logger() # Initialize the pages self.adcp_term = AdcpTerminal(self) # Initialize the window self.main_window_init()
def __init__(self, config=None): self.log.info('{klass}.__init__(config={config})', klass=self.__class__.__name__, config=config) ApplicationSession.__init__(self, config) self._key = cryptosign.SigningKey.from_key_bytes(config.extra['cskey']) self.log.info( "Client (delegate) WAMP-cryptosign authentication key loaded (pubkey={pubkey})", pubkey=self._key.public_key()) self._running = True
def __init__(self, config=None): ApplicationSession.__init__(self, config) self.dofs = {"-1609551312": 3600 * 4, "-1609550966": 3600 * 4, "-1609555623": 3600 * 4, "-1609555631": 3600 * 4, "-1609555510": 3600 * 4, "-1609555628": 3600 * 4} try: with open('dofs.pickle', 'rb') as f: self.dofs = pickle.load(f) except IOError: pass
def __init__(self, config=None): ApplicationSession.__init__(self, config) if self.config.extra['redis']: # parsed = urlparse(self.config.extra['redis']) parsed = urlparse(os.getenv('REDIS_PORT_6379_TCP') + '/0') host = parsed.hostname port = parsed.port db = int(parsed.path.replace('/', '')) self.config.extra['redis'] = txredis.lazyConnectionPool( host=host, port=port, dbid=db) self.user_hisory = {} print("component created")
def __init__(self, config, schemas = None): """ Ctor. :param config: WAMP application component configuration. :type config: Instance of :class:`autobahn.wamp.types.ComponentConfig`. :param schemas: An (optional) initial schema dictionary to load. :type schemas: dict """ ApplicationSession.__init__(self, config) self._schemas = {} if schemas: self._schemas.update(schemas) print("CrossbarRouterServiceSession: initialized schemas cache with {} entries".format(len(self._schemas)))
def __init__(self, module_name, parser_file, config=types.ComponentConfig(u"anonymous")): self.uRC_MODULE_NAME = module_name self.PARSER_FILE = parser_file self.LOGGER = None self._parser = None self._pendingAnswers = {} self._pendingRPCs = {} self._rpcsToComplete = 0 self._subscriptions = dict() self._rpcs = {} ApplicationSession.__init__(self, config=config)
def __init__(self, config=None): ApplicationSession.__init__(self, config) self.pfcIp = '192.168.1.50' self.modbusTcpPort = 502 self.numberOfClamps = 7 self.client = ModbusClient(self.pfcIp, self.modbusTcpPort) self.clamps = [] for i in range(0, self.numberOfClamps): self.clamps.append('Clamp' + str(i + 1)) self.clampsV2 = [] for i in range(0, self.numberOfClamps): if i < 9: self.clampsV2.append('Clamp0' + str(i + 1)) if i >= 9: self.clampsV2.append('Clamp' + str(i + 1))
def __init__(self, config, router, schemas=None): """ Ctor. :param config: WAMP application component configuration. :type config: Instance of :class:`autobahn.wamp.types.ComponentConfig`. :param router: The router this service session is running for. :type: router: instance of :class:`crossbar.router.session.CrossbarRouter` :param schemas: An (optional) initial schema dictionary to load. :type schemas: dict """ ApplicationSession.__init__(self, config) self._router = router self._schemas = {} if schemas: self._schemas.update(schemas) log.msg("CrossbarRouterServiceSession: initialized schemas cache with {} entries".format(len(self._schemas)))
def __init__(self, *args, **kwargs): log.msg("__init__") self.db = {} self.svar = {} log.msg("got args {}, kwargs {}".format(args,kwargs)) # reap init variables meant only for us for i in ( 'engine', 'topic_base', 'dsn', 'authinfo', 'debug', ): if i in kwargs: if kwargs[i] is not None: self.svar[i] = kwargs[i] del kwargs[i] log.msg("sending to super.init args {}, kwargs {}".format(args,kwargs)) ApplicationSession.__init__(self, *args, **kwargs)
def __init__(self, config, router, schemas=None): """ Ctor. :param config: WAMP application component configuration. :type config: Instance of :class:`autobahn.wamp.types.ComponentConfig`. :param router: The router this service session is running for. :type: router: instance of :class:`crossbar.router.session.CrossbarRouter` :param schemas: An (optional) initial schema dictionary to load. :type schemas: dict """ ApplicationSession.__init__(self, config) self._router = router self._schemas = {} if schemas: self._schemas.update(schemas) self.log.info( 'initialized schemas cache with {entries} entries', entries=len(self._schemas), ) # the service session can expose its API on multiple sessions # by default, it exposes its API only on itself, and that means, on the # router-realm the user started self._expose_on_sessions = [] enable_meta_api = self.config.extra.get('enable_meta_api', True) if self.config.extra else True if enable_meta_api: self._expose_on_sessions.append((self, None, None)) # optionally, when this option is set, the service session exposes its API # additionally on the management session to the local node router (and from there, to CFC) bridge_meta_api = self.config.extra.get('bridge_meta_api', False) if self.config.extra else False if bridge_meta_api: management_session = self.config.extra.get('management_session', None) if self.config.extra else None if management_session is None: raise Exception('logic error: missing management_session in extra') bridge_meta_api_prefix = self.config.extra.get('bridge_meta_api_prefix', None) if self.config.extra else None if bridge_meta_api_prefix is None: raise Exception('logic error: missing bridge_meta_api_prefix in extra') self._expose_on_sessions.append((management_session, bridge_meta_api_prefix, u'-'))
def __init__(self, *args, **kwargs): log.msg("SessionData:__init__") self.svar = {} c = args[0] sd = args[1] # reap init variables meant only for us for i in ( 'topic_base', ): if i in kwargs: if kwargs[i] is not None: self.svar[i] = kwargs[i] del kwargs[i] ApplicationSession.__init__(self,c) self.sessiondb = sd # we give the sessiondb a hook so it can publish add/delete sd.app_session = self return
def __init__(self, config=None): QMainWindow.__init__(self) ApplicationSession.__init__(self, config) self.setupUi(self) self._channel = config.extra['channel'] self._subscriptions_ = [] self._controls = [ (self.bigFellaDial, self.bigFellaSlider), (self.smallBuddyDial, self.smallBuddySlider), (self.tinyLadDial, self.tinyLadSlider), (self.littlePalDial, self.littlePalSlider), ] for i, (_, slider) in enumerate(self._controls): slider.valueChanged.connect(partial(self.changeValue, i)) self.channelEdit.setValidator(QRegularExpressionValidator(CHANNEL_REGEXP)) self.channelEdit.setText(self._channel)
def __init__(self, config): ApplicationSession.__init__(self, config) # Dict to hold all IPCATree instances, keyed by file name self.trees = {} # Storing server name and port in a json file for easy config server_filename = 'server_conf.json' server_opts = json.loads(open(server_filename).read()) # Go through data directory and add methods to root for each data set data_dir = server_opts['ipca_data_dir'] # HDF5 files data_paths = [xx for xx in glob.glob(os.path.join(data_dir,'*.hdf5')) if os.path.isfile(xx)] data_dirnames = [os.path.splitext(os.path.basename(xx))[0] for xx in data_paths] # This adds the methods for each data directory for ii,name in enumerate(data_dirnames): print name, data_paths[ii] self.trees[name] = IPCATree(data_paths[ii])
def __init__(self, config=None): ApplicationSession.__init__(self, config) self.connection = mysql.connector.connect(mysqlConfig) #============================================================================== # A notification email will be send every errorNotificationInterval hours #============================================================================== self.pfc = 'MISC_Netzanschluss' self.errorNotificationEmails = notificationMailAddresses self.errorNotificationInterval = 12 # hours' self.timestampOld = 0 # need for initial comparison #=====================is========================================================= # wagoClampStructure defined since the readout is published as dict-objects and those are not ordered in Python #============================================================================== self.wagoClampStructure = ['TimestampSYS', 'TimestampPFC', 'shStarr', 'sh4QS', 'speicherSh', 'speicher4QS']
def __init__(self, config=None): ApplicationSession.__init__(self, config=config) self.pdid = config.extra['pdid'] self.authid = config.extra.get('authid', self.pdid) # Need some idea of top level domain so we know which bouncer to call self.topLevelDomain = Domain(config.extra.get('topLevelDomain', 'xs.demo')) # extra overrides the environment variable self.token = config.extra.get('token', None) if self.token is None: self.token = EXIS_TOKEN keySource = config.extra.get('key', None) if keySource is None: keySource = EXIS_KEY if keySource is None: self.key = None else: self.key = getPrivateKey(keySource)