-
Notifications
You must be signed in to change notification settings - Fork 0
/
bpkg.py
59 lines (49 loc) · 1.76 KB
/
bpkg.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import sys
import os
import shutil
from bundler import bundle
from app_starter import start_app
from extractor import extract
def main():
if not os.path.exists(os.path.expanduser('~/.bpkg')):
os.mkdir(os.path.expanduser('~/.bpkg'))
if len(sys.argv) == 1:
print('Error: No arguments present.')
os.system('python bpkg.py -h')
exit()
# Change this each time version changes
if sys.argv[1] == '-v':
print('bpkg application packaging utility version 1.0.0')
exit()
if sys.argv[1] == '-h':
print(
'''
bpkg syntax - bpkg [-h|-v|start|bundle|extract|cleanup] foldername
bpkg is a tool used to bundle applications.
cleanup - Cleans up the bpkg cache
start - This command is used to start the application.
bundle - This command is used to bundle an application hence the name.
extract - This command is used to extract the contents of an application from its bundle.
'''
)
exit()
if not sys.argv[1] == 'cleanup':
if sys.argv[2] == None:
print('The directory of the project you want to package should be the second argument')
if sys.argv[1] == 'start':
start_app(sys.argv[2])
elif sys.argv[1] == 'cleanup':
for root, dirs, files in os.walk(os.path.expanduser('~/.bpkg')):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
elif sys.argv[1] == 'bundle':
bundle(sys.argv[2])
elif sys.argv[1] == 'extract':
extract(sys.argv[2])
else:
print('bundle, start, cleanup or extract should be present as the second argument')
exit()
if __name__ == '__main__':
main()