Navigation Menu

Skip to content

Commit

Permalink
fix #1767
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Jun 5, 2015
1 parent 3469045 commit aa06862
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions nikola/plugins/command/version.py
Expand Up @@ -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."""
Expand All @@ -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.