initial commit
This commit is contained in:
commit
3d53f25dcb
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
sp = os.path.dirname(os.path.realpath(__file__))
|
||||
p = os.path.join
|
||||
pp = p(sp,"prefixes")
|
||||
|
||||
def walklevel(some_dir, level=0):
|
||||
some_dir = some_dir.rstrip(os.path.sep)
|
||||
assert os.path.isdir(some_dir)
|
||||
num_sep = some_dir.count(os.path.sep)
|
||||
for root, dirs, files in os.walk(some_dir):
|
||||
yield root, dirs, files
|
||||
num_sep_this = root.count(os.path.sep)
|
||||
if num_sep + level <= num_sep_this:
|
||||
del dirs[:]
|
||||
|
||||
def launchPrefix(prefix,cmd,raw = False):
|
||||
home = os.environ["HOME"]
|
||||
user = os.environ["USER"]
|
||||
os.environ["USER"] = "User"
|
||||
os.environ["HOME"] = p(pp,prefix,os.environ["USER"])
|
||||
os.environ["WINEPREFIX"] = p(pp,prefix)
|
||||
if raw == False:
|
||||
subprocess.call(["wine"] + cmd)
|
||||
else:
|
||||
subprocess.call(cmd)
|
||||
os.environ["HOME"] = home
|
||||
os.environ["USER"] = user
|
||||
del os.environ["WINEPREFIX"]
|
||||
|
||||
|
||||
def main():
|
||||
while True:
|
||||
wineprefix = input("prefix: ")
|
||||
if not os.path.isdir(p(pp,wineprefix)):
|
||||
while True:
|
||||
print("\nthis wine-prefix does not exist yet, would you like to create it? (y/n)")
|
||||
choice = input().lower()
|
||||
if (choice == "n"): break
|
||||
if (choice != "y"): continue
|
||||
|
||||
while True:
|
||||
print("\n(6)4 or (3)2 bit?")
|
||||
choice = input().lower()
|
||||
syswow = False
|
||||
if (choice == "6"): syswow = True
|
||||
if (choice != "3"): continue
|
||||
os.makedirs(p(pp,wineprefix))
|
||||
if (syswow == False): os.environ["WINEARCH"] = "win32"
|
||||
launchPrefix(wineprefix,["winecfg"])
|
||||
del os.environ["WINEARCH"]
|
||||
break
|
||||
|
||||
if os.path.isdir(p(pp,wineprefix)):
|
||||
launchPrefix(wineprefix,["cmd"])
|
||||
print("\nended wine-session")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue