Skip to content

Commit 1c3e5ea

Browse files
committed
fix cplugin uri and add setupCalculator fun
1 parent 638a984 commit 1c3e5ea

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Funz/install.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def setupModel(model, edit_script=False):
140140
node.attrib['command'] = script
141141
cplugin = os.path.join(FUNZ_HOME,"plugins","calc",model+".cplugin.jar")
142142
if os.path.isfile(cplugin):
143-
node.attrib['cplugin'] = cplugin
143+
node.attrib['cplugin'] = "file:/"+cplugin
144144
list(calculator_xml.getroot())[i] = node
145145
break
146146
# Add this CODE if not yet found
@@ -151,7 +151,7 @@ def setupModel(model, edit_script=False):
151151
command=script)
152152
cplugin = os.path.join(FUNZ_HOME,"plugins","calc",model+".cplugin.jar")
153153
if os.path.isfile(cplugin):
154-
node.attrib['cplugin'] = cplugin
154+
node.attrib['cplugin'] = "file:/"+cplugin
155155
list(calculator_xml.getroot()).append(node)
156156

157157
with open(os.path.join(FUNZ_HOME,"calculator.xml"), "wb") as f:
@@ -160,6 +160,18 @@ def setupModel(model, edit_script=False):
160160
else:
161161
print("Funz model "+model+" already setup.")
162162

163+
def setupCalculator():
164+
print("The calculator.xml file is now opened in the editor: "+os.path.join(FUNZ_HOME,"calculator.xml"))
165+
if sys.platform.startswith("win"):
166+
os.system("start "+'"'+os.path.join(FUNZ_HOME,"calculator.xml")+'"')
167+
elif sys.platform.startswith("dar"):
168+
subprocess.call(["open", '"'+os.path.join(FUNZ_HOME,"calculator.xml")+'"'])
169+
else:
170+
if not os.getenv('EDITOR') is None:
171+
os.system('%s %s' % (os.getenv('EDITOR'), '"'+os.path.join(FUNZ_HOME,"calculator.xml")+'"'))
172+
else:
173+
subprocess.call(["xdg-open", '"'+os.path.join(FUNZ_HOME,"calculator.xml")+'"'])
174+
163175
import tempfile, pkg_resources
164176
def install_githubModel(model,force=False, edit_script=False):
165177
""" Install Funz model plugin from central GitHub repository.

0 commit comments

Comments
 (0)