Skip to content

Commit

Permalink
Add the ability to ignore packages or specific versions through a set…
Browse files Browse the repository at this point in the history
…ting.
  • Loading branch information
adamfast committed Sep 16, 2012
1 parent 8db8ac0 commit 684689f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
8 changes: 8 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ PIL (1.1.7 < 1.1.6)

It's a simple app / function, but will save me (and hopefully you) time and be easily installable on everything you do.

If you want to ignore versions (for instance you're tracking django-haystack on git, or want to make sure python-dateutil doesn't recommend you go to the 2.x branch with your app on Python 2.x) you can add LIBRARYWATCH_IGNORE_VERSIONS to your settings file.

LIBRARYWATCH_IGNORE_VERSIONS = {
'python-dateutil': '*', # 2.x series it recommends is not for Python 2.x
'django-haystack': '*', # running from git MASTER
'PIL': '1.1.6', # running 1.1.7 which doesn't appear to be on PyPI
}

Future ideas:
- Track versions to allow ignoring when newer versions aren't backwards compatible so you absolutely DON'T want to upgrade.
- Handle projects with multiple versions availabe better (i.e.) python-dateutil with 2.0 for Py3k only, 1.x series for Python 2.x)
Expand Down
25 changes: 15 additions & 10 deletions librarywatch/management/commands/check_for_updates.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pip
import xmlrpclib

from django.conf import settings
from django.core.management.base import BaseCommand, CommandError

'''
Expand All @@ -16,15 +17,19 @@
class Command(BaseCommand):
def handle(self, *args, **options):
pypi = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
for dist in pip.get_installed_distributions():
available = pypi.package_releases(dist.project_name)
if not available:
# Try to capitalize pkg name
available = pypi.package_releases(dist.project_name.capitalize())

try:
if available[0] != dist.version:
print '{dist.project_name} ({dist.version} != {available})'.format(dist=dist, available=available[0])
ignores = getattr(settings, 'LIBRARYWATCH_IGNORE_VERSIONS', {})

except IndexError:
pass
for dist in pip.get_installed_distributions():
if ignores.get(dist.project_name, '') != '*': # if it's totally ignored, don't even check.
available = pypi.package_releases(dist.project_name)
if not available:
# Try to capitalize pkg name
available = pypi.package_releases(dist.project_name.capitalize())

try:
if available[0] != dist.version and available[0] != ignores.get(dist.project_name, ''):
print '{dist.project_name} ({dist.version} != {available})'.format(dist=dist, available=available[0])

except IndexError:
print('%s is not available on PyPI.' % dist.project_name)

0 comments on commit 684689f

Please sign in to comment.