当前位置: 首页>>代码示例>>Python>>正文


Python Actions.actionHandler方法代码示例

本文整理汇总了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()
开发者ID:automicus,项目名称:Automaton,代码行数:72,代码来源:HumbleAutomaton.py


注:本文中的Actions.actionHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。