diff options
| author | 2015-07-08 07:35:02 -0300 | |
|---|---|---|
| committer | 2015-07-08 07:35:02 -0300 | |
| commit | b0b24795b24ee6809397fbbadf42f31f310a219f (patch) | |
| tree | 46d05bb47460b4ec679211717c4ab07414b80d9c /nikola/plugins/command/version.py | |
| parent | 5ec02211214350ee558fd9f6bb052264fd24f75e (diff) | |
Imported Upstream version 7.6.0upstream/7.6.0
Diffstat (limited to 'nikola/plugins/command/version.py')
| -rw-r--r-- | nikola/plugins/command/version.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/nikola/plugins/command/version.py b/nikola/plugins/command/version.py index 9b42423..b6520d7 100644 --- a/nikola/plugins/command/version.py +++ b/nikola/plugins/command/version.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2012-2014 Roberto Alsina and others. +# Copyright © 2012-2015 Roberto Alsina and others. # Permission is hereby granted, free of charge, to any # person obtaining a copy of this software and associated @@ -26,19 +26,42 @@ from __future__ import print_function +import lxml +import requests + from nikola.plugin_categories import Command from nikola import __version__ +URL = 'https://pypi.python.org/pypi?:action=doap&name=Nikola' + class CommandVersion(Command): """Print the version.""" name = "version" - doc_usage = "" + doc_usage = "[--check]" needs_config = False doc_purpose = "print the Nikola version number" + cmd_options = [ + { + 'name': 'check', + 'long': 'check', + 'short': '', + 'default': False, + 'type': bool, + 'help': "Check for new versions.", + } + ] def _execute(self, options={}, args=None): """Print the version number.""" print("Nikola v" + __version__) + if options.get('check'): + data = requests.get(URL).text + doc = lxml.etree.fromstring(data.encode('utf8')) + revision = doc.findall('*//{http://usefulinc.com/ns/doap#}revision')[0].text + if revision == __version__: + print("Nikola is up-to-date") + else: + print("The latest version of Nikola is v{0} -- please upgrade using `pip install --upgrade Nikola=={0}` or your system package manager".format(revision)) |
