# HG changeset patch # User Jeff Hammel # Date 1371596315 25200 # Node ID f8edfc9c28bab3af57482ee327cbce9119c73a7e # Parent 76eac0c9953a780a18bc6f173bb796000fbbe18c a really hacky way to disable...for temporary sanity and long term backing down from insanity diff -r 76eac0c9953a -r f8edfc9c28ba setup.py --- a/setup.py Fri May 24 14:26:57 2013 -0700 +++ b/setup.py Tue Jun 18 15:58:35 2013 -0700 @@ -20,7 +20,6 @@ 'martINI', 'netifaces', 'pexpect', - 'lxml', ], entry_points=""" # -*- Entry points: -*- diff -r 76eac0c9953a -r f8edfc9c28ba silvermirror/hg.py --- a/silvermirror/hg.py Fri May 24 14:26:57 2013 -0700 +++ b/silvermirror/hg.py Tue Jun 18 15:58:35 2013 -0700 @@ -1,13 +1,20 @@ #!/usr/bin/env python + """ stub for the hg backend of silvermirror """ -import lxml.html -import mercurial +try: + import lxml.html + import mercurial + from mercurial import commands, hg, ui + requirements_fulfilled = True +except ImportError as e: + _import_error = e + requirements_fulfilled = False + import os import sys -from mercurial import commands, hg, ui from optparse import OptionParser def update(host, path): @@ -16,7 +23,7 @@ """ _ui = ui.ui() url = '%s/%s' % (host, path) - try: + try: repo = hg.repository(_ui, path) print 'Updating %s:' % path except Exception, e: @@ -35,7 +42,7 @@ # ui = ui.ui() # files = [ os.path.join(path, f) for f in os.listdir(path) ] # directories = [ f for f in files if os.path.isdir(f) ] - + # repos = [] # for d in directories: # try: @@ -47,7 +54,7 @@ def repositories(url): """ - returns the list of reposotories under a URL of an hg server + returns the list of repositories under a URL of an hg server """ element = lxml.html.parse(url) tds = element.xpath('//tr[position() > 1]/td[1]') @@ -63,6 +70,9 @@ parser.add_option('--list', dest='list', action='store_true', default=False) options, args = parser.parse_args(args) + if not requirements_fulfilled: + # Hack; this should all be better o_O + parser.error("Must have mercurial and lxml packages to use, sorry") if not options.host: parser.print_usage() parser.exit() @@ -82,7 +92,6 @@ os.chdir(options.directory) for repo in repos: update(options.host, repo) - if __name__ == '__main__': main()