BUGFIX: Invoking Scyther scripts from non-standard directories or using symlinks should work consistently now.
Before, we were using both __file__ as well as sys.argv[0] to determine the base directory for Scyther, and we were not taking symlinks into account. By using the inspect module, we can consistently pick the current frame and derive the file from that, then use realpath to strip symlinks.
This commit is contained in:
parent
7658644295
commit
9e13d07b6e
@ -35,7 +35,12 @@ import Misc
|
||||
|
||||
def ScytherIcon(window):
|
||||
""" Set a nice Scyther icon """
|
||||
basedir = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
import os,inspect
|
||||
|
||||
# Determine base directory (taking symbolic links into account)
|
||||
cmd_file = os.path.realpath(os.path.abspath(inspect.getfile( inspect.currentframe() )))
|
||||
basedir = os.path.split(cmd_file)[0]
|
||||
|
||||
path = os.path.join(basedir,"Images")
|
||||
iconfile = Misc.mypath(os.path.join(path,"scyther-gui-32.ico"))
|
||||
if os.path.isfile(iconfile):
|
||||
|
@ -60,7 +60,11 @@ def sorted(li):
|
||||
def mypath(file):
|
||||
""" Construct a file path relative to the scyther-gui main directory
|
||||
"""
|
||||
basedir = os.path.dirname(__file__)
|
||||
import os, inspect
|
||||
|
||||
# Determine base directory (taking symbolic links into account)
|
||||
cmd_file = os.path.realpath(os.path.abspath(inspect.getfile( inspect.currentframe() )))
|
||||
basedir = os.path.split(cmd_file)[0]
|
||||
return os.path.join(basedir,file)
|
||||
|
||||
# commands: push data in, get fp.write out
|
||||
|
@ -84,7 +84,9 @@ def ensurePath(pt):
|
||||
def mypath(file):
|
||||
""" Construct a file path relative to the scyther-gui main directory
|
||||
"""
|
||||
basedir = os.path.dirname(__file__)
|
||||
# Determine base directory (taking symbolic links into account)
|
||||
cmd_file = os.path.realpath(os.path.abspath(inspect.getfile( inspect.currentframe() )))
|
||||
basedir = os.path.split(cmd_file)[0]
|
||||
return os.path.join(basedir,file)
|
||||
|
||||
def getShell():
|
||||
|
@ -179,11 +179,15 @@ def isSplashNeeded(opts):
|
||||
|
||||
class ScytherApp(wx.App):
|
||||
def OnInit(self):
|
||||
import os, inspect
|
||||
|
||||
wx.GetApp().SetAppName("Scyther-gui")
|
||||
|
||||
# Determine base directory (taking symbolic links into account)
|
||||
cmd_file = os.path.realpath(os.path.abspath(inspect.getfile( inspect.currentframe() )))
|
||||
basedir = os.path.split(cmd_file)[0]
|
||||
|
||||
# Parse arguments
|
||||
basedir = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
(opts,args) = parseArgs()
|
||||
|
||||
# License option may abort here
|
||||
|
Loading…
Reference in New Issue
Block a user