[python-uk] Here's a little test

python-uk@python.org python-uk@python.org
Wed, 28 Aug 2002 16:26:15 +0100


Thanks, Simon. 

First, the webbrowser module doesn't work. At all:

>>> webbrowser.open("news.bbc.co.uk", 1)
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python22\lib\webbrowser.py", line 43, in open
    get().open(url, new, autoraise)
  File "C:\Python22\lib\webbrowser.py", line 223, in open
    os.startfile(url)
WindowsError: [Errno 2] The system cannot find the file specified:
'news.bbc.co.uk'
>>> br = webbrowser.get()
>>> br.open('news.bbc.co.uk')
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python22\lib\webbrowser.py", line 223, in open
    os.startfile(url)
WindowsError: [Errno 2] The system cannot find the file specified:
'news.bbc.co.uk'
>>> br = webbrowser.get('windows-default')
>>> br.open('news.bbc.co.uk')
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python22\lib\webbrowser.py", line 223, in open
    os.startfile(url)
WindowsError: [Errno 2] The system cannot find the file specified:
'news.bbc.co.uk'
>>>

Second, the *args syntax is meaningless in this context. 'args' isn't a list
but a string.

The following are equivalent:

args = "stuff"
f(cmd, args)

args = ("stuff", )
f(cmd, *args)

I've tried calling os.execl in all sorts of ways from the interactive prompt
and it simply does not work. I can make it run a command but not get any
args. 

I thought this was going to be a simple conversion but I've spent bloody
hours on it :o(

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)

 -----Original Message-----
From: 	Simon Brunning [mailto:SBrunning@trisystems.co.uk] 
Sent:	Wed, 2002 August 28 15:28
To:	'python-uk@python.org'
Subject:	RE: [python-uk] Here's a little test

First thought - what's wrong with the webbrowser module?

Second thought - have you tried os.execl(iepath, *args)?

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning@trisystems.co.uk

> -----Original Message-----
> From:	dale@riverhall.co.uk [SMTP:dale@riverhall.co.uk]
> Sent:	Wednesday, August 28, 2002 3:28 PM
> To:	python-uk@python.org
> Subject:	[python-uk] Here's a little test
> 
> 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)
> 
> 
> _______________________________________________
> python-uk mailing list
> python-uk@python.org
> http://mail.python.org/mailman/listinfo/python-uk
> 
> 
> 
> 
-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.

_______________________________________________
python-uk mailing list
python-uk@python.org
http://mail.python.org/mailman/listinfo/python-uk