forked from SashaCX75/py_amazfit_tools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
42 lines (36 loc) · 1.5 KB
/
main.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
39
40
41
42
import os
import logging
from watchFaceParser.config import Config
if __name__ == '__main__':
import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--gtr', action='store_true', help='force GTR watchface')
parser.add_argument('filename', nargs='+', help='''watchface.bin - unpacks watchface images and config
watchface.json - packs config and referenced images to bin file''')
args = parser.parse_args()
Config.setGtrMode(args.gtr)
for inputFileName in args.filename:
isDirectory = os.path.isdir(inputFileName)
isFile = os.path.isfile(inputFileName)
if not isDirectory and not isFile:
print("File or direcotry %s doesn't exists." % (inputFileName, ))
continue
if isDirectory:
print("Not supported yet.")
sys.exit(1)
_, inputFileExtension = os.path.splitext(inputFileName)
try:
import program
if inputFileExtension == '.bin':
program.Parser.unpackWatchFace(inputFileName)
elif inputFileExtension == '.json':
program.Parser.packWatchFace(inputFileName)
else:
print("The app doesn't support file with extension %s." % (inputFileExtension, ))
print("Done")
except Exception as e:
print('[Fatal] %s' % (e, ))
import traceback
traceback.print_stack()
logging.exception(e)