-
Notifications
You must be signed in to change notification settings - Fork 2
/
cater.py
112 lines (89 loc) · 3.19 KB
/
cater.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
## importing modules
from shareBox import server as sender
from shareBox import client as receiver
from random import randint
######################
## banner printer
def printBanner():
## defining the banner
banner=''' 888
888
888
.d8888b 8888b. 888888 .d88b. 888d888 8888b. 88888b. 88888b.
d88P" "88b 888 d8P Y8b 888P" "88b 888 "88b 888 "88b
888 .d888888 888 88888888 888 .d888888 888 888 888 888
Y88b. 888 888 Y88b. Y8b. 888 888 888 888 d88P 888 d88P
"Y8888P "Y888888 "Y888 "Y8888 888 "Y888888 88888P" 88888P"
888 888
______________________________________________________ 888 ____ 888 _____
888 888
Using v1.1 888 888 '''
## printing greeting
print("\n welcome to:",end="")
## choosing a color banner
colorCode = 31 + randint(1,100) % 7
BANNERCOLOR = '\033[' + str(colorCode) + 'm' # 31 to 37
## printting the banner
print(BANNERCOLOR + banner)
## resetting the colors
BANNERCOLOR = '\033[m'
print(BANNERCOLOR + "")
return
######################################
class cater():
def __init__(self, menuOption=""):
## greeting
printBanner()
## menu
self.__mainMenu = "\n Menu\n"+"-"*6+"\n\n1. Send Files! \n2. Receive Files!"+menuOption
self.choice = self.__menu__()
## main menu
def __menu__(self):
print(self.__mainMenu)
ch = input("\nEnter your choice: ")
return ch
## mainApp
def cater(self):
## making host to share files
if self.choice == '1':
Sender = sender.server()
print("\n"+"-"*20+"\n")
Sender.server()
return True
## making client to get files
elif self.choice == '2':
Receiver = receiver.client()
print("\n"+"-"*20+"\n")
Receiver.client()
return True
## invalid input
else:
print("\n"+"-"*20+"\n")
return False
## if ran at least once
flag = False
######################
def app():
flag = True
firstRun = True
addOnMenu = ''
while flag:
## creating an instance
caterApp = cater(addOnMenu)
## sharing the files
flag = caterApp.cater()
## adding exit choice in menu
if flag and firstRun:
firstRun = False
if firstRun is False:
addOnMenu = "\n* Any other key to exit!!"
## deleting current instence on Secreat Share App
del(caterApp)
## exit prompt
if firstRun:
print("\nSomething went wrong!!\nApp terminated unexpectedly!!")
else:
print("\nThanks for using 'cater'!\n")
#############################################
if __name__ == '__main__':
app()