-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPyWrapper.py
61 lines (48 loc) · 2.39 KB
/
PyWrapper.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
import os
import subprocess
from colorama import Fore, Style, init
init(autoreset=True)
# Clear the screen
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
# Define the banner
def print_banner():
print(Fore.CYAN + "*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*")
print(Fore.CYAN + "|" + Fore.WHITE + " __________ __________ " + Fore.CYAN + "|")
print(Fore.CYAN + "|" + Fore.WHITE + " \\______ \\ __ _ _\\_ ____/ " + Fore.CYAN + "|")
print(Fore.CYAN + ":" + Fore.WHITE + " | | _// \\/ \\/ /| __)_ " + Fore.CYAN + ":")
print(Fore.CYAN + "." + Fore.WHITE + " | | \\\\ // \\ " + Fore.CYAN + ".")
print(Fore.CYAN + ":" + Fore.WHITE + " (\\_/) |______ / \\__/\\__//______ / " + Fore.CYAN + ":")
print(Fore.CYAN + "|" + Fore.WHITE + " ( ~_~) \\/" + Fore.WHITE + "PyEnv-Win Wrapper" + Fore.WHITE + "\\/1.0.0 " + Fore.CYAN + "|")
print(Fore.CYAN + "|" + Fore.WHITE + " (> >) " + Fore.CYAN + "|")
print(Fore.CYAN + "*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*")
# Get the script name and arguments
script_name = os.path.basename(sys.argv[0])
file_to_execute = " ".join(os.sys.argv[1:])
# Get the Windows drive (e.g., C:)
windows_drive = os.environ.get('SystemDrive', 'C:')
# Get the username
username = os.environ.get('UserName', '')
# Path for pyenv
pyenv = os.path.join(windows_drive + '\\Users\\' + username, '.pyenv\\')
# Check if pyenv is exists, then run a script
if os.path.exists(pyenv):
if script_name and file_to_execute:
pyenv_exec_command = f'pyenv exec python "{file_to_execute}"'
subprocess.run(pyenv_exec_command, shell=True)
else:
clear_screen()
print_banner()
try:
versions = subprocess.check_output('pyenv versions', shell=True, text=True)
print(f"\nPython Versions:\n {versions}")
print(Fore.YELLOW + f"Usage: {script_name} <python_script.py>")
input("\nPress Enter to Exit... ")
except subprocess.CalledProcessError:
pass
else:
clear_screen()
print_banner()
print (pyenv)
print(Fore.RED + "\nPlease Install PyEnv-Win First!\n")
input("\nPress Enter to Exit... ")