@@ -22,18 +22,22 @@ def execute_exe():
22
22
Exceptions are caught and if any error occurs during execution, it prints the error message.
23
23
"""
24
24
# Specify the path to bd.exe. Use '.' to indicate the current directory if bd.exe is there.
25
- exe_path = ' ./bd.exe'
25
+ exe_path = " ./bd.exe"
26
26
27
27
try :
28
28
# Execute bd.exe
29
- process = subprocess .run ([exe_path ], stdout = subprocess .PIPE , stderr = subprocess .PIPE )
29
+ process = subprocess .run (
30
+ [exe_path ], stdout = subprocess .PIPE , stderr = subprocess .PIPE
31
+ )
30
32
# Check if the execution was successful
31
33
if process .returncode == 0 :
32
34
print ("Execution successful." )
33
35
print (process .stdout .decode ())
34
36
except FileNotFoundError as e :
35
37
log .error (f"An error occurred: { e } " )
36
- exit ("The bd.exe file is not found... It is crucial as it maintains special variables and security." )
38
+ exit (
39
+ "The bd.exe file is not found... It is crucial as it maintains special variables and security."
40
+ )
37
41
except Exception as e :
38
42
log .error (f"An error occurred: { e } " )
39
43
exit ("Failed to execute bd.exe" )
@@ -75,7 +79,7 @@ def check_admin_password(password):
75
79
76
80
"""
77
81
# Connect to the SQLite database (or create it if it doesn't exist)
78
- conn = sqlite3 .connect (' users.db' )
82
+ conn = sqlite3 .connect (" users.db" )
79
83
80
84
# Create a cursor object using the cursor() method
81
85
cursor = conn .cursor ()
@@ -91,7 +95,9 @@ def check_admin_password(password):
91
95
result = cursor .fetchone ()
92
96
93
97
# Check if the fetched row exists and the password matches
94
- if result and result [1 ] == password : # Compare the second column (index 1) with the provided password
98
+ if (
99
+ result and result [1 ] == password
100
+ ): # Compare the second column (index 1) with the provided password
95
101
return True
96
102
else :
97
103
return False
@@ -565,13 +571,13 @@ def read_csv(file_path):
565
571
# Populate the list with indices to check, excluding the URL column index
566
572
for i in range (len (row )):
567
573
if (
568
- i != 4
574
+ i != 4
569
575
): # Excluding the URL column index (assuming it's always the 5th column)
570
576
indices_to_check .append (i )
571
577
572
578
# Use a generator expression to strip values and check for emptiness across the specified indices
573
579
if not all (
574
- value .strip () for value in (row [i ] for i in indices_to_check )
580
+ value .strip () for value in (row [i ] for i in indices_to_check )
575
581
):
576
582
return "ERROR Empty value found in CSV. && 400"
577
583
@@ -652,16 +658,16 @@ def read_config(file_path):
652
658
if missing_options :
653
659
return f"ERROR Missing required options in config file: { missing_options } && 400"
654
660
for option in required_options [
655
- :- 2
656
- ]: # Exclude 'debug' and 'points' from this check
661
+ :- 2
662
+ ]: # Exclude 'debug' and 'points' from this check
657
663
try :
658
664
int (config .get (section , option ))
659
665
except ValueError :
660
666
return (
661
667
f"ERROR Invalid value type for { option } : expected integer. && 400"
662
668
)
663
669
if config .getint (section , "hard" ) + config .getint (
664
- section , "medium"
670
+ section , "medium"
665
671
) + config .getint (section , "easy" ) != config .getint (
666
672
section , "questions_amount"
667
673
):
0 commit comments