Example #1
0
 def setUp(self):
     self.path = tempfile.mkdtemp(prefix='test_file_archive_')
     FileStore.create_store(self.path)
     self.store = FileStore(self.path)
     testfiles = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                              'testfiles')
     self.t = lambda f: os.path.join(testfiles, f)
Example #2
0
def initialize():
    if configuration.check('file_store'):
        file_store_path = configuration.file_store
    else:
        file_store_path = os.path.join(current_dot_vistrails(), 'file_archive')
    if not os.path.exists(file_store_path) or not os.listdir(file_store_path):
        FileStore.create_store(file_store_path)
    set_default_store(FileStore(file_store_path))
Example #3
0
def main(args):
    warnings.filterwarnings('always', category=UsageWarning)

    usage = _(
        "usage: {bin} <store> create\n"
        "   or: {bin} <store> add <filename> [key1=value1] [...]\n"
        "   or: {bin} <store> write [key1=value1] [...]\n"
        "   or: {bin} <store> query [-d] [-t] [key1=value1] [...]\n"
        "   or: {bin} <store> print [-m] [-t] <filehash> [...]\n"
        "   or: {bin} <store> print [-m] [-t] [key1=value1] [...]\n"
        "   or: {bin} <store> remove [-f] <filehash>\n"
        "   or: {bin} <store> remove [-f] <key1=value1> [...]\n"
        "   or: {bin} <store> verify\n"
        "   or: {bin} <store> view\n",
        bin='file_archive')

    if len(args) < 2:
        sys.stderr.write(usage)
        sys.exit(1)

    store = args[0]
    command = args[1]

    if command == 'create':
        try:
            FileStore.create_store(store)
        except Exception as e:
            sys.stderr.write(_("Can't create store: {err}\n", err=e.args[0]))
            sys.exit(3)
        sys.exit(0)

    try:
        store = FileStore(store)
    except Exception as e:
        sys.stderr.write(_("Invalid store: {err}\n", err=e.args[0]))
        sys.exit(3)

    try:
        try:
            func = commands[command]
        except KeyError:
            sys.stderr.write(usage)
            sys.exit(1)
        try:
            func(store, args[2:])
        except Exception:
            import traceback
            traceback.print_exc()
            sys.exit(3)
    finally:
        store.close()

    sys.exit(0)
Example #4
0
def main(args):
    warnings.filterwarnings('always', category=UsageWarning)

    usage = _(
        "usage: {bin} <store> create\n"
        "   or: {bin} <store> add <filename> [key1=value1] [...]\n"
        "   or: {bin} <store> write [key1=value1] [...]\n"
        "   or: {bin} <store> query [-d] [-t] [key1=value1] [...]\n"
        "   or: {bin} <store> print [-m] [-t] <filehash> [...]\n"
        "   or: {bin} <store> print [-m] [-t] [key1=value1] [...]\n"
        "   or: {bin} <store> remove [-f] <filehash>\n"
        "   or: {bin} <store> remove [-f] <key1=value1> [...]\n"
        "   or: {bin} <store> verify\n"
        "   or: {bin} <store> view\n",
        bin='file_archive')

    if len(args) < 2:
        sys.stderr.write(usage)
        sys.exit(1)

    store = args[0]
    command = args[1]

    if command == 'create':
        try:
            FileStore.create_store(store)
        except Exception as e:
            sys.stderr.write(_("Can't create store: {err}\n", err=e.args[0]))
            sys.exit(3)
        sys.exit(0)

    try:
        store = FileStore(store)
    except Exception as e:
        sys.stderr.write(_("Invalid store: {err}\n", err=e.args[0]))
        sys.exit(3)

    try:
        try:
            func = commands[command]
        except KeyError:
            sys.stderr.write(usage)
            sys.exit(1)
        try:
            func(store, args[2:])
        except Exception:
            import traceback
            traceback.print_exc()
            sys.exit(3)
    finally:
        store.close()

    sys.exit(0)