-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_terminal.py
93 lines (90 loc) · 3.43 KB
/
run_terminal.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import json
import requests
import urllib3
from classMovieDB import MovieDB
urllib3.disable_warnings()
proxie1s = {"https":"my_proxy"}
db = MovieDB('BaseURL', 'username', 'password' , proxie1s)
db.get_all()
action = input("Choose action: GET, POST, PUT, DELETE, PATCH or END to Exit.\n")
while action != "END":
to_whom = input("Choose: ACTOR, DIRECTOR, MOVIE\n")
if action == "GET":
id_get = input("Which to return?\n")
if to_whom == "ACTOR":
db.get_actor(id_get)
elif to_whom == "DIRECTOR":
db.get_director(id_get)
else:
db.get_movie(id_get)
elif action == "POST":
if to_whom == "ACTOR":
name_give = input("Give name.\n")
birthday_give = input("Give birthday.\n")
db.post_actor(name_give, birthday_give)
elif to_whom == "DIRECTOR":
name_give = input("Give name.\n")
birthday_give = input("Give birthday.\n")
db.post_director(name_give, birthday_give)
else:
name_give = input("Give name.\n")
year_give = input("Give year.\n")
dir_give = input("Give director id.\n")
actor_list = list()
flag = False
while flag == False:
actor_id = input('Actor of the new movie?(for exitting press OK.)\n')
if actor_id == "OK":
flag=True
else:
actor_list.append(actor_id)
db.post_movie(name_give, year_give, dir_give, actor_list)
db.get_all()
elif action == "PUT":
id_get = input("Which to update?\n")
if to_whom == "ACTOR":
name_give = input("Give new name.\n")
birthday_give = input("Give new birthday.\n")
db.put_actor(id_get, name_give, birthday_give)
elif to_whom == "DIRECTOR":
name_give = input("Give new name.\n")
birthday_give = input("Give new birthday.\n")
db.put_director(id_get, name_give, birthday_give)
else:
name_give = input("Give new name.\n")
year_give = input("Give new year.\n")
dir_give = input("Give new director id.\n")
actor_list = list()
flag = False
while flag == False:
actor_id = input('Actor of the movie?(for exitting press OK.)\n')
if actor_id == "OK":
flag=True
else:
actor_list.append(actor_id)
db.put_movie(id_get, name_give, year_give, dir_give, actor_list)
db.get_all()
elif action == "PATCH":
id_get = input("Which to update?\n")
if to_whom == "ACTOR":
name_give = input("Give new name.\n")
db.patch_actor(id_get, name_give)
elif to_whom == "DIRECTOR":
name_give = input("Give new name.\n")
db.patch_director(id_get, name_give)
else:
name_give = input("Give new name.\n")
db.patch_movie(id_get, name_give)
db.get_all()
elif action == "DELETE":
id_get = input("Which to delete?\n")
if to_whom == "ACTOR":
db.delete_actor(id_get)
elif to_whom == "DIRECTOR":
db.delete_director(id_get)
else:
db.delete_movie(id_get)
db.get_all()
else:
print("Wrong action.\n")
action = input("Choose action: GET, POST, PUT, DELETE or END to Exit.\n")