main logo
Subject: [dabo-dev] daborun Commit 4
Author: noreply (AT) paulmcnett DOT com
Posted: 2004/10/31 20:04:12
 
View Entire Thread
New Search


daborun Commit
Revision 4
Date: 2004-10-31 17:04:11 -0800 (Sun, 31 Oct 2004)
Author: ed

Log:
Added the ability to run a regular script file that uses the 'if __name__ == __main__ ' construction to execute only when called directly. There are still some issues with pathing for the icon files that will be attacked next.

Changed:
U trunk/daborun.py

Diff:
Modified: trunk/daborun.py
===================================================================
--- trunk/daborun.py 2004-08-19 18:54:54 UTC (rev 3)
+++ trunk/daborun.py 2004-11-01 01:04:11 UTC (rev 4)
@@ -1,4 +1,8 @@
import sys, os
+
+import wx.lib.mixins.listctrl
+import wx.lib.gridmovers
+
# Add the current dir and library path
pth = sys.path
currdir = os.getcwd()
@@ -23,6 +27,7 @@
import wx
import wx.build
import wx.lib
+ import wx.lib.mixins
import wx.py
import wx.tools
import wx.calendar
@@ -36,6 +41,8 @@
# import wx.ogl
import wx.stc
import wx.xrc
+
+ import mx.DateTime


class DaboRuntimeEngine(object):
@@ -44,7 +51,6 @@
self.prg = sys.argv[1]
except:
self.prg = None
-
try:
self.module = sys.argv[2]
except:
@@ -52,6 +58,10 @@

# Update the argv list to eliminate this program
sys.argv = sys.argv[1:]
+
+ # Add the current path
+ # print "__FILE__", self.__file__
+ print "SYSPATH", sys.path


####################################################
@@ -87,19 +97,25 @@
# print "Current directory is:", os.getcwd()
####################################################

-
+
def run(self):
impt = self.prg
- if impt[-3:] == ".py":
+ isFile = (impt[-3:] == ".py")
+ if isFile:
impt = self.prg[:-3]
print "self.prg:", self.prg, impt
print "self.module:", self.module

if impt:
- exec("import " + impt)
- if self.module:
-# print "EXEC:", impt + "." + self.module + "()"
- exec(impt + "." + self.module + "()")
+ if not self.module:
+ if isFile:
+ execfile(self.prg, {"__name__": "__main__"} )
+ else:
+ # File should run directly when imported
+ exec("import " + impt)
+ else:
+ #print "EXEC:", impt + "." + self.module + "()"
+ exec(impt + "." + self.module + "()")


if __name__ == "__main__":



 
©2004 noreply /at/ paulmcnett DO.T com
<-- Prior Message New Search Next Message -->