Hi guys.
I've a very big big big problem:
I've in my windows computer a file named cicciobello.htm l, located in
c:\documents and settings\userna me\desktop\cicc iobello.html.
Now, I MUST open this file with os.spawn(os.P_W AIT ...., because I must
wait the user cancel the explorer window, ok?
And so, I write:
import os
os.spawnl(os.P_ WAIT, "c:\programmi\i nternet explorer\iexplo rer.exe",
"c:\documen ts and settings\userna me\desktop\cicc iobello.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 3688
mardif a écrit : Hi guys. I've a very big big big problem:
I've in my windows computer a file named cicciobello.htm l, located in c:\documents and settings\userna me\desktop\cicc iobello.html.
Now, I MUST open this file with os.spawn(os.P_W AIT ...., because I must wait the user cancel the explorer window, ok? And so, I write:
import os os.spawnl(os.P_ WAIT, "c:\programmi\i nternet explorer\iexplo rer.exe", "c:\documen ts and settings\userna me\desktop\cicc iobello.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\iexplo rer.exe",
r"c:\documen ts and settings\userna me\desktop\cicc iobello.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.htm l, located in c:\documents and settings\userna me\desktop\cicc iobello.html.
Now, I MUST open this file with os.spawn(os.P_W AIT ...., because I must wait the user cancel the explorer window, ok? And so, I write:
import os os.spawnl(os.P_ WAIT, "c:\programmi\i nternet explorer\iexplo rer.exe", "c:\documen ts and settings\userna me\desktop\cicc iobello.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.urlencod e 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.htm l, located in c:\documents and settings\userna me\desktop\cicc iobello.html.
Now, I MUST open this file with os.spawn(os.P_W AIT ...., because I must wait the user cancel the explorer window, ok? And so, I write:
import os os.spawnl(os.P_ WAIT, "c:\programmi\i nternet explorer\iexplo rer.exe", "c:\documen ts and settings\userna me\desktop\cicc iobello.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\iexplo rer.exe", r"c:\documen ts and settings\userna me\desktop\cicc iobello.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:\\prog rammi\\internet explorer\\iexpl orer.exe"',
'"c:\\docume nts and settings\\usern ame\\desktop\\c icciobello.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\i nternet
explorer\iexplo re.exe",'"C:\Do cuments and
Settings\michel e\Desktop\cicci o.html"','"C:\D ocuments and
Settings\michel e\Desktop\cicci o.html"')
The secret are the ' simbols around arguments:
' "C:\Documen ts and Settings\michel e\Desktop\cicci o.html" '
Without these, don't work!
Very STRONG!!!!!
bye and thx
"mardif" wrote: Now, I MUST open this file with os.spawn(os.P_W AIT ...., 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\iexplo rer.exe"
file = r"c:\documen ts and settings\userna me\desktop\cicc iobello.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\i nternet explorer\iexplo re.exe",'"C:\Do cuments and Settings\michel e\Desktop\cicci o.html"','"C:\D ocuments and Settings\michel e\Desktop\cicci o.html"')
The secret are the ' simbols around arguments:
' "C:\Documen ts and Settings\michel e\Desktop\cicci o.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.h tm 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 doesnt work!
Help me please
thanks
|
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 user types in "51" the method should return " 51.00.00" but I am
finding difficulty adding a white space infront of the string, I have been
using the PadLeft method eg: sCode = sCode.PadLeft(1, ' ') + ".00" + ".00";
|
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. I
want to preserve data between double quotes. So,
hello world "It is a sunny... world"
|
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 method to read all the characters (including leading
whitespaces) until the new line character (the default line delimiter)
or end-of-file is reached. Then I close the stream, reopen it and
repeat the procedure. I get the correct answer only the...
| |
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 posts. I
then retrieve the text using Request.Form.
The problem I am facing is in retaining whitespaces in the text the
user has entered. Assume that the user has entered the following text
in the JavaScript prompt dialog (note the whitespaces...
|
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 in middle to make it "hi bye"
any help would be appreciated...thanks.
|
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 this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts, disregarding the syntax that stream contains. Parsing is actually including the syntax in order to make...
|
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 first 8 whitespaces separating those 9 colums, because the 9th column contains a sentence separated by space. similaryly i want all the rows in that file to get updated in the same fashion.
Heres how the contents of the textfile looks:...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |