Skip to content

Commit db3d3e7

Browse files
committed
Funz/client.py
1 parent aae2692 commit db3d3e7

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

Funz/install.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
import re, os, requests, warnings, subprocess
3+
import re, os, requests, warnings, subprocess, sys
44

55
from Funz import FUNZ_HOME
66
from .inst.Funz.Funz import *
@@ -98,29 +98,31 @@ def setupModel(model):
9898
"""
9999
# Setup script file
100100
if sys.platform.startswith("win"):
101-
script = '"'+os.path.join(FUNZ_HOME,"scripts",model+".bat")+'"'
101+
script = os.path.join(FUNZ_HOME,"scripts",model+".bat")
102102
else:
103-
script = '"'+os.path.join(FUNZ_HOME,"scripts",model+".sh")+'"'
103+
script = os.path.join(FUNZ_HOME,"scripts",model+".sh")
104104

105-
if not os.path.isfile(script):
106-
if sys.platform.startswith("win"):
107-
with open(script, "wb") as f:
108-
f.write(("@echo off\n\nREM Fill this file to launch "+model+"\nREM First argument will be the main file").encode('utf8'))
109-
else:
110-
with open(script, "wb") as f:
111-
f.write(("#!/bin/bash\n\n# Fill this file to launch "+model+"\n# First argument will be the main file").encode('utf8'))
112-
105+
try:
106+
if not os.path.isfile(script):
107+
if sys.platform.startswith("win"):
108+
with open(script, "wb") as f:
109+
f.write(("@echo off\n\nREM Fill this file to launch "+model+"\nREM First argument will be the main file").encode('utf8'))
110+
else:
111+
with open(script, "wb") as f:
112+
f.write(("#!/bin/bash\n\n# Fill this file to launch "+model+"\n# First argument will be the main file").encode('utf8'))
113+
except:
114+
pass
113115
os.chmod(script,int(0o644))
114116
print("The script used to launch "+model+" is now opened in the editor.")
115117
if sys.platform.startswith("win"):
116-
os.system("start "+script)
118+
os.system("start "+'"'+script+'"')
117119
elif sys.platform.startswith("dar"):
118-
subprocess.call(["open", script])
120+
subprocess.call(["open", '"'+script+'"'])
119121
else:
120122
if not os.getenv('EDITOR') is None:
121-
os.system('%s %s' % (os.getenv('EDITOR'), script))
123+
os.system('%s %s' % (os.getenv('EDITOR'), '"'+script+'"'))
122124
else:
123-
subprocess.call(["xdg-open", script])
125+
subprocess.call(["xdg-open", '"'+script+'"'])
124126
os.chmod(script,int(0o755))
125127

126128
# Update calculator_xml

0 commit comments

Comments
 (0)