2022-03-21 22:55:30 +00:00
|
|
|
import os
|
|
|
|
|
import subprocess as sp
|
|
|
|
|
from time import sleep
|
|
|
|
|
|
|
|
|
|
accounts = ["username", "username"]
|
|
|
|
|
os.chdir("C://Users/joshu/Documents/Uni/CSY1026/scripts/")
|
|
|
|
|
runFlag = True
|
|
|
|
|
|
|
|
|
|
while runFlag:
|
2022-03-21 23:04:24 +00:00
|
|
|
account_choice = int(input("\nWhich account would you like to log into?\n1) Normal\n2) Coursework\n>"))
|
2022-03-21 22:55:30 +00:00
|
|
|
|
2022-03-21 23:04:24 +00:00
|
|
|
if (account_choice == 1 or account_choice == 2):
|
2022-03-21 22:55:30 +00:00
|
|
|
runFlag = False
|
|
|
|
|
else:
|
|
|
|
|
print("\nIncorrect Input\n")
|
|
|
|
|
input("Press Enter to continue...\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("\nHere are your available scripts:\n")
|
|
|
|
|
files = [f for f in os.listdir(".") if os.path.isfile(f)]
|
|
|
|
|
runFlag = True
|
|
|
|
|
|
|
|
|
|
while runFlag:
|
|
|
|
|
os.chdir("C://Users/joshu/Documents/Uni/CSY1026/scripts/")
|
|
|
|
|
for i in range(0,len(files)):
|
|
|
|
|
print(files[i][:len(files[i])-4])
|
|
|
|
|
|
|
|
|
|
choice = input("\nWhat would you like to do? \nform: 'command file'\n\nCommands:\nedit\nedit folder\nrun\nquit\n> ")
|
|
|
|
|
|
|
|
|
|
if (choice == "quit"):
|
|
|
|
|
runFlag = False
|
|
|
|
|
break
|
|
|
|
|
try:
|
|
|
|
|
split_choice = choice.rsplit(" ",1)
|
|
|
|
|
command = split_choice[0]
|
|
|
|
|
current_file = split_choice[1]
|
|
|
|
|
except IndexError:
|
|
|
|
|
print ("\nIncorrect Input\n")
|
|
|
|
|
input("Press Enter to continue...\n")
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if (command == "edit"):
|
|
|
|
|
if (current_file == "folder"):
|
|
|
|
|
os.system("code --n .")
|
|
|
|
|
else:
|
|
|
|
|
os.system(f"code {current_file}.sql")
|
|
|
|
|
|
|
|
|
|
elif (command == "run"):
|
|
|
|
|
os.chdir("C://Oracle12c/")
|
2022-03-21 23:04:24 +00:00
|
|
|
run_time = sp.Popen(f"sqlplus.exe {accounts[account_choice-1]}@student/password", stdout=sp.PIPE, stdin=sp.PIPE, stderr=sp.PIPE)
|
2022-03-21 22:55:30 +00:00
|
|
|
print("\n"+run_time.communicate(f"@C://Users/joshu/Documents/Uni/CSY1026/scripts/{current_file}.sql\n".encode())[0].decode())
|
|
|
|
|
input("Press Enter to continue...\n")
|
|
|
|
|
else:
|
|
|
|
|
print("\nIncorrect Input\n")
|
2022-03-21 23:04:24 +00:00
|
|
|
input("Press Enter to continue...\n")
|