コード例 #1
0
ファイル: base.py プロジェクト: zimagi/zimagi
    def bootstrap(self, options):
        Cipher.initialize()

        if options.get('debug', False):
            Runtime.debug(True)

        if options.get('no_parallel', False):
            Runtime.parallel(False)

        if options.get('no_color', False):
            Runtime.color(False)

        if options.get('display_width', False):
            Runtime.width(options.get('display_width'))

        self.init_environment()

        if self.bootstrap_ensure() and settings.CLI_EXEC:
            self._user._ensure(self)

        self.set_options(options, True)

        if self.bootstrap_ensure() and settings.CLI_EXEC:
            self.ensure_resources()

        if self.initialize_services():
            self.manager.initialize_services(settings.STARTUP_SERVICES)
        return self
コード例 #2
0
ファイル: cli.py プロジェクト: mbeacom/zimagi
 def handle_error(self, error):
     if not isinstance(error, CommandError):
         self.print('** ' + self.error_color(error.args[0]), sys.stderr)
         if Runtime.debug():
             self.print('> ' + self.traceback_color("\n".join(
                 [item.strip() for item in format_exception_info()])),
                        stream=sys.stderr)
コード例 #3
0
ファイル: base.py プロジェクト: mbeacom/zimagi
    def bootstrap(self, options, primary = False):
        if primary:
            if options.get('debug', False):
                Runtime.debug(True)

            if options.get('no_parallel', False):
                Runtime.parallel(False)

            if options.get('no_color', False):
                Runtime.color(False)

            if options.get('display_width', False):
                Runtime.width(options.get('display_width'))

        self._environment._ensure(self)
        self._user._ensure(self)

        self.set_options(options)
        if primary and self.bootstrap_ensure():
            self.ensure_resources()
コード例 #4
0
ファイル: messages.py プロジェクト: mbeacom/zimagi
 def format(self, debug=False, disable_color=False, width=None):
     message = self.message if disable_color else self.error_color(
         self.message)
     if Runtime.debug() or debug:
         traceback = [item.strip() for item in self.traceback]
         traceback_message = "\n".join(
             traceback) if disable_color else self.traceback_color(
                 "\n".join(traceback))
         return "\n{}** {}\n\n> {}\n".format(
             self._format_prefix(disable_color), message, traceback_message)
     return "{}** {}".format(self._format_prefix(disable_color), message)
コード例 #5
0
ファイル: cli.py プロジェクト: mbeacom/zimagi
    def initialize(self):
        django.setup()

        parser = CommandParser(add_help=False, allow_abbrev=False)
        parser.add_argument('args', nargs='*')
        namespace, extra = parser.parse_known_args(self.argv[1:])
        args = namespace.args

        if not args:
            args = ['help']

        if '--debug' in extra:
            Runtime.debug(True)

        if '--no-color' in extra:
            Runtime.color(False)

        if not settings.NO_MIGRATE and args and args[0] not in (
                'check', 'migrate', 'makemigrations'):
            verbosity = 3 if Runtime.debug() else 0
            start_time = time.time()
            current_time = start_time

            while (current_time - start_time) <= settings.AUTO_MIGRATE_TIMEOUT:
                try:
                    call_command('migrate',
                                 interactive=False,
                                 verbosity=verbosity)
                    break

                except Exception:
                    pass

                time.sleep(settings.AUTO_MIGRATE_INTERVAL)
                current_time = time.time()

        return args
コード例 #6
0
ファイル: base.py プロジェクト: mbeacom/zimagi
 def debug(self):
     return self.options.get('debug', Runtime.debug())