Hi guys.
I've a very big big big problem:
I've in my windows computer a file named cicciobello.html, located in
c:\documents and settings\username\desktop\cicciobello.html.
Now, I MUST open this file with os.spawn(os.P_WAIT ...., because I must
wait the user cancel the explorer window, ok?
And so, I write:
import os
os.spawnl(os.P_WAIT, "c:\programmi\internet explorer\iexplorer.exe",
"c:\documents and settings\username\desktop\cicciobello.html")
the python process don't fail, but explorer don't visualize correctly
the file opened: i receive an "not found" error message.
I've found that the whitespaces in file path are the problem.
If you see to explorer address bar, you will find the address
completely wrong...
I've found no solution!
Can you help me, please??
thx very very very much!!! 6 3676
mardif a écrit : Hi guys. I've a very big big big problem:
I've in my windows computer a file named cicciobello.html, located in c:\documents and settings\username\desktop\cicciobello.html.
Now, I MUST open this file with os.spawn(os.P_WAIT ...., because I must wait the user cancel the explorer window, ok? And so, I write:
import os os.spawnl(os.P_WAIT, "c:\programmi\internet explorer\iexplorer.exe", "c:\documents and settings\username\desktop\cicciobello.html")
the python process don't fail, but explorer don't visualize correctly the file opened: i receive an "not found" error message.
I've found that the whitespaces in file path are the problem. If you see to explorer address bar, you will find the address completely wrong...
I've found no solution! Can you help me, please??
thx very very very much!!!
And I thought the problem where the incorrectly used \ :) Try that first :
os.spawnl(os.P_WAIT, r"c:\programmi\internet explorer\iexplorer.exe",
r"c:\documents and settings\username\desktop\cicciobello.html")
mardif wrote: Hi guys. I've a very big big big problem:
<ot>
I think a lot of people in the world would not find it so big wrt/ their
own situation...
</ot>
I've in my windows computer a file named cicciobello.html, located in c:\documents and settings\username\desktop\cicciobello.html.
Now, I MUST open this file with os.spawn(os.P_WAIT ...., because I must wait the user cancel the explorer window, ok? And so, I write:
import os os.spawnl(os.P_WAIT, "c:\programmi\internet explorer\iexplorer.exe", "c:\documents and settings\username\desktop\cicciobello.html")
take care of the meaning of the antislash in strings... What do you
thing "c:\toto" or "c:\nothing" will expand to ?-)
import os.path
help(os.path)
Or at least, and IIRC, "c:/something/" should work.
the python process don't fail, but explorer don't visualize correctly the file opened: i receive an "not found" error message.
I've found that the whitespaces in file path are the problem. If you see to explorer address bar, you will find the address completely wrong...
Not using Windows, I won't find anything. So what's the result ?-)
Anyway, you may find urllib.urlencode useful for, well, encoding urls...
HTH
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Christophe wrote: mardif a écrit :
Hi guys. I've a very big big big problem:
I've in my windows computer a file named cicciobello.html, located in c:\documents and settings\username\desktop\cicciobello.html.
Now, I MUST open this file with os.spawn(os.P_WAIT ...., because I must wait the user cancel the explorer window, ok? And so, I write:
import os os.spawnl(os.P_WAIT, "c:\programmi\internet explorer\iexplorer.exe", "c:\documents and settings\username\desktop\cicciobello.html")
the python process don't fail, but explorer don't visualize correctly the file opened: i receive an "not found" error message.
I've found that the whitespaces in file path are the problem. If you see to explorer address bar, you will find the address completely wrong...
I've found no solution! Can you help me, please??
thx very very very much!!!
And I thought the problem where the incorrectly used \ :) Try that first :
os.spawnl(os.P_WAIT, r"c:\programmi\internet explorer\iexplorer.exe", r"c:\documents and settings\username\desktop\cicciobello.html")
Another option to try in case this is not the problem is to put the file
name in quotation marks as it is necessary when using command line shell
(not tested, just an idea):
os.spawnl(os.P_WAIT,'"c:\\programmi\\internet explorer\\iexplorer.exe"',
'"c:\\documents and settings\\username\\desktop\\cicciobello.html"')
OK OK GUYS!!!!
I've found the solution: ( effectly, a friend of mine has found the
solution )
import os
os.spawnl(os.P_WAIT, "c:\programmi\internet
explorer\iexplore.exe",'"C:\Documents and
Settings\michele\Desktop\ciccio.html"','"C:\Docume nts and
Settings\michele\Desktop\ciccio.html"')
The secret are the ' simbols around arguments:
' "C:\Documents and Settings\michele\Desktop\ciccio.html" '
Without these, don't work!
Very STRONG!!!!!
bye and thx
"mardif" wrote: Now, I MUST open this file with os.spawn(os.P_WAIT ...., because I must wait the user cancel the explorer window, ok?
note that backslashes in string literals have special meaning in Python; to make
sure a backslash in the string literal really ends up as a backslash in the resulting
string, you must either double each backslash, or use "raw" strings:
program = r"c:\programmi\internet explorer\iexplorer.exe"
file = r"c:\documents and settings\username\desktop\cicciobello.html"
also, getting the quoting/escaping right with os.exec/os.spawn is quite messy. I
recommend using the subprocess module instead:
import subprocess
print subprocess.call([program, file])
</F>
mardif wrote: OK OK GUYS!!!! I've found the solution: ( effectly, a friend of mine has found the solution )
import os
os.spawnl(os.P_WAIT, "c:\programmi\internet explorer\iexplore.exe",'"C:\Documents and Settings\michele\Desktop\ciccio.html"','"C:\Docume nts and Settings\michele\Desktop\ciccio.html"')
The secret are the ' simbols around arguments:
' "C:\Documents and Settings\michele\Desktop\ciccio.html" '
Without these, don't work!
Very STRONG!!!!!
bye and thx
Wasn't that what I have suggested?
By the way:
it is much better to use double backslashes here, as in case of other
file/directory names (e.g. folder\name.txt folder\remote.htm i.e. for
all the cases a backslash is followed by a letter making out of this
twin one special character) this above won't work.
But best is to use in full path file names forward slashes as Python
handles them properly not only on *nix and Linux, but also on Windows:
'"C:/Documents and Settings/michele/Desktop/ciccio.html"'
The "secret" symbols around arguments are single quotation marks making
the double quotation marks part of the string passed to the .spawnl()
function. Check out in IDLE, that: "x"
'x' '"x"'
'"x"'
Command shell command arguments need to be enclosed in quotation marks
in case spaces can occur in them (as it can happen in file names) as
otherwise the spaces will be interpreted as separator characters between
the arguments and as consequence of this the command shell command fails
due to bad or wrong number of parameter.
You see, no "secrets" here ... only some simple rules and a bit more
understanding of what is going on behind the scenes.
Claudio This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mar Thomas |
last post by:
I have a dom tree created from an XML document but it shows whitespaces as
Textnodes!! Pls tell me how to get rid of them
I tried ...
factory.setIgnoringElementContentWhitespace(true); but it...
|
by: Dave |
last post by:
Hi
Have a method that builds and returns a of specfic accounting codes to a
datagrid textbox field.
eg, if a user types in "200" the method builds & returns the code "200.00.00".
also if a...
|
by: asjad |
last post by:
Is there is any way that i can show whitespaces in my editor, made by
extending rich text box.
|
by: rj |
last post by:
Hello,
I try to remove whitespaces from a string using the preg_replace function
like
preg_replace("/*/"," ",$string);
This works great, but makes no handles all characters in the same way....
|
by: Generic Usenet Account |
last post by:
I have been able to recreate a problem that I am having with the file
stream using the simple sample code given below.
I am trying to read the number of lines in a file, relying on the
getline...
| |
by: rn5a |
last post by:
When a Button is clicked in a Form, the JavaScript 'prompt' dialog
pops-up for users to enter any text. When the user clicks OK in the
prompt dialog, the text is populated in a TextBox & the Form...
|
by: mishink7 |
last post by:
i was wondering how would u remove multiple whitespaces from the middle of a string to make it only one white space...for example:
string hi= "hi bye";
then remove the multiple whitespaces...
|
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming.
FYI
Although I have called...
|
by: kris06 |
last post by:
Hi All,
I have a textfile and i need to format it, so that i can import it to the mysql database.
The textfile contains 9 colums of data separated by a space. I want to replace only the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |