コード例 #1
0
 def exposed_handle_cli(self, args):
     args = rpyc.utils.classic.obtain(args)
     log.verbose('Running command `%s` for client.' % ' '.join(args))
     parser = get_parser()
     try:
         options = parser.parse_args(args, file=self.client_out_stream)
     except SystemExit as e:
         if e.code:
             # TODO: Not sure how to properly propagate the exit code back to client
             log.debug(
                 'Parsing cli args caused system exit with status %s.' %
                 e.code)
         return
     # Saving original terminal size to restore after monkeypatch
     original_terminal_info = terminal.terminal_info
     # Monkeypatching terminal_size so it'll work using IPC
     terminal.terminal_info = self._conn.root.terminal_info
     try:
         if not options.cron:
             with capture_output(self.client_out_stream,
                                 loglevel=options.loglevel):
                 self.manager.handle_cli(options)
         else:
             self.manager.handle_cli(options)
     finally:
         # Restoring original terminal_size value
         terminal.terminal_info = original_terminal_info
コード例 #2
0
ファイル: task.py プロジェクト: jmcabrera/Flexget
 def wrapper(self, *args, **kw):
     # Set the task name in the logger and capture output
     from flexget import logger
     with logger.task_logging(self.name, self.id):
         if self.output:
             with capture_output(self.output, loglevel=self.loglevel):
                 return func(self, *args, **kw)
         else:
             return func(self, *args, **kw)
コード例 #3
0
ファイル: task.py プロジェクト: swapdisc/Flexget
 def wrapper(self, *args, **kw):
     # Set the task name in the logger and capture output
     from flexget import logger
     with logger.task_logging(self.name):
         if self.output:
             with capture_output(self.output, loglevel=self.loglevel):
                 return func(self, *args, **kw)
         else:
             return func(self, *args, **kw)
コード例 #4
0
ファイル: ipc.py プロジェクト: H1ghT0p/Flexget
 def exposed_handle_cli(self, args):
     args = rpyc.utils.classic.obtain(args)
     parser = get_parser()
     try:
         options = parser.parse_args(args, raise_errors=True)
     except ParserError as e:
         # Recreate the normal error text to the client's console
         self.client_console('error: ' + e.message)
         e.parser.print_help(self.client_out_stream)
         return
     if not options.cron:
         with capture_output(self.client_out_stream, loglevel=options.loglevel):
             self.manager.handle_cli(options)
     else:
         self.manager.handle_cli(options)
コード例 #5
0
ファイル: ipc.py プロジェクト: thomaswr/Flexget
 def exposed_handle_cli(self, args):
     args = rpyc.utils.classic.obtain(args)
     log.verbose('Running command `%s` for client.' % ' '.join(args))
     parser = get_parser()
     try:
         options = parser.parse_args(args, file=self.client_out_stream)
     except SystemExit as e:
         if e.code:
             # TODO: Not sure how to properly propagate the exit code back to client
             log.debug('Parsing cli args caused system exit with status %s.' % e.code)
         return
     if not options.cron:
         with capture_output(self.client_out_stream, loglevel=options.loglevel):
             self.manager.handle_cli(options)
     else:
         self.manager.handle_cli(options)
コード例 #6
0
ファイル: ipc.py プロジェクト: awesome-python/Flexget
 def exposed_handle_cli(self, args):
     args = rpyc.utils.classic.obtain(args)
     log.verbose('Running command `%s` for client.' % ' '.join(args))
     parser = get_parser()
     try:
         options = parser.parse_args(args, file=self.client_out_stream)
     except SystemExit as e:
         if e.code:
             # TODO: Not sure how to properly propagate the exit code back to client
             log.debug('Parsing cli args caused system exit with status %s.' % e.code)
         return
     if not options.cron:
         with capture_output(self.client_out_stream, loglevel=options.loglevel):
             self.manager.handle_cli(options)
     else:
         self.manager.handle_cli(options)
コード例 #7
0
 def exposed_handle_cli(self, args):
     args = rpyc.utils.classic.obtain(args)
     parser = get_parser()
     try:
         options = parser.parse_args(args, raise_errors=True)
     except ParserError as e:
         # Recreate the normal error text to the client's console
         self.client_console('error: ' + e.message)
         e.parser.print_help(self.client_out_stream)
         return
     if not options.cron:
         with capture_output(self.client_out_stream,
                             loglevel=options.loglevel):
             self.manager.handle_cli(options)
     else:
         self.manager.handle_cli(options)
コード例 #8
0
ファイル: task.py プロジェクト: H1ghT0p/Flexget
    def wrapper(self, *args, **kw):
        # Set the task name in the logger
        from flexget import logger
        old_loglevel = logging.getLogger().getEffectiveLevel()
        new_loglevel = logging.getLevelName(self.options.loglevel.upper())
        if old_loglevel != new_loglevel:
            log.verbose('Setting loglevel to `%s` for this execution.' % self.options.loglevel)
            logging.getLogger().setLevel(new_loglevel)

        with logger.task_logging(self.name):
            try:
                if self.output:
                    with capture_output(self.output, loglevel=new_loglevel):
                        return func(self, *args, **kw)
                else:
                    return func(self, *args, **kw)
            finally:
                if old_loglevel != new_loglevel:
                    log.verbose('Returning loglevel to `%s` after task execution.' % logging.getLevelName(old_loglevel))
                    logging.getLogger().setLevel(old_loglevel)
コード例 #9
0
    def wrapper(self, *args, **kw):
        # Set the task name in the logger
        from flexget import logger
        old_loglevel = logging.getLogger().getEffectiveLevel()
        new_loglevel = logging.getLevelName(self.options.loglevel.upper())
        if old_loglevel != new_loglevel:
            log.verbose('Setting loglevel to `%s` for this execution.' %
                        self.options.loglevel)
            logging.getLogger().setLevel(new_loglevel)

        with logger.task_logging(self.name):
            try:
                if self.output:
                    with capture_output(self.output, loglevel=new_loglevel):
                        return func(self, *args, **kw)
                else:
                    return func(self, *args, **kw)
            finally:
                if old_loglevel != new_loglevel:
                    log.verbose(
                        'Returning loglevel to `%s` after task execution.' %
                        logging.getLevelName(old_loglevel))
                    logging.getLogger().setLevel(old_loglevel)
コード例 #10
0
ファイル: ipc.py プロジェクト: AnthonyGuerreiro/Flexget
 def exposed_handle_cli(self, args):
     args = rpyc.utils.classic.obtain(args)
     log.verbose('Running command `%s` for client.' % ' '.join(args))
     parser = get_parser()
     try:
         options = parser.parse_args(args, file=self.client_out_stream)
     except SystemExit as e:
         if e.code:
             # TODO: Not sure how to properly propagate the exit code back to client
             log.debug('Parsing cli args caused system exit with status %s.' % e.code)
         return
     # Saving original terminal size to restore after monkeypatch
     original_terminal_info = terminal.terminal_info
     # Monkeypatching terminal_size so it'll work using IPC
     terminal.terminal_info = self._conn.root.terminal_info
     try:
         if not options.cron:
             with capture_output(self.client_out_stream, loglevel=options.loglevel):
                 self.manager.handle_cli(options)
         else:
             self.manager.handle_cli(options)
     finally:
         # Restoring original terminal_size value
         terminal.terminal_info = original_terminal_info