Skip to content

Commit

Permalink
Fix #3170 — make nikola version --check work again
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Sep 30, 2018
1 parent f58ba9a commit 1a44901
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -10,6 +10,7 @@ Features
Bugfixes
--------

* Make ``nikola version --check`` work again (Issue #3170)
* Set logging level for reST to warning in order to limit noise
* Fix docinfo removal for sites that use reST docinfo metadata
(Issue #3167)
Expand Down
13 changes: 7 additions & 6 deletions nikola/plugins/command/version.py
Expand Up @@ -33,7 +33,7 @@
from nikola.plugin_categories import Command
from nikola import __version__

URL = 'https://pypi.python.org/pypi?:action=doap&name=Nikola'
URL = 'https://pypi.org/pypi/Nikola/json'


class CommandVersion(Command):
Expand All @@ -59,10 +59,11 @@ 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__:
data = requests.get(URL).json()
pypi_version = data['info']['version']
if pypi_version == __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))
print("The latest version of Nikola is v{0}. Please upgrade "
"using `pip install --upgrade Nikola=={0}` or your "
"system package manager.".format(pypi_version))

0 comments on commit 1a44901

Please sign in to comment.