=== modified file 'doc/pykhtml.htm'
--- doc/pykhtml.htm 2007-04-09 17:52:29 +0000
+++ doc/pykhtml.htm 2007-04-10 01:22:36 +0000
@@ -30,11 +30,11 @@
Starts the PyKHTML event loop. PyKHTML works with an asynchronous callback mechanism – a little like Twisted does. Calls to open a new webpage aren't synchronous, as with urllib, for example.
Stop the event loop and hence exit the scraper.
-Call the given function after the alloted time. The PyKHTML event loop needs to be running.
+Call the given function after the alloted time. The PyKHTML event loop needs to be checkProcessRunning.
Initiate the system if necessary (start Xvfb if it's not running, connect to it, start our program instance). This is called automatically when you create a Browser instance, so you shouldn't have to worry about it unless you want to set some of the values of the arguments. You can specify use of a certain X display by setting the `display` parameter, and can stop pykhtml registering its exception handler (the
excepthook function) by setting `registerExceptionHandler` to False.
+
Our exception hook that prints out the traceback, powers down the pykhtml engine, and then exits.
Utility function to search for and get the full path of a file in $PATH.
-Check whether a process of the given name is running.
=== modified file 'pykhtml/__init__.py'
--- pykhtml/__init__.py 2007-04-09 17:52:29 +0000
+++ pykhtml/__init__.py 2007-04-10 01:22:36 +0000
@@ -31,20 +31,20 @@
temp = tempfile.gettempdir()
## If this is being launched from multiple instances it's
## stupid to start Xvfb each time
+def _checkProcessRunningPosix(name):
+ procs = os.popen("ps -eo comm").read().strip().split("\n")
+ return name in procs
if os.name == "posix":
- def running(name):
- """ Check whether a process of the given name is running """
- procs = os.popen("ps -eo comm").read().strip().split("\n")
- return name in procs
+ checkProcessRunning = _checkProcessRunningPosix
else:
- raise OSError("Need to implement running(name) for %s" % repr(os.name))
-# Xvfb process. All you need to know is that it's
-# an object with a display attribute (that contains the
+ raise OSError("Need to implement checkProcessRunning(name) for %s" % repr(os.name))
+# Xvfb process.
+# An object with a display attribute (that contains the
# X display value (i.e :1))
#
# XX refactor into init
xvfb = None
-if running("Xvfb") and os.path.exists(os.path.join(temp, "PyKHTMLXvfb")):
+if checkProcessRunning("Xvfb") and os.path.exists(os.path.join(temp, "PyKHTMLXvfb")):
f = file(os.path.join(temp, "PyKHTMLXvfb"))
data = f.read().strip()
assert data[1:].isdigit()
@@ -78,7 +78,6 @@
def _createDialog():
global dialog
if not dialog:
- print application.name()
dialog = _PyKHTMLDialog(None)
#dialog.setCaption("PyKHTML")
application.setMainWidget(dialog)
@@ -99,7 +98,11 @@
wallet.sync()
# kick kwallet
kded = dcopext.DCOPApp("kded", application.dcopClient())
- kded.kwalletd.reconfigure()
+ try:
+ kded.kwalletd.reconfigure()
+ except:
+ # try using os.system
+ os.system("dcop kded kwalletd reconfigure")
def _reEnableKWallet():
wallet = kdecore.KConfig("kwalletrc")
@@ -231,7 +234,7 @@
del self
def timer(time, func):
- """ Call the given function after the alloted time. The PyKHTML event loop needs to be running """
+ """ Call the given function after the alloted time. The PyKHTML event loop needs to be checkProcessRunning """
_Timer(int(time * 1000), func)