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):
|
def ScytherIcon(window):
|
||||||
""" Set a nice Scyther icon """
|
""" 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")
|
path = os.path.join(basedir,"Images")
|
||||||
iconfile = Misc.mypath(os.path.join(path,"scyther-gui-32.ico"))
|
iconfile = Misc.mypath(os.path.join(path,"scyther-gui-32.ico"))
|
||||||
if os.path.isfile(iconfile):
|
if os.path.isfile(iconfile):
|
||||||
|
@ -60,7 +60,11 @@ def sorted(li):
|
|||||||
def mypath(file):
|
def mypath(file):
|
||||||
""" Construct a file path relative to the scyther-gui main directory
|
""" 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)
|
return os.path.join(basedir,file)
|
||||||
|
|
||||||
# commands: push data in, get fp.write out
|
# commands: push data in, get fp.write out
|
||||||
|
@ -84,7 +84,9 @@ def ensurePath(pt):
|
|||||||
def mypath(file):
|
def mypath(file):
|
||||||
""" Construct a file path relative to the scyther-gui main directory
|
""" 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)
|
return os.path.join(basedir,file)
|
||||||
|
|
||||||
def getShell():
|
def getShell():
|
||||||
|
@ -179,11 +179,15 @@ def isSplashNeeded(opts):
|
|||||||
|
|
||||||
class ScytherApp(wx.App):
|
class ScytherApp(wx.App):
|
||||||
def OnInit(self):
|
def OnInit(self):
|
||||||
|
import os, inspect
|
||||||
|
|
||||||
wx.GetApp().SetAppName("Scyther-gui")
|
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
|
# Parse arguments
|
||||||
basedir = os.path.abspath(os.path.dirname(sys.argv[0]))
|
|
||||||
(opts,args) = parseArgs()
|
(opts,args) = parseArgs()
|
||||||
|
|
||||||
# License option may abort here
|
# License option may abort here
|
||||||
|
Loading…
Reference in New Issue
Block a user