def init(url): timestamp = str(time()).replace('.', '')[-3:] store.init(timestamp) swap.init(timestamp) db.metadata().create_all(db.engine()) swap.current.push(url)
def init(command=None): args = configure_cmdline(command) if command is None: command = args.command single = args.single configure_logging() logging.debug("Starting sdnalyzer.") configuration = None config_file_path = "/etc/sdnalytics/sdnalytics.json" if not os.path.isfile(config_file_path): print "Run sdn-ctl setup before executing sdn-observe or sdn-analyze" #"Copy sdnalyzer.default.json to " + config_file_path + " and adapt the file according to your setup. Then start this program again." return with open(config_file_path) as config_file: configuration = json.loads(config_file.read()) if "connectionString" not in configuration: raise Exception("No connection string configured in sdnalyzer.json.") store.start(configuration["connectionString"]) if "api" in configuration: if "port" in configuration["api"]: api_port = int(configuration["api"]["port"]) if "username" in configuration["api"]: api_username = configuration["api"]["username"] if "password" in configuration["api"]: api_password = configuration["api"]["password"] if command == "observe" or command == "analyze": command += "r" if command == "setup": store.init() print "Successfully setup the database. You can now use sdn-analyze and sdn-observe monitor your network." elif command == "reset": store.drop() store.init() print "Successfully reset the database. All previously gathered data has been discarded." elif command == "observer": program_state = start_api(command, api_username, api_password, api_port + 1) import observer poll_interval = 30 if "pollInterval" in configuration: poll_interval = int(configuration["pollInterval"]) if "controller" in configuration: if "host" in configuration["controller"]: controller_host = configuration["controller"]["host"] if "port" in configuration["controller"]: controller_port = configuration["controller"]["port"] program_state.instance = observer.Observer(controller_host, controller_port) program_state.instance.observe(single, poll_interval, program_state) elif command == "analyzer": program_state = start_api(command, api_username, api_password, api_port + 2) import analyzer program_state.instance = analyzer.Analyzer() program_state.instance.analyze(single, program_state) elif command == "adhoc": import adhoc adhoc.run() else: logging.error("Invalid command {}.".format(command)) logging.debug("Shut down.")
def init(command=None): args = configure_cmdline(command) if command is None: command = args.command single = args.single configure_logging() logging.debug("Starting sdnalyzer.") configuration = None config_file_path = "/etc/sdnalytics/sdnalytics.json" if not os.path.isfile(config_file_path): print "Run sdn-ctl setup before executing sdn-observe or sdn-analyze" #"Copy sdnalyzer.default.json to " + config_file_path + " and adapt the file according to your setup. Then start this program again." return with open(config_file_path) as config_file: configuration = json.loads(config_file.read()) if "connectionString" not in configuration: raise Exception( "No connection string configured in sdnalyzer.json.") store.start(configuration["connectionString"]) if "api" in configuration: if "port" in configuration["api"]: api_port = int(configuration["api"]["port"]) if "username" in configuration["api"]: api_username = configuration["api"]["username"] if "password" in configuration["api"]: api_password = configuration["api"]["password"] if command == "observe" or command == "analyze": command += "r" if command == "setup": store.init() print "Successfully setup the database. You can now use sdn-analyze and sdn-observe monitor your network." elif command == "reset": store.drop() store.init() print "Successfully reset the database. All previously gathered data has been discarded." elif command == "observer": program_state = start_api(command, api_username, api_password, api_port + 1) import observer poll_interval = 30 if "pollInterval" in configuration: poll_interval = int(configuration["pollInterval"]) if "controller" in configuration: if "host" in configuration["controller"]: controller_host = configuration["controller"]["host"] if "port" in configuration["controller"]: controller_port = configuration["controller"]["port"] program_state.instance = observer.Observer(controller_host, controller_port) program_state.instance.observe(single, poll_interval, program_state) elif command == "analyzer": program_state = start_api(command, api_username, api_password, api_port + 2) import analyzer program_state.instance = analyzer.Analyzer() program_state.instance.analyze(single, program_state) elif command == "adhoc": import adhoc adhoc.run() else: logging.error("Invalid command {}.".format(command)) logging.debug("Shut down.")
@itchat.msg_register(itchat.content.TEXT,isGroupChat=True) def text_reply(msg): response = record.reply(msg) if not record.none_or_empty(response): return msg.user.send(response) #print(response) if __name__=='__main__': if len(sys.argv)<2: logger.debug('请指定群聊名称') sys.exit(1) room = sys.argv[1].strip() store.init() itchat.auto_login() record.update_members(room) itchat.run(debug=True,blockThread=True) # text='#run分结束啦20.3/49.3/150.3' # keys = extra(text) # text='#run得劲20.3/49.3/150.3' # keys = extra(text)
def move(self, data): dir = [0, 0] if data.up: dir[1] -= 10 if data.down: dir[1] += 10 if data.left: dir[0] -= 10 if data.right: dir[0] += 10 self.x += dir[0] self.y += dir[1] if not self.legalPos(data): self.x -= dir[0] if not self.legalPos(data): self.x += dir[0] self.y -= dir[1] if not self.legalPos(data): self.x -= dir[0] if data.roomCleared: if self.x < self.r and data.endBehavior[0] != "": if isinstance(data.endBehavior[0], int): data.mode = "game" if data.endBehavior[0] == 2: levels.room2(data) elif data.endBehavior[0] == 3: levels.room3(data) else: levels.room1(data) return elif data.endBehavior[0] == "Store": data.mode = "store" store.init(data) elif self.x > data.width - self.r: if isinstance(data.endBehavior[2], int): data.mode = "game" if data.endBehavior[2] == 2: levels.room2(data) elif data.endBehavior[2] == 3: levels.room3(data) else: levels.room1(data) return elif data.endBehavior[2] == "Store": data.mode = "store" store.init(data) elif self.y < self.r: if isinstance(data.endBehavior[1], int): data.mode = "game" if data.endBehavior[1] == 2: levels.room2(data) elif data.endBehavior[1] == 3: levels.room3(data) else: levels.room1(data) return elif data.endBehavior[1] == "Store": data.mode = "store" store.init(data) elif self.y > data.height - self.r: if isinstance(data.endBehavior[3], int): data.mode = "game" if data.endBehavior[3] == 2: levels.room2(data) elif data.endBehavior[3] == 3: levels.room3(data) else: levels.room1(data) return elif data.endBehavior[3] == "Store": data.mode = "store" store.init(data) if self.x < self.r: self.x = self.r elif self.x > data.width - self.r: self.x = data.width - self.r if self.y < self.r: self.y = self.r elif self.y > data.height - self.r: self.y = data.height - self.r