-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRun.py
executable file
·38 lines (32 loc) · 1.35 KB
/
Run.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
from DontEdit import *
import subprocess
import pyfiglet
if os.geteuid() == 0:
print(f"{BRIGHT}{RED}WARNING:{RESET} It's recommended not to run this program with sudo.")
print(f"Running the program with sudo privileges might have unintended consequences.")
print(f"Consider running the program without sudo.")
exit(1)
else:
def startProgram():
# Generate ASCII art text
ascii_text = pyfiglet.figlet_format("| Runner |")
# Print the colored ASCII art text
print(ascii_text)
# Replace 'program_to_run.py' with the name of the Python program you want to run
os.system('ls')
ProgramToRun = input("Enter the name of the Python program you want to run: ")
if ProgramToRun == "":
print("ERROR: Please enter a valid Python program name.")
startProgram()
else:
program_name = ProgramToRun
# Run the program and capture its output and errors
try:
output = subprocess.check_output(['python3', program_name], stderr=subprocess.STDOUT, universal_newlines=True)
print("_________________")
print("Program output:")
print(output)
except subprocess.CalledProcessError as e:
print("An error occurred:")
print(e.output)
startProgram()