How to call application in the background with subprocess.call

2010-04-08 Thread jorma kala
Hi,

I'd like to call an external application (firefox) from a python program (a
PyQT GUI), but I want the external application to run in the background, I
mean I do not want my python calling program to wait till the external
subprocess terminates.
I've tried this:

call([firefox, http://www.python.org;])

but my PyQT interface freezes until I terminate Firefox.
Is there any parameter I need to use with call so that the python calling
program doesn't wait for the termination of the subprocess?

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


Re-enabling a logger

2009-10-22 Thread jorma kala
Hi,
I'm using the logging module.
At one point in my code I disable logging like this:

logging.disable(logging.INFO)

But how can I enable the logging again further on?

I've tried the following, which doesn't work for re-enabling the logger:

my_logger.setLevel(logging.INFO)

I've also tried to disable the logger by doin this:

 my_logger.setLevel(logging.NOTSET)

and then re-enabling like this:

my_logger.setLevel(logging.INFO)

But that doesnt work either.

Can you tell me how to re-enable the logging?
Many thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


logger module : Question about log message format

2009-09-04 Thread jorma kala
Hi,
I've created a logger like this:


LOG_FILENAME = 'test.txt'
fh=logging.FileHandler(LOG_FILENAME,'w')
logger1 = logging.getLogger('myLogger1')
logger1.addHandler(fh)
logger1.setLevel(logging.INFO)
logger1.info('message from logger1')

and was hoping to get log messages in this format in my log file:

:INFO:myLogger1:message from logger1

instead I just get a plain message like this:

message from logger1

Do you know why?

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


Question about apply

2009-09-03 Thread jorma kala
Hi,
I'm using apply to pass keyword arguments as a dictionary  to a funcion at
runtime (which keyword arguments to pass is only known at runtime)
apply is very handy for this, because it takes a dictionary of keyword
arguments directly

def f1(a=None,b=None,c=None):
pass


kw={'a':1}

apply(f1,[],kw)

But I read in the doc that apply is deprecated.
What is the non-deprecated way of doing this?
Many thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about apply

2009-09-03 Thread jorma kala
Many thanks!!



On Thu, Sep 3, 2009 at 4:21 PM, Gary Herron gher...@islandtraining.comwrote:

  jorma kala wrote:


 Hi,
 I'm using apply to pass keyword arguments as a dictionary  to a funcion at
 runtime (which keyword arguments to pass is only known at runtime)
 apply is very handy for this, because it takes a dictionary of keyword
 arguments directly

 def f1(a=None,b=None,c=None):
pass
 kw={'a':1}

 apply(f1,[],kw)

 But I read in the doc that apply is deprecated.
 What is the non-deprecated way of doing this?
 Many thanks


 Use the double-star syntax:

 f1(**kw)


 Gary Herron


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


Re: How to document Python code properly for Pydoc

2009-07-23 Thread jorma kala
Thanks very much for your help

On Wed, Jul 22, 2009 at 6:43 PM, Lie Ryan lie.1...@gmail.com wrote:

  jorma kala wrote:
  Hi,
  Do you know where I can find the rules for documenting Python code, so
  that automatic document generation with Pydoc makes the most of the
  comments inserted in the code?
  I know about documenting class and method through triple quote just
  under the class definition. But how do you comment a specific field or
  variable, or how do you document function arguments so that they are
  extracted like in javadoc?
  Thanks very much

 pydoc is a simple tool, and doesn't do much. You write in freeform,
 although generally you'll do something like this:

 def myfunc(a, b):
'''
short description of myfunc

longer description of myfunc, if necessary, and typically includes
description of the arguments and the behaviors. Also includes the
description of the return value.
'''

pass

 pydoc doesn't recognize any special markups. If you want to get more
 from the docstring, you need other documentation generator such as
 epydoc, Doxygen, or Sphinx.

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

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


How to document Python code properly for Pydoc

2009-07-22 Thread jorma kala
Hi,
Do you know where I can find the rules for documenting Python code, so that
automatic document generation with Pydoc makes the most of the comments
inserted in the code?
I know about documenting class and method through triple quote just under
the class definition. But how do you comment a specific field or variable,
or how do you document function arguments so that they are extracted like in
javadoc?
Thanks very much
-- 
http://mail.python.org/mailman/listinfo/python-list


Retrieving column values by column name with MySQLdb

2009-06-19 Thread jorma kala
Hi,
Is there a way of retrieving the value of columns in the rows returned by
fetchall, by column name instead of index on the row?
Code Snippet:

 query=select * from employees
 db=MySQLdb.connect(host=host,user=user,passwd=passwd,db=database)
 cursor = db.cursor ()
 cursor.execute (query)
 rows = cursor.fetchall ()

  for row in rows:
   print row[0]


Instead of specifying the index of the row to retrieve the first column
(row[0]), I'd like to retrieve the value of the first column by column name.
Something like row.get('employee_id')
Is something of the sort possible with Mysqdb?
Thanks very much.
-- 
http://mail.python.org/mailman/listinfo/python-list


Accessing files in a directory which is a shortcut link (Windows)

2009-05-02 Thread jorma kala
Hi,
I'd like to process files in a directory which is in fact a short cut link
to another directory (under windows XP).
If the path to the directory is for instance called c:\test. I have tried
both following code snipets for printing all names of files in the
directory:

++ snippet 1++

 for filename in glob.glob( os.path.join(r'c:\test', '*') ):
 print filename

++ snippet 2++

 for filename in glob.glob( os.path.join(r'c:\test.lnk', '*') ):
 print filename

Neither solution works.
Thanks very much for any help.
--
http://mail.python.org/mailman/listinfo/python-list


Using ascii numbers in regular expression

2009-04-28 Thread jorma kala
Hi,

How can I use the ascii number of a character in a regular expression
(module re) instead of the character itself?
Thanks very much
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using ascii numbers in regular expression

2009-04-28 Thread jorma kala
Thanks very much for your reply.
What I mean is that I would like to use the ascii number in a regular
expression pattern.
For instance, if I want to substitute the occurrences of character 'a' for
the character 'b' in a string, instead of doing this:

re.subn('a','b','')

I'd like to specify the ascii number of a (which is 97)
I tried converting 97 to hexadecimal (with hex()) and tried this

re.subn(''\0x61,'b','')

but it doesnt work.
I need this because I'm working on non printable characters.

Thanks a lot



On Tue, Apr 28, 2009 at 12:45 PM, Chris Rebert c...@rebertia.com wrote:

  On Tue, Apr 28, 2009 at 4:05 AM, jorma kala jjk...@gmail.com wrote:
  Hi,
 
  How can I use the ascii number of a character in a regular expression
  (module re) instead of the character itself?
  Thanks very much

 I refer you to the chr() and ord() built-in functions, which can
 certainly be used to solve your problem, though they are not
 regex-specific in application.
 http://docs.python.org/library/functions.html

 Cheers,
 Chris
 --
 http://blog.rebertia.com

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


Using ZSI Soap libraries from behind a proxy-based firewall

2008-11-04 Thread jorma kala
Hi I'm trying to build a simple soap client using  the ZSI library.
My python script operates from behind a proxy-based firewall.
Do you know how I can specify the proxy name and port to use, when using the
ZSI client.
( using the urllib2, this can be done through ProxyHandler, for instance.
But I dont know how its done using soap libraries.
Many thanks
--
http://mail.python.org/mailman/listinfo/python-list


Using httplib to access servlets on tomcat server

2008-09-03 Thread jorma kala
Hi,

I'm trying unsuccesfully to use the httplib library to execute servlets on a
local tomcat server.

If I type the following http adress on my browser
http://localhost:8080/test/Serv1  the servlet works fine.
But if I try to access it with the following python code:

   conn = httplib.HTTPConnection(http://localhost:8080;)
   conn.request(GET, /test/Serv1)
   r1 = conn.getresponse()

I get the following error:

socket.gaierror: (11001, 'getaddrinfo failed')

Do you know what I do wrong?
Thank you very much.


(The complete traceback is:

Traceback (most recent call last):
  File http1.py, line 130, in module
getTomcat1()
  File http1.py, line 46, in getTomcat1
conn.request(GET, /test/Serv1)
  File C:\Python25\lib\httplib.py, line 862, in request
self._send_request(method, url, body, headers)
  File C:\Python25\lib\httplib.py, line 885, in _send_request
self.endheaders()
  File C:\Python25\lib\httplib.py, line 856, in endheaders
self._send_output()
  File C:\Python25\lib\httplib.py, line 728, in _send_output
self.send(msg)
  File C:\Python25\lib\httplib.py, line 695, in send
self.connect()
  File C:\Python25\lib\httplib.py, line 663, in connect
socket.SOCK_STREAM):
socket.gaierror: (11001, 'getaddrinfo failed')
--
http://mail.python.org/mailman/listinfo/python-list

Retrieving http headers from HTTPConnection object

2008-09-01 Thread jorma kala
Hi,

when using  httplib for http requests, like for example:


   conn = httplib.HTTPConnection(www.python.org)
   conn.request(GET, /index.html)

Is it possible to retrieve the complete http request in string form :


GET /index.html HTTP/1.1
Host: www.python.org
User-Agent: ...
Accept:   ...
Accept-Language:
Accept-Encoding:
Accept-Charset:
Keep-Alive:
Connection:

I mean does  the HTTPConnection object have a property that stores this ?
or is it retrievable by some other form?

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

Automating GUI interaction with Python

2008-02-20 Thread jorma kala
Hi,

Is there a python library or bindings to a library in some other language
for automating GUI interaction (the kind of functionality provided by Autoit
for instance).
What I need to do is very simple GUI automation : moving the mouse cursor to
and from specified screen coordinates, clicking, etc.
Thanks a lot.
-- 
http://mail.python.org/mailman/listinfo/python-list

getpixel with Python Imaging Library

2007-11-30 Thread jorma kala
Hi,
I read that the getpixel function of the PIL library is relatively slow.
Which alternative is therefore faster and more efficient, accesing the
result of getdata() as a flat list or
using  the function load(), and accessing pixels through the resulting
2-dimensional array?

Thanks a lot.

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

Problem using subprocess.Popen on windows

2007-10-07 Thread jorma kala
Hi,

I get an error that I don't understand when using the subprocess module on
Windows.
I guess I'm missing out something very basic.
For instance, to execute and capture the output of the ms-dos dir command, I
tried the following:


from subprocess import *

p1 = Popen([dir],  stdout=PIPE)
output = p1.communicate()[0]


But I get a WindowsError : [Error 2]  File Not Found


The exact traceback is :

Traceback (most recent call last):
  File pipe2.py, line 5, in module
p1 = Popen([dir],  stdout=PIPE)
  File C:\Python25\lib\subprocess.py, line 593, in __init__
errread, errwrite)
  File C:\Python25\lib\subprocess.py, line 815, in _execute_child
startupinfo)
WindowsError: [Error 2] Le fichier spÚcifiÚ est introuvable


Do you know what is missing in my code?

Thanks a lot

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

Using ImageGrab (PIL) to capture screen of remote computer

2007-10-02 Thread jorma kala
Hi,

Is it possible to use ImageGrab of the Python Imaging Library to capture the
screen of a remote computer?

I'm running my python program on a computer that is connected directly via a
ethernet crossover cable to another computer.
Can I somehow get ImageGrab to grab the display of the remote computer by
specifying the IP address ?

Thanks a lot

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