-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathenter-staej.py
38 lines (32 loc) · 1.33 KB
/
enter-staej.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import argparse
import shutil
# check & create software data directory
dir_config = os.path.expandvars('$APPDATA/staej').replace('$APPDATA', os.path.expanduser('~/.config'))
dir_tasks = os.path.join(dir_config, 'tasks')
os.makedirs(dir_tasks, exist_ok=True)
# look at arguments
parser = argparse.ArgumentParser(description='staej command line interface')
parser.add_argument('zipfile', nargs='*', help='path of the JIGSAWS zip file')
parser.add_argument('--db', action='store_const', const=True, default=False,
help='create or recreate the working SQLite database')
args = parser.parse_args()
# copy database
file_db = os.path.join(dir_config, 'staej.sqlite')
if args.db or not os.path.exists(file_db) :
shutil.copyfile('template.sqlite', file_db)
if len(args.zipfile) > 0 :
from import_zip import extract_videos
for file_name in args.zipfile :
basename = os.path.basename(file_name).rpartition('.')[0]
try :
print(basename, ':', 'start')
name = extract_videos(file_name, globals())
if name :
print(basename, ':', 'done')
else :
print(basename, ':', 'failed')
except StopIteration as e: # Exception as e :
print(basename, ':', e)
import traceback
traceback.print_exc()