Skip to content
Permalink
Browse files

fix #1767

  • Loading branch information
ralsina committed Jun 5, 2015
1 parent 3469045 commit aa06862d121b2d19efa1ca9018586dea5bc89b07
Showing with 28 additions and 0 deletions.
  1. +1 −0 CHANGES.txt
  2. +27 −0 nikola/plugins/command/version.py
@@ -4,6 +4,7 @@ New in master
Features
--------

* New ``nikola version --check`` option (Issue #1767)
* Add ipython support to the default themes (Issue #1782)
* Automatically mark ipynb posts/pages as requiring mathjax (Issue #1782)
* New --get-path option for ``nikola install_theme`` (Issue #1762)
@@ -26,9 +26,18 @@

from __future__ import print_function

import lxml
try:
import requests
except ImportError:
requests = None

from nikola.plugin_categories import Command
from nikola.utils import req_missing
from nikola import __version__

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


class CommandVersion(Command):
"""Print the version."""
@@ -38,7 +47,25 @@ class CommandVersion(Command):
doc_usage = ""
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['check']:
if requests is None:
req_missing(['requests'], 'check for updates')
exit(1)
data = requests.get(URL).text
doc = lxml.etree.fromstring(data.encode('utf8'))
revision = doc.findall('*//{http://usefulinc.com/ns/doap#}revision')[0].text
print("Latest version is: ", revision)

0 comments on commit aa06862

Please sign in to comment.
You can’t perform that action at this time.