[python-uk] Here's a little test
python-uk@python.org
python-uk@python.org
Wed, 28 Aug 2002 15:27:36 +0100
I've posted this on clp but not had a response. I thought I'd test you guys
:o)
I have a little program I've converted from Javascript which I use
frequently. It doesn't work in Python because the last line keeps
throwing the error:
Traceback (most recent call last):
File "I:\batch\ie.py", line 22, in ?
os.execl(iepath, args)
File "C:\Python22\Lib\os.py", line 266, in execl
execv(file, args)
TypeError: execv() arg 2 must contain only strings
I have tried a variety of formats for the os.execl function,
including:
os.execl(iepath, (args, ))
os.execl(iepath, [args])
os.execl(iepath, args)
but it always complains about arg 2 in this way.
What is execl on about?
Any help appreciated.
I'm going to lie down for a while.
(Python 2.2.1 Win2k SP2)
Here is the full code (it may wrap):
==========================================
# Run IE - wherever it happens to be.
# Take URL from clipboard if not supplied as arg
import sys, os, os.path
import win32clipboard as clip
import win32api
import win32con
hklm = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App
Paths\\IEXPLORE.EXE\\"
if len(sys.argv) > 1:
args = sys.argv[1]
else:
clip.OpenClipboard(0)
args = clip.GetClipboardData(clip.CF_TEXT)
clip.CloseClipboard()
iekey = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, hklm, 0,
win32con.KEY_READ)
iepath = win32api.RegQueryValueEx(iekey, None)[0]
win32api.RegCloseKey(iekey)
os.execl(iepath, args)
--
Dale Strickland-Clark
Riverhall Systems Ltd
Dale Strickland-Clark
Riverhall Systems Ltd. Custom database and Web applications.
http://www.riverhall.co.uk
Offices: London: 0870 321 0034 Wokingham: 0870 321 2378
Mobile 0701 071 DALE (3253)