def __init__(self): self.logger = Log("vps_mgr", config=conf) self.logger_net = Log("vps_mgr_net", config=conf) self.logger_misc = Log("misc", config=conf) self.logger_debug = Log("debug", config=conf) self.host_id = conf.HOST_ID self.vpsops = VPSOps(self.logger) self.handlers = { CMD.OPEN: self.__class__.vps_open, CMD.REBOOT: self.__class__.vps_reboot, CMD.CLOSE: self.__class__.vps_close, CMD.OS: self.__class__.vps_reinstall_os, CMD.UPGRADE: self.__class__.vps_upgrade, CMD.BANDWIDTH: self.__class__.vps_set_bandwidth, CMD.RM: self.__class__.vps_delete, CMD.PRE_SYNC: self.__class__.vps_hot_sync, CMD.MIGRATE: self.__class__.vps_migrate, CMD.RESET_PW: self.__class__.vps_reset_pw, } self._locker = threading.Lock() self._vps_locker = dict() self.xenstat = XenStat() self.timer = TimerEvents(time.time, self.logger_misc) assert conf.MONITOR_COLLECT_INV > 0 self.last_netflow = None self.last_diskstat = None self.monitor_inv = conf.MONITOR_COLLECT_INV self.last_monitor_ts = None self.timer.add_timer(conf.MONITOR_COLLECT_INV, self.monitor_vps) self.timer.add_timer(12 * 3600, self.refresh_host_space) self.workers = [] self.running = False
def __init__(self): self.is_running = False self.linkage_dict = dict() self.logger = Log("icmp_mon", config=config) self.alarm_q = JobQueue(self.logger) self.emailalarm = EmailAlarm(Log("alarm", config=config)) self.logger_links = Log("links", config=config) if 'log_length_per_link' in dir(config): self.log_length_per_link = config.log_length_per_link else: self.log_length_per_link = 128 if 'links' not in dir(config): self.logger.error("no 'links' in config") return g_alarm_levels = None g_recover = None if 'alarm_levels' in dir(config): g_alarm_levels = self._parse_alarm_levels(config.alarm_levels) if 'recover' in dir(config): g_recover = int(config.recover) links = config.links if isinstance(links, dict): for ip, v in links.iteritems(): if not isinstance(v, dict): v = dict() ttl = v.get('ttl') if ttl >= 0: pass else: ttl = 0 alarm_levels = v.get('alarm_levels') if not alarm_levels and g_alarm_levels: alarm_levels = g_alarm_levels elif alarm_levels: alarm_levels = self._parse_alarm_levels(alarm_levels) if not alarm_levels: continue else: self.logger.error( "config: %s, missing alarm_levels value" % (ip)) continue recover = v.get('recover') if recover: recover = int(recover) elif not recover and g_recover: recover = g_recover else: self.logger.error("config: %s, missing recover value" % (ip)) continue self.linkage_dict[ip] = Linkage(ip, alarm_levels, recover) self.logger.info("%d link loaded from config" % (len(self.linkage_dict.keys())))
def test_create_vps0 (self): print "create vps00" logger = Log ("test", config=conf) vpsops = VPSOps (logger) vps = XenVPS (0) try: vps.setup (os_id=20001, vcpu=1, mem_m=512, disk_g=7, ip="113.11.199.3", netmask="255.255.255.0", gateway="113.11.199.1", root_pw="fdfdfd") #vps.add_extra_storage (disk_id=1, size_g=1, fs_type='ext3') #vps.add_extra_storage (disk_id=2, size_g=0.5, fs_type='ext4') #vps.setup (os_id=10001, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=10002, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=30001, vcpu=1, mem_m=512, disk_g=7, ip="10.10.2.2", netmask="255.255.255.0", gateway="10.10.2.1", root_pw="root") #vps.setup (os_id=1, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=10000, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=20001, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=10003, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") #vps.setup (os_id=20001, vcpu=1, mem_m=512, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") print vps.gen_xenpv_config () #vpsops.create_vps (vps, vps_image='/data/vps/images/arch-2011.08.19-i386-fs-ext3.tar.gz') vpsops.create_vps (vps) except Exception, e: print str(e) logger.exception (e) raise e
def test_alarm_good(): alarm = EmailAlarm(Log("test", config=config)) link = Linkage("1.1.1.1", [1, 10], 5) link.last_state = True link.bitmap = ["1", "1", "1", "1", "1"] link.cur_alarm_level = 1 alarm.send(link.alarm_text(), link.details())
def start(): global server server = ThreadingXMLRPCServer(addr=(SERVER_ADRES, SERVER_PORT)) server.register_introspection_functions() server.register_instance(DroidPresInstance()) Log('Start server on %s:%s' % (SERVER_ADRES, SERVER_PORT)) server.serve_forever()
def __init__(self): self.logger = Log("vps_mgr", config=conf) self.logger_err = Log("vps_mgr_err", config=conf) self.logger_misc = Log("misc", config=conf) self.host_id = conf.HOST_ID self.handlers = { Cmd.OPEN: self.__class__.vps_open, Cmd.REBOOT: self.__class__.vps_reboot, Cmd.CLOSE: self.__class__.vps_close, Cmd.OS: self.__class__.vps_reinstall_os, } self.timer = TimerEvents(time.time, self.logger_misc) assert conf.NETFLOW_COLLECT_INV > 0 self.timer.add_timer(conf.NETFLOW_COLLECT_INV, self.send_netflow) self.timer.add_timer(12 * 3600, self.refresh_host_space) self.workers = [] self.running = False
def __init__(self): self.is_running = False self.hostname = socket.gethostname() self.logger = Log("saas_mon", config=conf) self.recover_thres = conf.SAAS_RECOVER_THRESHOLD or (30 * 5) self.bad_thres = conf.SAAS_BAD_THRESHOLD or 5 self.alarm_q = JobQueue(self.logger) self.emailalarm = EmailAlarm(self.logger) self.last_state = True
def sync_partition(dev, dest_ip, speed=None): logger = Log("vps_mgr", config=conf) try: client = MigrateClient(logger, dest_ip) client.sync_partition(dev, speed=speed) print "ok" except Exception, e: logger.exception(e) raise e
def move_closed_vps(vps_id, dest_ip, speed=None, force=False): logger = Log("vps_mgr", config=conf) client = VPSMgr() vps_info = None try: vps_info = client.query_vps(vps_id) except Exception, e: print "failed to query vps state: [%s] %s" % (type(e), str(e)) if not force: os._exit(1)
def test_meta(self): print "test vps meta" logger = Log("test", config=conf) vpsops = VPSOps(logger) vps = XenVPS(0) vps.setup(os_id=50001, vcpu=1, mem_m=500000, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") vps.add_extra_storage(disk_id=1, size_g=1, fs_type='ext3') vps.add_netinf('vps0_inter', "10.10.3.2", '255.255.255.0', 'xenbr0', None) vps.data_disks['xvdc1']._set_expire_days(1) print "trash_date", vps.data_disks['xvdc1'].trash_date print "expire_date", vps.data_disks['xvdc1'].expire_date vpsops.save_vps_meta(vps) _vps = vpsops.load_vps_meta(0) self.assertEqual(_vps.vps_id, vps.vps_id) self.assertEqual(_vps.os_id, vps.os_id) self.assertEqual(_vps.vcpu, vps.vcpu) self.assertEqual(_vps.mem_m, vps.mem_m) self.assertEqual(_vps.ip, vps.ip) self.assertEqual(_vps.netmask, vps.netmask) self.assertEqual(_vps.gateway, vps.gateway) self.assertEqual(_vps.root_store.size_g, vps.root_store.size_g) self.assertEqual(_vps.swap_store.size_g, vps.swap_store.size_g) self.assertEqual(_vps.data_disks['xvdc1'].size_g, 1) self.assertEqual(_vps.data_disks['xvdc1'].fs_type, 'ext3') self.assertEqual(_vps.data_disks['xvdc1'].mount_point, '/mnt/data1') self.assertEqual(_vps.data_disks['xvdc1'].xen_dev, 'xvdc1') self.assertEqual(_vps.data_disks['xvdc1'].trash_date, vps.data_disks['xvdc1'].trash_date) self.assertEqual(_vps.data_disks['xvdc1'].expire_date, vps.data_disks['xvdc1'].expire_date) print _vps.data_disks['xvdc1'].__class__.__name__ self.assertEqual(len(_vps.vifs.values()), 2) self.assertEqual(_vps.vifs['vps0_inter'].ip, '10.10.3.2') self.assertEqual(_vps.vifs['vps0_inter'].netmask, '255.255.255.0') self.assertEqual(_vps.vifs['vps0_inter'].bridge, 'xenbr0') self.assertEqual(_vps.vifs['vps0_inter'].mac, vps.vifs['vps0_inter'].mac) print "test trash expire date None" vps.data_disks['xvdc1']._set_expire_days(None) self.assertEqual(vps.data_disks['xvdc1'].trash_date, None) self.assertEqual(vps.data_disks['xvdc1'].expire_date, None) vpsops.save_vps_meta(vps) _vps = vpsops.load_vps_meta(0) self.assertEqual(_vps.data_disks['xvdc1'].trash_date, None) self.assertEqual(_vps.data_disks['xvdc1'].expire_date, None)
def start(self): """ This method inicialize the server and start listening requests. """ while True: try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # inicialize Socket s.bind(('', self.port)) # bind socket for listen s.listen(self.max_conn) # Start listen for incomming connections msg = "ProxY Started Sucessfully [ %d ]" % self.port Log(msg) print msg break except Exception, e: print e msg = "Unable to initialize server on [ %d ]" % self.port Log(msg) print msg if self.auto_increment_port: self.port += 1 else: sys.exit(2)
class GetCPUTempCommand(OSPollCommand): _logger = Log("GetCPUTempCommand") @staticmethod def getCommand(): return ['cat', '/sys/class/thermal/thermal_zone0/temp'] @staticmethod def parseFunction(stdout, stderr): t = stdout.decode('utf-8') t = "%s.%s" % (t[0:2], t[2]) GetCPUTempCommand._logger.log("parsed {text}".format(text=t)) return "{t}°C".format(t=t), getColorInRange(float(t), 55, 65)
class GetGPUTempCommand(OSPollCommand): _logger = Log("GetGPUTempCommand") @staticmethod def getCommand(): return ['/opt/vc/bin/vcgencmd', 'measure_temp'] @staticmethod def parseFunction(stdout, stderr): t = stdout.decode('utf-8') t = "%s.%s" % (t[5:7], t[8]) GetGPUTempCommand._logger.log("parsed {text}".format(text=t)) return "{t}°C".format(t=t), getColorInRange(float(t), 55, 65)
def main(): logger = Log("vps_mgr", config=conf) mgr = VPSMgr() host_list = None try: rpc = mgr.rpc_connect() try: host_list = rpc.host_list() finally: rpc.close() update_iplist(host_list) except Exception, e: print e logger.exception(e) return
def __new__(cls, *args, **kargs): cls._log = None if OPTIONS is not None and OPTIONS.AreLocked: if Manager.instance is None: Manager.instance = object.__new__(cls, *args, **kargs) Manager.initialized = False else : Manager.initialized = True cls._options = OPTIONS return Manager.instance cls._log = Log() cls._log.create("", False, True, LogLevel.Debug , LogLevel.Debug, LogLevel.Debug) cls._log.write(LogLevel.Error, cls, "Options have not been created and locked. Exiting...") exit(1) return None
def main(): logger = Log("migrate", config=conf) migsvr = MigrateServer(logger) def exit_sig_handler(sig_num, frm): global stop_signal_flag if stop_signal_flag: return stop_signal_flag = True migsvr.stop() return migsvr.start() signal.signal(signal.SIGTERM, exit_sig_handler) signal.signal(signal.SIGINT, exit_sig_handler) migsvr.loop() return
def test_mem_too_big(self): print "test mem too big" vps = XenVPS(0) logger = Log("test", config=conf) vps.setup(os_id=50001, vcpu=1, mem_m=500000, disk_g=7, ip="10.10.1.2", netmask="255.255.255.0", gateway="10.10.1.1", root_pw="fdfdfd") try: vps.check_resource_avail() except Exception, e: logger.exception(e) print "exception caught", type(e), str(e) return
def start(self): threadlist = [] loglist = {} files = self.get_files() req = self.detect() print(req) # for i in files: # print(i) for i in range(NUMBER_OF_THREAD): threadlist.append(Scan(self.url, loglist, files, req)) for t in threadlist: t.start() for t in threadlist: t.join() if CACHE_LOG: log = Log(self.url, loglist) log.save()
def main(): bridge = args[0] vif_name = args[1] logger = Log("vps_mgr", config=conf) try: ovsops = OVSOps() ofport = ovsops.find_ofport_by_name(vif_name) if ofport < 0: logger.error("vif %s ofport=%s, skip it" % (vif_name, ofport)) else: ovsops.unset_mac_filter(bridge, ofport) # it's strange that if you unset traffic first, might find ofport==-1 ovsops.unset_traffic_limit(vif_name) logger.debug("unset %s" % vif_name) return 0 except Exception, e: logger.exception(e) print >> sys.stderr, str(e) return 0
def _file(self, filename, msg='', type='read'): ''' filename read/write/add ''' try: if type == "read": if not os.path.exists(filename): open(filename, "w+").close() file_obj = open(filename, "r") content = file_obj.read() elif type == "write": file_obj = open(filename, "w") content = file_obj.write(msg) file_obj.close() return content except Exception, e: Log().debug("main.py _file error: %s" % (str(e)))
def test_1(self): logger = Log("test", config=conf) migsvr = migrate.MigrateServer(logger) migsvr.start() def foo(): migsvr.loop() return th = threading.Thread(target=foo) th.setDaemon(1) th.start() client = migrate.MigrateClient(logger, "127.0.0.1") # call_cmd ("dd if=/proc/interrupts of=/tmp/test") #client.sendfile ("/tmp/test", "/tmp/test1") client.sendfile("/dev/main/vps00_swap", "/tmp/vps00_swap") time.sleep(3) migsvr.stop()
def Create(self): # Create the log file (if enabled) find, logging = self._options.GetOptionAsBool("Logging") if not find: logging = False find, userPath = self._options.GetOptionAsString("UserPath") if not find: userPath = "" find, logFileNameBase = self._options.GetOptionAsString("LogFileName") if not find: logFileNameBase = "OZWEmule_Log.txt" find, bAppend = self._options.GetOptionAsBool("AppendLogFile") if not find: bAppend = False find, bConsoleOutput = self._options.GetOptionAsBool("ConsoleOutput") if not find: bConsoleOutput = True find, nSaveLogLevel = self._options.GetOptionAsInt("SaveLogLevel") if not find: nSaveLogLevel = LogLevel.Debug #LogLevel.Detail find, nQueueLogLevel = self._options.GetOptionAsInt("QueueLogLevel") if not find: nQueueLogLevel = LogLevel.StreamDetail # LogLevel.Debug find, nDumpTrigger = self._options.GetOptionAsInt("DumpTriggerLevel") if not find: nDumpTrigger = LogLevel.Warning logFilename = userPath + logFileNameBase self._log = Log() self._log.create(logFilename, bAppend, bConsoleOutput, nSaveLogLevel, nQueueLogLevel, nDumpTrigger) self._log.setLoggingState(logging) self._options.setLog(self._log) find, configPath = self._options.GetOptionAsString("ConfigPath") self.readXmlDeviceClasses(configPath) self.manufacturers = Manufacturers(configPath) self.cmdClassRegistered = CommandClasses(self) self.cmdClassRegistered.RegisterCommandClasses() # try : # self.paramsConfig = readJsonFile('../data/config_emulation.json') # self._log.write(LogLevel.Always, self,"Config parameters loaded : {0}".format(self.paramsConfig)) # except: # self._log.write(LogLevel.Warning, self,"No correct file config for emulation in data path.") self.loadXmlConfig() # Scene.ReadScenes() self._log.write( LogLevel.Always, self, "OpenZwave-emulator Version {0} Starting Up".format( self.getVersionAsString())) for homeId in self.zwNetworks: self.startDriver(homeId)
def test_vps0(self): print "create vps00" logger = Log("test", config=conf) vpsops = VPSOps(logger) xv = XenVPS(0) try: xv.setup(os_id=10001, vcpu=1, mem_m=512, disk_g=7, ip="10.10.2.2", netmask="255.255.255.0", gateway="10.10.2.1", root_pw="fdfdfd") xv.add_extra_storage(disk_id=1, size_g=1, fs_type='ext3') print xv.gen_xenpv_config() vpsops.create_vps(xv) except Exception, e: logger.exception(e) raise e
def main(): bridge = args[0] vif_name = args[1] logger = Log("vps_mgr", config=conf) vpsops = VPSOps(logger) logger.debug("set %s" % vif_name) try: ovsops = OVSOps() om = re.match(r'^\w+?(\d+)\w*?$', vif_name) if not om: print >> sys.stderr, "wrong vif format %s" % (vif_name) return 1 vps_id = int(om.group(1)) xv = vpsops.load_vps_meta(vps_id) vif = xv.vifs.get(vif_name) if not vif: logger.error("no vif %s in metadata of %s" % (vif_name, vps_id)) return 1 ofport = ovsops.find_ofport_by_name(vif_name) if ofport < 0: logger.error( "vif %s ofport=%s, fix it by delete the port from bridge " % (vif_name, ofport)) ovsops.del_port_from_bridge(bridge, vif_name) ovsops.add_port_to_bridge(bridge, vif_name) ofport = ovsops.find_ofport_by_name(vif_name) if ofport < 0: logger.error("vif %s ofport=%s, impossible " % (vif_name, ofport)) if ofport >= 0: ovsops.set_mac_filter(bridge, ofport, vif.ip_dict.keys()) ovsops.unset_traffic_limit(vif_name) bandwidth = float(vif.bandwidth or 0) ovsops.set_traffic_limit(vif_name, int(bandwidth * 1000)) print "set vif %s bandwidth %sm/s" % (vif_name, vif.bandwidth) return 0 except Exception, e: logger.exception(e) print >> sys.stderr, str(e) return 1
def create(self, configPath, userPath, command): self._configPath = configPath self._userPath = userPath self._command = command if not os.path.exists(self._configPath): _log = Log() _log.create("", False, True, LogLevel.Debug , LogLevel.Debug, LogLevel.Debug) _log.write(LogLevel.Error, "Cannot Find a path to the configuration files at {0}. Exiting...".format(self._configPath)) exit(1) # Add the default options self.AddOptionString("ConfigPath", configPath, False) # Path to the OpenZWave config folder. self.AddOptionString("UserPath",userPath, False) # Path to the user's data folder. self.AddOptionBool("Logging",True) # Enable logging of library activity. self.AddOptionString("LogFileName","OZWEmul_Log.txt",False) # Name of the log file (can be changed via Log::SetLogFileName) self.AddOptionBool("AppendLogFile",False) # Append new session logs to existing log file (False = overwrite) self.AddOptionBool("ConsoleOutput",True) # Display log information on console (as well as save to disk) self.AddOptionInt("SaveLogLevel", LogLevel.Detail) # Save (to file) log messages equal to or above Detail self.AddOptionInt("QueueLogLevel", LogLevel.Debug) # Save (in RAM) log messages equal to or above Debug self.AddOptionInt("DumpTriggerLevel", LogLevel.Never) # Default is to never dump RAM-stored log messages self.AddOptionBool("Associate",True) # Enable automatic association of the controller with group one of every device. self.AddOptionString("Exclude","", True) # Remove support for the listed command classes. self.AddOptionString("Include","",True) # Only handle the specified command classes. The Exclude option is ignored if anything is listed here. self.AddOptionBool("NotifyTransactions",False) # Notifications when transaction complete is reported. self.AddOptionString("Interface","",True) # Identify the serial port to be accessed (TODO: change the code so more than one serial port can be specified and HID) self.AddOptionBool("SaveConfiguration",True) # Save the XML configuration upon driver close. self.AddOptionInt("DriverMaxAttempts",0) self.AddOptionInt("PollInterval",30000) # 30 seconds (can easily poll 30 values in this time; ~120 values is the effective limit for 30 seconds) self.AddOptionBool("IntervalBetweenPolls",False) # if False, try to execute the entire poll list within the PollInterval time frame # if True, wait for PollInterval milliseconds between polls self.AddOptionBool("SuppressValueRefresh",False) # if True, notifications for refreshed (but unchanged) values will not be sent self.AddOptionBool("PerformReturnRoutes",True) # if true, return routes will be updated self.AddOptionString("NetworkKey", "", False) self.AddOptionBool("RefreshAllUserCodes", False) # if true, during startup, we refresh all the UserCodes the device reports it supports. If False, we stop after we get the first "Available" slot (Some devices have 250+ usercode slots! - That makes our Session Stage Very Long ) self.AddOptionInt("RetryTimeout", RETRY_TIMEOUT) # How long do we wait to timeout messages sent self.AddOptionBool("EnableSIS", True) # Automatically become a SUC if there is no SUC on the network. self.AddOptionBool("AssumeAwake", True) # Assume Devices that Support the Wakeup CC are awake when we first query them.... self.AddOptionBool("NotifyOnDriverUnload", False) # Should we send the Node/Value Notifications on Driver Unloading - Read comments in Driver::~Driver() method about possible race conditions
def proxy_server(self, webserver, port, conn, data, addr): """ This method receive the request of **conn_string** method and sends to this destination. After receive the response return this to client. :param webserver: host :param port: hosts port :param conn: connection socket :param data: request (HTTP message) :param addr: socket address """ try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((webserver, port)) s.send(data) while 1: reply = self.recvall(s) if len(reply) > 0: # Parser().http_to_dict(reply) # Log(reply) if self.do_cache: Cache().store_cache(data, reply) conn.send(reply) # send reply back to client Log('response received!') else: break # break connection if receive data fail s.close() conn.close() except socket.error, (value, message): print "value: " + value print "Message:" + message s.close() conn.close() sys.exit(1)
redis_news_hkey = "snowball.newschema" redis_comments_hkey = "snowball.commentschema" redis_news_list = "snowball.updatenews" redis_comments_list = "snowball.updatecomments" schema_container = "snowballschema" schema_url = "https://financestore.blob.core.windows.net/snowballschema/" user_container = "snowballuser" user_url = "https://financestore.blob.core.windows.net/snowballuser/" text_container = "snowballtext" text_url = "https://financestore.blob.core.windows.net/snowballtext/" source_container = "xueqiu" source_url = "https://financestore.blob.core.windows.net/xueqiu/" log = Log(tag="stdout") redis = Redis(host=host, port=port) blob = BlockBlob() index = redis.hash.get(redis_news_hkey, "index") index = int(index["index"]) def related_code(text): code = set() with open("./dict.pk", 'rb') as f: dict = pickle.load(f) words = jieba.cut(text) for word in words: if word in dict.keys(): code.add(dict[word])
def open_demo_page(self, url): """打开环球网校官网""" self.dr.get(url) Log().info('open url')
def run(self): start() if __name__ == '__main__': if sys.platform == 'linux2OFF': daemon = ServerDaemon(pidfile='/var/run/droidpresd.pid', stdout='/var/log/droidpresd.log', stderr='/var/log/droidpresd.log') if len(sys.argv) == 2: if 'start' == sys.argv[1]: daemon.start() elif 'stop' == sys.argv[1]: daemon.stop() elif 'restart' == sys.argv[1]: daemon.restart() else: print "Unknown command." print "usage: %s start|stop|restart" % sys.argv[0] sys.exit(2) sys.exit(0) else: print "usage: %s start|stop|restart" % sys.argv[0] sys.exit(2) else: try: start() except KeyboardInterrupt: Log('^C received, shutting down server') server.socket.close()
#!/usr/bin/env python from lib.log import Log from settings import CFG G_CFG = CFG() G_LOGGER = Log(G_CFG) # 通用普通交易推送模板 G_PUSH_TEMPLATE = { "Txid": "", "Type": "", "From": "", "To": "", "Amount": "", "Time": "", "BlockNumber": 0, "Contract": "", "Charge": False, # 是否为找零 "Memo": "", # 交易信息 "Fee": 0, # 手续费 "Action": "", # 交易类型 "Valid": "", "VoutsIndex": 0, "status": "unconfirm", # 交易是否生效 } # 以太坊多签名交易推送模板 G_ETH_MULTI_PUSH_TEMPLATE = { "operationId": "", "Txid": "", "owners": "",