def run(self): signal.signal(signal.SIGINT, self.terminate) self.gateways = {} self.gateways['GCS'] = gateway.Gateway(portIn=6128, portOut=6129) self.gateways['UAV'] = gateway.Gateway(portIn=6130, portOut=6131) for gw in self.gateways: self.gateways[gw].start() signal.pause()
def addGateway(self, levelGateway): for gateway1 in levelGateway: block = gateway.Gateway(gateway1[0], gateway1[1]) block.rect.x = gateway1[2] block.rect.y = gateway1[3] block.player = self.player self.gateway_list.add(block)
def _activate_device_group(self, device): group_name = device.group group_devices = self._devices.get_by_group(group_name) existing_gateways = { device.gateway for device in group_devices if device.gateway } if existing_gateways: existing = existing_gateways.pop() LOGGER.info('Gateway for existing device group %s is %s', group_name, existing) return existing set_num = self._find_gateway_set(device) LOGGER.info( 'Gateway for device group %s not found, initializing base %d...', device.group, set_num) gateway = gateway_manager.Gateway(self, group_name, set_num, self.network) try: gateway.initialize() except Exception: LOGGER.error('Cleaning up from failed gateway initialization') LOGGER.debug('Clearing %s gateway group %s for %s', device, set_num, group_name) self.gateway_sets.add(set_num) raise return gateway
def __init__(self, logName): self.logName = logName self.exchange = "SPC" #instantiate pricing and gateway modules self.gateway = gateway.Gateway(logName=logName) self.pricing = pricing.Pricing() #create strategies array self.strategies = [] self.maxStrategiesPerMatch = 1 self.strategiesByMatch = { } #dictionary of lists, lists contain pointers to self.strategies #balance related parameters self.account_bal_watermark = 0 self.account_bal_tolerance = (.1) * 10**18 #LIMITS self.maxNotionalOutstanding = (.75) * 10**18 self.notionalOutstanding = 0 ### instantiate logger ### self.logger = logging.getLogger(self.exchange + "." + logName) logFile = '../logs/' + self.exchange + '.' + logName + "_" + datetime.datetime.utcnow( ).strftime("%Y%m%d.%H%M%S") + '.log' hdlr = RotatingFileHandler(logFile, mode='a', maxBytes=500 * 1024 * 1024, backupCount=5, encoding=None, delay=0) formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) self.logger.addHandler(hdlr) self.logger.setLevel(logging.DEBUG) #reject related parameters self.reject_counter = 0 self.max_rejects = 10 #misc parameters self.loop_counter = 0 #STRATEGY self.leagues = ["all"] self.matchTypes = ["all"] self.strategyParams = { "edge": 2, "size": (.01) * 10**18, "duration": tools.MINUTE * 30, "quoter": True, "hitter": False, }
def main(): """This function starts the Discord Webhook Center application. It generates a new window, where the user can send content to a discord server. """ # create window root = tk.Tk() root.title("Discord Webhook Center") root.resizable(width=False, height=False) root.geometry("800x610") # set gateway instance gateway = gate.Gateway() # load gui app = MainApp(root, gateway) app.clearInputs() # Run mainloop root.mainloop()
def _activate_device_group(self, group_name, target_port): if group_name in self._device_groups: existing = self._device_groups[group_name] LOGGER.debug('Gateway for existing device group %s is %s', group_name, existing.name) return existing set_num = self._find_gateway_set(target_port) LOGGER.info('Gateway for device group %s not found, initializing base %d...', group_name, set_num) gateway = gateway_manager.Gateway(self, group_name, set_num, self.network) self._gateway_sets[set_num] = group_name self._device_groups[group_name] = gateway try: gateway.initialize() except: LOGGER.error('Cleaning up from failed gateway initialization') LOGGER.debug('Clearing target %s gateway group %s for %s', target_port, set_num, group_name) del self._gateway_sets[set_num] del self._device_groups[group_name] raise return gateway
def handle_isalive_gateway(self, pck, gateway_ip): flag_create = False _id, ip, port, seed = utils.segment_packet(pck, utils.GATEWAY_ISALIVE) if _id not in self.gateways_info: flag_create = True self.gateways_info[_id] = gateway.GatewayInfo(_id, time.time()) flag_update = self.check_seed(_id, seed) if flag_update: xml_filename = _id + '.xml' ftp.download_xml(gateway_ip, self.gateways_xml_dir, xml_filename) _gateway = gateway.Gateway(_id, (ip, port)) gateway_location, nodes = self.parser.get_xml_info( self.gateways_xml_dir + xml_filename) for node in nodes: node.gateway_id = _id if flag_create: # ( Send_seed = 1 ) > ( local_seed = 0 ) self.gateways_info[_id].id = _id self.dbConnector.insert_gateway(_gateway, gateway_location, nodes) # self.dbConnector.update_gateway_location(_id, gateway_location) ftp.upload_file( ip, os.path.dirname(os.path.abspath(__file__)) + '/', utils.NODETYPES_FILE) ftp.upload_file( ip, os.path.dirname(os.path.abspath(__file__)) + '/', utils.LOCATIONS_FILE) self.upload_erase_images(ip) else: self.dbConnector.update_gateway_nodes(_gateway, nodes) self.gateways_info[_id].timer = time.time()
def __init__(self): self._param = rocon_gateway.setup_ros_parameters() key = uuid.uuid4( ) # random 16 byte string, alternatively uuid.getnode() returns a hash based on the mac address, uuid.uid1() based on localhost and time self._unique_name = self._param[ 'name'] + key.hex # append a unique hex string rospy.loginfo("Gateway : generated unique hash name [%s]" % self._unique_name) self._hub_manager = hub_manager.HubManager( hub_whitelist=self._param['hub_whitelist'], hub_blacklist=self._param['hub_blacklist']) self._gateway = gateway.Gateway(self._hub_manager, self._param, self._unique_name, self._publish_gateway_info) self._gateway_services = self._setup_ros_services() self._gateway_publishers = self._setup_ros_publishers() direct_hub_uri_list = [self._param['hub_uri'] ] if self._param['hub_uri'] != '' else [] self._hub_discovery_thread = rocon_hub_client.HubDiscovery( self._register_gateway, direct_hub_uri_list, self._param['disable_zeroconf']) # aliases self.spin = self._gateway.spin
from flask import Flask import gateway import bus import dal import product if __name__ == "__main__": # Here's the bootstrapper, it starts the vector of microservices we'll need, along with their protocols enterpriseServiceBus = bus.Bus( 'amqp://*****:*****@rabbitmq-master.default.svc.cluster.local/%2f', 10) gatewayService = gateway.Gateway(enterpriseServiceBus) dalDbDriver = dal.DalHelper() productService = ProductService()
""" Created on Sun Mar 14 11:59:47 2021 @author: Yasser """ ############################################################################### import gateway as gw ############################################################################### ############################################################################### gate = gw.Gateway() db = gw.DbConnections() ############################################################################### ############################################################################### tableCreation = { 'ORDER_BOOK_TRACKING' : {'fields' : {'PAIR' : 'VARCHAR(8)' , 'DIRECTION' : 'VARCHAR(4)' , 'DEPTH' : 'INTEGER' , 'PRICE' : 'VARCHAR(12)', 'VOLUME' : 'VARCHAR(12)', 'UPDT_DTTM' : 'TIMESTAMP'},
#!/usr/bin/python3 import gateway import argparse parser = argparse.ArgumentParser() parser.add_argument("-d", "--debug", help="", action="store_true") parser.add_argument("-i", "--identifier", help="locker identifier", type=str) parser.add_argument("--host", help="host", type=str) parser.add_argument("-c", "--code", help="code", type=str) parser.add_argument("action", help="open, close, search, synchronize, update, synchronize_locker, update_locker") args = parser.parse_args() gw = gateway.Gateway(args.debug) if args.host: gw.set_host(args.host) if args.action == "open": gw.open(args.identifier, args.code.encode("ascii")) elif args.action == "close": gw.close(args.identifier, args.code.encode("ascii")) elif args.action == "search": gw.search() elif args.action == "synchronize": gw.synchronize() elif args.action == "update": gw.update() elif args.action == "synchronize_locker": gw.synchronize_locker(args.identifier)
def setUp(self): self.gw = gateway.Gateway()
import gateway as g import sys a = sys.argv gw = g.Gateway() options = {"-d": gw.changeDNSSetting, "-h": gw.getHostInfo, "-p": gw.getPortmapping, "-r": gw.rebootGateway} if (a[1] in options): if len(a)==2: options[a[1]]() elif len(a)==3: options[a[1]](a[2]) else: print("Not an option!")
# ----------------------------------------------------------------------------- import autodoc as ad # ----------------------------------------------------------------------------- import gateway import coin_metrics_api ############################################################################### ############################################################################### # Loan Automatic Documenation Generator AutoDoc = ad.AutoDocumentation() # ----------------------------------------------------------------------------- # Run automatic documentation generator for each object AutoDoc.runDocumentation(gateway.Gateway()) AutoDoc.runDocumentation(gateway.DbConnections()) AutoDoc.runDocumentation(coin_metrics_api.CoinMetricsAPI()) ###############################################################################
from log import log name = sys.argv[1] test = sys.argv[2] if len(sys.argv) > 2 else "manual" class TestGatewayListener(gateway.Listener): def onGatewayMessage(self, g, message): log.info("TestGatewayListener.onGatewayMessage('%s') => pos = %d" % (message, g.pos)) ##log.info(g.liveOrders) log.info("pendingOrders = %s" % ([oid for oid in g.pendingOrders ])) log.info("pendingCancels = %s" % ([oid for oid in g.pendingCancels])) L = TestGatewayListener() log.info("Starting gateway named %s", name) g = gateway.Gateway(name=name, listeners=[L]) while True: if test == "manual": time.sleep(0.1) print "input message: ", m = sys.stdin.readline().rstrip() if m == "": break g.outboundQueue.put(m) elif test == "random": time.sleep(1) prc = random.randint(45,55) side = random.choice((Order.BUY, Order.SELL)) qty = random.randint(1,10)
def __init__(self, name): self.gateway = gateway.Gateway(name=name, listeners=[self]) self.feed = feed.Feed(listeners=[self]) self.book = book.Book() self.board = ChessBoard.ChessBoard() self.gameId = None
import gateway if __name__ == "__main__": gw = gateway.Gateway() while 1: packet = gw.waitForPacket() if (packet != None): print("Received: {%s}" % packet) gw.handlePacket(packet)
def __init__(self, gateway_url, appid, appsecret): self.gateway = gateway.Gateway(gateway_url, appid, appsecret)