Get and use path for HUD_main.py to prevent some crashes.

This commit is contained in:
Ray 2008-12-13 14:57:08 -05:00
parent 71309ab337
commit 3994d3bb94

View File

@ -23,6 +23,8 @@ pygtk.require('2.0')
import gtk import gtk
import gobject import gobject
import os import os
import sys
import inspect
import time import time
import fpdb_import import fpdb_import
@ -105,6 +107,10 @@ class GuiAutoImport (threading.Thread):
print "GuiAutoImport.import_dir done" print "GuiAutoImport.import_dir done"
return True return True
def execution_path(self, filename):
"""Join the fpdb path to filename."""
return os.path.join(os.path.dirname(inspect.getfile(sys._getframe(1))), filename)
def startClicked(self, widget, data): def startClicked(self, widget, data):
"""runs when user clicks start on auto import tab""" """runs when user clicks start on auto import tab"""
@ -126,8 +132,7 @@ class GuiAutoImport (threading.Thread):
self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE, self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE,
universal_newlines=True) universal_newlines=True)
else: else:
cwd = os.getcwd() command = self.execution_path('HUD_main.py')
command = os.path.join(cwd, 'HUD_main.py')
bs = 1 bs = 1
self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE, self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE,
universal_newlines=True) universal_newlines=True)