Example #1
0
    def _execute(self, options, args):
        """Start the console."""
        self.site.scan_posts()
        # Create nice object with all commands:

        self.site.commands = Commands(self.site.doit, self.config,
                                      self._doitargs)

        self.context = {
            'conf': self.site.config,
            'site': self.site,
            'nikola_site': self.site,
            'commands': self.site.commands,
        }
        if options['bpython']:
            self.bpython(True)
        elif options['ipython']:
            self.ipython(True)
        elif options['plain']:
            self.plain(True)
        else:
            for shell in self.shells:
                try:
                    return getattr(self, shell)(False)
                except ImportError:
                    pass
            raise ImportError
Example #2
0
    def _execute(self, options, args):
        """Start the console."""
        self.site.scan_posts()
        # Create nice object with all commands:

        self.site.commands = Commands(self.site.doit, self.config, self._doitargs)

        self.context = {
            'conf': self.site.config,
            'site': self.site,
            'nikola_site': self.site,
            'commands': self.site.commands,
        }
        if options['command']:
            exec(options['command'], None, self.context)
        elif options['script']:
            with open(options['script']) as inf:
                code = compile(inf.read(), options['script'], 'exec')
            exec(code, None, self.context)
        elif options['bpython']:
            self.bpython(True)
        elif options['ipython']:
            self.ipython(True)
        elif options['plain']:
            self.plain(True)
        else:
            for shell in self.shells:
                try:
                    return getattr(self, shell)(False)
                except ImportError:
                    pass
            raise ImportError