@@ -60,10 +60,11 @@ def availableModels(refresh_repo = False):
60
60
61
61
import zipfile
62
62
from .inst .Funz import Funz
63
- def install_fileModel (model_zip , force = False ):
63
+ def install_fileModel (model_zip , force = False , edit_script = False ):
64
64
""" Install Funz model plugin from local zip file.
65
65
@param model_zip zip file of plugin. Usually plugin-XYZ.zip
66
66
@param force if already installed, reinstall.
67
+ @param edit_script open installed script for customization.
67
68
@param ... optional parameters to pass to unzip()
68
69
@export
69
70
"""
@@ -88,12 +89,13 @@ def install_fileModel(model_zip, force=False):
88
89
print ("Installed Funz model " + model )
89
90
90
91
# .. in the end, configure model script
91
- setupModel (model = model )
92
+ setupModel (model = model , edit_script = edit_script )
92
93
93
94
import xml .etree .ElementTree as ElementTree
94
- def setupModel (model ):
95
+ def setupModel (model , edit_script = False ):
95
96
""" Configure model calculation entry point
96
97
@param model Name of model corresponding to given script
98
+ @param edit_script open installed script for customization.
97
99
@export
98
100
"""
99
101
# Setup script file
@@ -113,16 +115,18 @@ def setupModel(model):
113
115
except :
114
116
pass
115
117
os .chmod (script ,int (0o644 ))
116
- print ("The script used to launch " + model + " is now opened in the editor." )
117
- if sys .platform .startswith ("win" ):
118
- os .system ("start " + '"' + script + '"' )
119
- elif sys .platform .startswith ("dar" ):
120
- subprocess .call (["open" , '"' + script + '"' ])
121
- else :
122
- if not os .getenv ('EDITOR' ) is None :
123
- os .system ('%s %s' % (os .getenv ('EDITOR' ), '"' + script + '"' ))
118
+
119
+ if edit_script :
120
+ print ("The script used to launch " + model + " is now opened in the editor." )
121
+ if sys .platform .startswith ("win" ):
122
+ os .system ("start " + '"' + script + '"' )
123
+ elif sys .platform .startswith ("dar" ):
124
+ subprocess .call (["open" , '"' + script + '"' ])
124
125
else :
125
- subprocess .call (["xdg-open" , '"' + script + '"' ])
126
+ if not os .getenv ('EDITOR' ) is None :
127
+ os .system ('%s %s' % (os .getenv ('EDITOR' ), '"' + script + '"' ))
128
+ else :
129
+ subprocess .call (["xdg-open" , '"' + script + '"' ])
126
130
os .chmod (script ,int (0o755 ))
127
131
128
132
# Update calculator_xml
@@ -157,10 +161,11 @@ def setupModel(model):
157
161
print ("Funz model " + model + " already setup." )
158
162
159
163
import tempfile , pkg_resources
160
- def install_githubModel (model ,force = False ):
164
+ def install_githubModel (model ,force = False , edit_script = False ):
161
165
""" Install Funz model plugin from central GitHub repository.
162
166
@param model model to install.
163
167
@param force if already installed, reinstall.
168
+ @param edit_script open installed script for customization.
164
169
@export
165
170
@examples
166
171
\dontrun{
@@ -179,23 +184,24 @@ def install_githubModel(model,force=False):
179
184
180
185
if not z .ok : raise Exception ("Could not download model " + model )
181
186
182
- install_fileModel (model_zip = model_zip , force = force )
187
+ install_fileModel (model_zip = model_zip , force = force , edit_script = edit_script )
183
188
184
- def installModel (model ,force = False ):
189
+ def installModel (model , force = False , edit_script = False ):
185
190
""" Install Funz model from local file or GitHub central repository
186
191
@param model model to install.
187
192
@param force if already installed, reinstall.
193
+ @param edit_script open installed script for customization.
188
194
@export
189
195
@examples
190
196
\dontrun{
191
197
installModel('Modelica')
192
198
}
193
199
"""
194
200
if os .path .isfile (model ):
195
- install_fileModel (model_zip = model , force = force )
201
+ install_fileModel (model_zip = model , force = force , edit_script = edit_script )
196
202
else :
197
203
if model in availableModels ():
198
- install_githubModel (model , force = force )
204
+ install_githubModel (model , force = force , edit_script = edit_script )
199
205
else :
200
206
raise Exception ("Model " + model + " is not available." )
201
207
0 commit comments