Skip to content

Commit 6c26ef3

Browse files
committed
fix G2scrpting shortcut
1 parent a0a7ead commit 6c26ef3

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

GSASII/GSASIIctrlGUI.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6760,7 +6760,6 @@ def OnSave(self,event):
67606760
'''Write the config variables to ~/.GSASII/config.ini
67616761
as the current settings
67626762
'''
6763-
print(self.vars)
67646763
SaveConfigVars(self.vars,parent=self)
67656764
GSASIIpath.SetConfigValue(self.vars)
67666765
self.EndModal(wx.ID_OK)

GSASII/GSASIIpath.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,24 +1739,29 @@ def makeScriptShortcut():
17391739
print('No site-packages directory found in Python path')
17401740
return
17411741
newfil = os.path.join(p,'G2script.py')
1742-
fp = open(newfil,'w')
1743-
fp.write(f'#Created in makeScriptShortcut from {__file__}')
1744-
fp.write(dt.datetime.strftime(dt.datetime.now(),
1745-
" at %Y-%m-%dT%H:%M\n"))
1742+
with open(newfil,'w') as fp:
1743+
fp.write(f'#Created in makeScriptShortcut from {__file__}')
1744+
fp.write(dt.datetime.strftime(dt.datetime.now(),
1745+
" at %Y-%m-%dT%H:%M\n"))
17461746

1747-
fp.write(f"""import sys,os
1747+
fp.write(f"""
1748+
import sys,os
17481749
Path2GSASII=r'{path2GSAS2}'
17491750
if os.path.exists(os.path.join(Path2GSASII,'GSASIIscriptable.py')):
17501751
print('setting up GSASIIscriptable from',Path2GSASII)
1751-
if Path2GSASII not in sys.path:
1752-
sys.path.insert(0,Path2GSASII)
1753-
from GSASIIscriptable import *
1752+
if os.path.dirname(Path2GSASII) not in sys.path:
1753+
sys.path.insert(0,os.path.dirname(Path2GSASII))
1754+
try:
1755+
from GSASII.GSASIIscriptable import *
1756+
except:
1757+
print('Import of GSASIIscriptable failed.\\nRerun "Install GSASIIscriptable shortcut" from inside GSAS-II?')
1758+
sys.exit()
17541759
else:
17551760
print('GSASIIscriptable not found in ',Path2GSASII)
17561761
print('Rerun "Install GSASIIscriptable shortcut" from inside GSAS-II')
17571762
sys.exit()
1758-
""")
1759-
fp.close()
1763+
""")
1764+
fp.close()
17601765
print('Created file',newfil)
17611766
try:
17621767
import G2script

0 commit comments

Comments
 (0)