From e9e152ca7d2dd92a1a21505c2dce2d7c419df49a Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Sat, 7 Dec 2013 00:27:59 -0800 Subject: [PATCH] tox (and travis ci?) were hiding the fact that the gdbm dependency was the problem --- .travis.yml | 3 +++ bin/dump-anydbm | 22 +++++++++++++++++----- setup.py | 2 +- tox.ini | 3 +-- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 027464c..ffa0e6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,9 @@ python: - "2.7" - "3.2" - "3.3" +before_install: + - sudo apt-get update + - sudo apt-get -y install python-gdbm python3-gdbm install: python setup.py install script: python setup.py test diff --git a/bin/dump-anydbm b/bin/dump-anydbm index 4cc9aff..f1f8a42 100755 --- a/bin/dump-anydbm +++ b/bin/dump-anydbm @@ -8,19 +8,31 @@ module can read. Included with warcprox because it's useful for inspecting a deduplication database or a playback index database, but it is a generic tool. """ -import anydbm +try: + import dbm + whichdb = dbm.whichdb +except: + import anydbm + dbm = anydbm + from whichdb import whichdb + import sys +import os.path if __name__ == "__main__": if len(sys.argv) != 2: sys.stderr.write("usage: {} DBM_FILE\n".format(sys.argv[0])) exit(1) - # import whichdb - # which = whichdb.whichdb(sys.argv[1]) - # print('{} is a {} db'.format(sys.argv[1], which)) + if not os.path.exists(sys.argv[1]): + sys.stderr.write('No such file {}\n\n'.format(sys.argv[1])) + sys.stderr.write("usage: {} DBM_FILE\n".format(sys.argv[0])) + exit(1) - db = anydbm.open(sys.argv[1]) + which = whichdb(sys.argv[1]) + print('{} is a {} db'.format(sys.argv[1], which)) + + db = dbm.open(sys.argv[1], 'r') for key in db.keys(): print("{}:{}".format(key, db[key])) diff --git a/setup.py b/setup.py index b637a99..98ffcbf 100755 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setuptools.setup(name='warcprox', long_description=open('README.rst').read(), license='GPL', packages=['warcprox'], - install_requires=['pyopenssl', 'warctools>=4.8.3'], # gdbm/dbhash? + install_requires=['gdbm', 'pyopenssl', 'warctools>=4.8.3'], dependency_links=['git+https://github.com/nlevitt/warctools.git@python3#egg=warctools-4.8.3'], tests_require=['requests>=2.0.1'], # >=2.0.1 for https://github.com/kennethreitz/requests/pull/1636 test_suite='warcprox.tests', diff --git a/tox.ini b/tox.ini index 1c70ded..811b04d 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,6 @@ envlist = py27, py32, py33 [testenv] +sitepackages = True commands = {envpython} setup.py test -# commands = {envpython} -m unittest discover -# deps = requests>=2.0.1