diff --git a/bin/swh-objstorage-add-dir b/bin/swh-objstorage-add-dir index c1dd69d..59bdabf 100755 --- a/bin/swh-objstorage-add-dir +++ b/bin/swh-objstorage-add-dir @@ -1,37 +1,37 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # Copyright (C) 2015 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import logging import os import sys from swh.storage import objstorage if __name__ == '__main__': try: root_dir = sys.argv[1] dirname = sys.argv[2] except IndexError: print("Usage: swh-objstorage-add-dir OBJ_STORAGE_DIR DATA_DIR") sys.exit(1) logging.basicConfig(level=logging.INFO) objs = objstorage.ObjStorage(root_dir) dups = 0 for root, _dirs, files in os.walk(dirname): for name in files: path = os.path.join(root, name) with open(path, 'rb') as f: try: objs.add(f.read()) except objstorage.DuplicateObjError: dups += 1 if dups: logging.info('skipped %d duplicate(s) file(s)' % dups) diff --git a/bin/swh-objstorage-fsck b/bin/swh-objstorage-fsck index b277883..67f3851 100755 --- a/bin/swh-objstorage-fsck +++ b/bin/swh-objstorage-fsck @@ -1,28 +1,28 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # Copyright (C) 2015 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import logging import sys from swh.storage import objstorage if __name__ == '__main__': try: root_dir = sys.argv[1] except IndexError: print("Usage: swh-objstorage-add-dir OBJ_STORAGE_DIR") sys.exit(1) logging.basicConfig(level=logging.INFO) objs = objstorage.ObjStorage(root_dir) for obj_id in objs: try: objs.check(obj_id) except objstorage.Error as err: logging.error(err)