@@ -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
17481749Path2GSASII=r'{ path2GSAS2 } '
17491750if 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()
17541759else:
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