本文整理汇总了Python中Actions.actionHandler方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.actionHandler方法的具体用法?Python Actions.actionHandler怎么用?Python Actions.actionHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actions
的用法示例。
在下文中一共展示了Actions.actionHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import actionHandler [as 别名]
def run(self):
# create standard paths
log_path = configuration.var_directory + os.sep + 'automaton.log'
config_path = configuration.conf_directory + 'automaton.conf'
work_path = configuration.var_directory + os.sep + 'workspace'
# create log file
banner = self.banner.split('\n')
self.log = Log.logger(log_path, 1, 1)
self.log.info('Program Started')
for line in banner:
self.log.continuation(line)
# read config files
self.config = configuration.ConfigFile(fname=config_path, log=self.log)
self.log.setLevels(self.config['LogLevel'], self.config['StdoutLevel'])
# create ftp server
self.servers['ftp'] = servers.ftp.HumbleFTPServer(
self,
self.config['FTPHost'],
self.config['AdminUser'],
self.config['AdminPass'],
work_path, self.log)
self.servers['ftp'].serve_on_thread()
# create modules
self.modules = {}
for fullname, settings in self.config['Modules'].iteritems():
try:
names = fullname.split(':')
mod = getattr(modules, names[0])
self.modules[names[1]] = mod.install(log=self.log, **settings)
except AttributeError:
self.log.error('Could not install module (' +
names[0] + ') does not exist.')
except TypeError:
self.log.error('Could not install module (' +
names[0] + ') missing parameters.')
except:
self.log.error('Could not install module (' +
names[0] + ') unkown error.')
else:
self.log.info('Installed module ' +
names[0] + ' as ' + names[1])
# import workspace and setup event handler
self._ws = WorkspaceManager(self.log, work_path)
self.action_handler = \
Actions.actionHandler(self.log, self.config['LocString'])
workspace = self._ws.load()
self.action_handler.scanModule(workspace)
# wait until exit request
self.booting = False
self.log.info('Ready to Run')
while self.running:
try:
time.sleep(100)
except KeyboardInterrupt:
cmd = raw_input('Action (reboot/stop/debug/[none])? ')
if cmd == 'reboot':
self.reset()
elif cmd == 'stop':
self.stop()
elif cmd == 'debug':
self.debug()
else:
pass
self.stop()