Skip to content

Instantly share code, notes, and snippets.

@ericoporto
Created August 28, 2016 23:19
Show Gist options
  • Save ericoporto/f254a3e103b3be6c2e1a21db2108e532 to your computer and use it in GitHub Desktop.
Save ericoporto/f254a3e103b3be6c2e1a21db2108e532 to your computer and use it in GitHub Desktop.
how to check if version is latest
from distutils.version import StrictVersion
from fgmk import __version__
try:
import xmlrpclib
except ImportError:
import xmlrpc.client as xmlrpclib
def is_this_newest():
try:
pypi = xmlrpclib.ServerProxy('https://pypi.python.org/pypi')
newest_version = pypi.package_releases('fgmk')[0]
this_v = StrictVersion(__version__)
new_v = StrictVersion(newest_version)
return this_v >= new_v
except Exception as e:
return 'failed'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment