problem in executing a file

2006-07-13 Thread ciccio


Dear all,

I'm using python to manage a web-site. In particular, a user insert specific
parameters in a form and, then, I recover all parameters and run an executable
file according to the user parameters. The output is finally showed in a new
web-page.
The problem is when I need to run the executable file. I tried with:

import os
os.system("file.exe parameters")

but I received an error like "cmd.exe : permission deneided"

Probably I don't have the permission to execute the file. However, the server
administrator said me that he cannot give me the permission, but I can also use
ed execute files in my folder. so, is there a way to execute a file in my folder
using python and not the os module?

Thank you

Ernesto 

-
This mail sent through IMP: http://horde.org/imp/

-- 
http://mail.python.org/mailman/listinfo/python-list


capture the output

2006-07-19 Thread ciccio


Dear all,

I'm executing a program by os.spawnv() function. However the program print out
several things. I would to capture this output, but I don't know how.
Could you give me a suggestion?

Thank you

Ernesto

-
This mail sent through IMP: http://horde.org/imp/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: capture the output

2006-07-19 Thread ciccio


On 7/19/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


Dear all,

I'm executing a program by os.spawnv() function. However the program print out
several things. I would to capture this output, but I don't know how.
Could you give me a suggestion?

Thank you 

Ernesto

Hi Ernesto

could you use popen2 or are you bound to os.spawnv?

- Unfortunately I cannot use functions calling the cmd.exe. My operating system
is windows 
 
from os import popen2
dummy, stdout = popen2("prog")
stdout.readlines

and why not put this into a thread? 

- Because I don't know how...

Ciao
Roberto 



-
This mail sent through IMP: http://horde.org/imp/

--
http://mail.python.org/mailman/listinfo/python-list



-
This mail sent through IMP: http://horde.org/imp/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: capture the output

2006-07-21 Thread ciccio


On 7/19/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


On 7/19/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


Dear all,

I'm executing a program by os.spawnv() function. However the program print out 
several things. I would to capture this output, but I don't know how.
Could you give me a suggestion?

Thank you

Ernesto

Hi Ernesto

could you use popen2 or are you bound to os.spawnv?

- Unfortunately I cannot use functions calling the cmd.exe. My operating system
is windows

Hmm can you elaborate on this, it works perfectly on my XP.

-  In reality It works also on my XP, but my application is a web application
and thus I have not all permissions and in particular the permission to run 
cmd.exe.

from os import popen2
dummy, stdout = popen2("prog")
stdout.readlines

and why not put this into a thread?

- Because I don't know how...

That was just an idea, does not matter for now. 
Ciao
Roberto

Anyway thank you

Ernesto



-
This mail sent through IMP: http://horde.org/imp/

--
http://mail.python.org/mailman/listinfo/python-list



-
This mail sent through IMP: http://horde.org/imp/

--
http://mail.python.org/mailman/listinfo/python-list




-
This mail sent through IMP: http://horde.org/imp/

-- 
http://mail.python.org/mailman/listinfo/python-list


upload a file

2006-07-25 Thread ciccio


Dear all,

could you give me an help ?

I would to upload a file from web using Python. Is there a simple way to do
this? I'm using the cgi module and python 2.3. The file to be uploaded is a text
file.

Thank you for all your suggestions,

Ernesto

-
This mail sent through IMP: http://horde.org/imp/

-- 
http://mail.python.org/mailman/listinfo/python-list


help to install MySQL-python module

2006-06-07 Thread ciccio


Dear python users,

I have an account on a Linux Cluster. I installed python version 2.3.5 on my 
account. I need to install the module MySQL-python to interact with a MySQL 
server already installed on the cluster.
However, I read the README file but running

python setup.py build 

the system fails to build the module and gives me the following error:

 error: invalid Python installation: unable to 
open /usr/local/lib/python2.3/config/Makefile (No such file or directory)

How can I solve this problem?

Thank you in advance

Ernesto

-
This mail sent through IMP: http://horde.org/imp/

-- 
http://mail.python.org/mailman/listinfo/python-list


Regular expression for "key = value" pairs

2010-12-22 Thread Ciccio

Hi all,
suppose I have:

s='a=b, c=d'

and I want to extract sub-strings a,b,c and d from s (and in general 
from any longer list of such comma separated pairs).

Some failed attempts:

In [12]: re.findall(r'(.+)=(.+)', s)
Out[12]: [('a=b, c', 'd')]

In [13]: re.findall(r'(.+?)=(.+)', s)
Out[13]: [('a', 'b, c=d')]

In [14]: re.findall(r'(.+)=(.+)*', s)
Out[14]: [('a=b, c', 'd')]

In [15]: re.findall(r'(.+)=(.+),', s)
Out[15]: [('a', 'b')]

In [16]: re.findall(r'(.+)=(.+),?', s)
Out[16]: [('a=b, c', 'd')]

Thanks for your help,
francesco.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Regular expression for "key = value" pairs

2010-12-23 Thread Ciccio
I extracted an isolated problem from a slightly more complex
situation, that's why I'm using REs.
Thank you all for your help, my problem is now solved.
-- 
http://mail.python.org/mailman/listinfo/python-list


inspect.getsource bug?

2010-12-26 Thread Ciccio
Try this:
1) define a function 'foo' in a script
2) runfile the script from a shell
3) do 'inspect.getsource(foo)'
4) change the source of 'foo'
5) runfile the script from the same shell
6) do 3 again

On my 2.6.6 getsource returns twice the same code. I couldn't find
very much about this, is there any known workaround?

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inspect.getsource bug?

2010-12-26 Thread Ciccio
On 26 Dic, 19:24, Ciccio  wrote:
> Try this:
> 1) define a function 'foo' in a script
> 2) runfile the script from a shell
> 3) do 'inspect.getsource(foo)'
> 4) change the source of 'foo'
> 5) runfile the script from the same shell
> 6) do 3 again
>
> On my 2.6.6 getsource returns twice the same code. I couldn't find
> very much about this, is there any known workaround?
>
> thanks

found this in the meantime: http://bugs.python.org/issue993580
-- 
http://mail.python.org/mailman/listinfo/python-list



Dictionary of lists strange behaviour

2010-11-09 Thread Ciccio

Hi all,

hope you can help me understanding why the following happens:

In [213]: g = {'a': ['a1','a2'], 'b':['b1','b2']}
In [214]: rg = dict.fromkeys(g.keys(),[])
In [215]: rg
Out[215]: {'a': [], 'b': []}
In [216]: rg['a'].append('x')
In [217]: rg
Out[217]: {'a': ['x'], 'b': ['x']}

What I meant was appending 'x' to the list pointed by the key 'a' in the 
dictionary 'rg'. Why rg['b'] is written too?


Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dictionary of lists strange behaviour

2010-11-09 Thread Ciccio

Il 09/11/2010 16:47, Terry Reedy ha scritto:

On 11/9/2010 9:14 AM, Ciccio wrote:

Hi all,

hope you can help me understanding why the following happens:

In [213]: g = {'a': ['a1','a2'], 'b':['b1','b2']}
In [214]: rg = dict.fromkeys(g.keys(),[])


If you rewrite this as

bl = []
rg = dict.fromkeys(g.keys(),bl)

is the answer any more obvious?


It isn't since I erroneously assumed that a clone of the object would be 
made in both cases.


Thanks for your help
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dictionary of lists strange behaviour

2010-11-09 Thread Ciccio

Thank you all, this was timely and helpful.
francesco
--
http://mail.python.org/mailman/listinfo/python-list