aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/plugins/command_console.py
diff options
context:
space:
mode:
authorLibravatarAgustin Henze <tin@sluc.org.ar>2013-03-13 20:58:39 -0300
committerLibravatarAgustin Henze <tin@sluc.org.ar>2013-03-13 20:58:39 -0300
commit1004b9f3c61574acbdb3ec2f303d35307949fb7e (patch)
tree3ae41121a82650e6889fda82a4316f989dfc0b4b /nikola/plugins/command_console.py
parent1c7c74d71f5dc9d13d029c9df8d46f27907a7503 (diff)
parent8b14a1e5b2ca574fdd4fd2377567ec98a110d4b6 (diff)
Merge tag 'upstream/5.4.2'
Upstream version 5.4.2
Diffstat (limited to 'nikola/plugins/command_console.py')
-rw-r--r--nikola/plugins/command_console.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/nikola/plugins/command_console.py b/nikola/plugins/command_console.py
index 7a009fd..4af759f 100644
--- a/nikola/plugins/command_console.py
+++ b/nikola/plugins/command_console.py
@@ -22,6 +22,8 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+from __future__ import print_function, unicode_literals
+
import os
from nikola.plugin_categories import Command
@@ -31,5 +33,31 @@ class Deploy(Command):
"""Start debugging console."""
name = "console"
- def run(self, *args):
- os.system('python -i -c "from nikola.console import *"')
+ def _execute(self, options, args):
+ """Start the console."""
+ from nikola import Nikola
+ try:
+ import conf
+ SITE = Nikola(**conf.__dict__)
+ SITE.scan_posts()
+ print("You can now access your configuration as conf and your "
+ "site engine as SITE.")
+ except ImportError:
+ print("No configuration found.")
+ import code
+ try:
+ import readline
+ except ImportError:
+ pass
+ else:
+ import rlcompleter
+ readline.set_completer(rlcompleter.Completer(globals()).complete)
+ readline.parse_and_bind("tab:complete")
+
+ pythonrc = os.environ.get("PYTHONSTARTUP")
+ if pythonrc and os.path.isfile(pythonrc):
+ try:
+ execfile(pythonrc) # NOQA
+ except NameError:
+ pass
+ code.interact(local=globals())