|
1 | 1 | #!/usr/bin/env python3
|
2 | 2 |
|
3 |
| -import re, os, requests, warnings, subprocess |
| 3 | +import re, os, requests, warnings, subprocess, sys |
4 | 4 |
|
5 | 5 | from Funz import FUNZ_HOME
|
6 | 6 | from .inst.Funz.Funz import *
|
@@ -98,29 +98,31 @@ def setupModel(model):
|
98 | 98 | """
|
99 | 99 | # Setup script file
|
100 | 100 | 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") |
102 | 102 | else:
|
103 |
| - script = '"'+os.path.join(FUNZ_HOME,"scripts",model+".sh")+'"' |
| 103 | + script = os.path.join(FUNZ_HOME,"scripts",model+".sh") |
104 | 104 |
|
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 |
113 | 115 | os.chmod(script,int(0o644))
|
114 | 116 | print("The script used to launch "+model+" is now opened in the editor.")
|
115 | 117 | if sys.platform.startswith("win"):
|
116 |
| - os.system("start "+script) |
| 118 | + os.system("start "+'"'+script+'"') |
117 | 119 | elif sys.platform.startswith("dar"):
|
118 |
| - subprocess.call(["open", script]) |
| 120 | + subprocess.call(["open", '"'+script+'"']) |
119 | 121 | else:
|
120 | 122 | 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+'"')) |
122 | 124 | else:
|
123 |
| - subprocess.call(["xdg-open", script]) |
| 125 | + subprocess.call(["xdg-open", '"'+script+'"']) |
124 | 126 | os.chmod(script,int(0o755))
|
125 | 127 |
|
126 | 128 | # Update calculator_xml
|
|
0 commit comments