-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
36 lines (32 loc) · 820 Bytes
/
manage.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
import sys
from app.search_parser import SearchEngine
help = '''
Usage: manage.py command [args]
Commands:
help
search, args="search query in quotation marks"
export, args=(1/0) - dump media files or not
'''
if __name__ == '__main__':
try:
command = sys.argv[1]
except IndexError:
command = 'help'
se = SearchEngine()
if command == 'help':
print(help)
elif command == 'search':
try:
for i in range(2, len(sys.argv)):
print(sys.argv[i])
se.start(sys.argv[i])
except IndexError:
print('Invalid command!')
elif command == 'export':
try:
media = sys.argv[2]
except IndexError:
media = 0
se.write_json(media)
else:
print('Invalid command!')