[Qgis-user] Action in 1.8 with python interprets slash wrong
Giuseppe Sucameli
sucameli at faunalia.it
Mon Jul 9 10:12:59 PDT 2012
Hi Daniela,
On Mon, Jul 9, 2012 at 4:17 PM, Wörz Daniela
<daniela.woerz at vorarlberg.at> wrote:
> the slashes in the path will be wrong interpreted:
>
> os.startfile("[% "DOC_Path" %]")
[[snip]]
> WindowsError: [Error 2] System can not find stated file
> '\\avlrbrc103a\x0biia\\state\x0b_City\xob.14.xls'
you must escape again your backslashes (\) (duplicating them)
because the 2 interpretation steps, from expression engine
and then from python interpreter, something like:
os.startfile("[% replace("DOC_Path", '\\', '\\\\') %]")
or just replace them with a slashes (/) since the python interpreter
replace slashes on path with backshashes on WinOS:
os.startfile("[% replace("DOC_Path", '\\', '/') %]")
I'd suggest the second approach because you're sure you don't
get any problems if the string is further interpreted and in
addition it should works on all the OSs.
Regards.
--
Giuseppe Sucameli - Faunalia
More information about the Qgis-user
mailing list