-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
66 lines (52 loc) · 2.13 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
class color:
CYAN = '\033[96m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
print(color.BOLD + color.CYAN + color.UNDERLINE + '\nWelcome to Cricket Wizard! Our CMPT 353 Final Project.\n' + color.END)
print('This is an analysis of a method to predict T20 fixture results and its batting/bowling averages:\n')
print('1- 2018 IPL Match and championship prediction.')
print('2- 2018 IPL Batting/Bowling averages prediction.\n')
value = input("Please enter the results that you are intrested to see.(1 or 2):\n")
while (value != '1' and value != '2'):
value = input(color.RED + 'Wrong entry type! Please re-enter your answer in form of "1" or "2":\n' + color.END)
if(value == "1"):
file_name = 'python ipl_predictor_script.py'
if(value == "2"):
file_name = 'python index.py'
secondary_check = value
print('\n')
# https://stackoverflow.com/questions/18739239/python-how-to-get-stdout-after-running-os-system
result_code = os.system(file_name + ' > output.txt')
if os.path.exists('output.txt'):
fp = open('output.txt', "r")
output = fp.read()
fp.close()
os.remove('output.txt')
print(output)
if(value == "1"):
value = input(color.CYAN + "Would you like to see batting averages as well?(y or n):\n" + color.END)
if(value == '2'):
value = '0'
if(value == "2"):
value = input(color.CYAN + "Would you like to see IPL prediction as well?(y or n):\n" + color.END)
if (value == 'y' or 'Y'):
if (secondary_check == '1'):
file_name = 'python index.py'
if (secondary_check == '2'):
file_name = 'python ipl_predictor_script.py'
while (value != 'y' and value != 'Y' and value != 'N' and value != 'n'):
value = input(color.RED + 'Wrong entry type! Please re-enter your answer in form of "y" or "n":\n' + color.END)
if(value != 'n' and value != 'N'):
print('\n')
result_code = os.system(file_name + ' > output.txt')
if os.path.exists('output.txt'):
fp = open('output.txt', "r")
output = fp.read()
fp.close()
os.remove('output.txt')
print(output)
print('\nThank you for using The Cricket Wizard!\n')
print(color.BOLD + color.CYAN + 'Josie Buter\nPooya Jamali\nLakshay Sethi\n')