Uploading a file using POST

2009-03-18 Thread Thomas Robitaille

Hello,

I am trying to upload a binary file (a tar.gz file to be exact) to a  
web server using POST, from within a python script.


At the moment I am trying

URL="http://www.whatever.com";
f=open(filename, 'rb')
filebody = f.read()
f.close()
data = {'name':'userfile','file': filebody}
u = urllib.urlopen(URL,urllib.urlencode(data))
u.read()

The page on the web server receiving the file is a PHP script. What I  
would like is for the path to the uploaded file to appear in the  
$_FILES global variable. However, this is not happening. Instead, the  
content of the file is all contained inside the $_POST variable.


What I would like is essentially the equivalent of

enctype="multipart/form-data">




which does result in the file being uploaded and the path placed in  
$_FILES.


What am I doing wrong?

Thanks for any help!

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


Read IDL save files into Python

2009-11-23 Thread Thomas Robitaille
I would like to briefly advertise the 0.9.2 release of IDLSave, a
package I recently developed to read IDL save files into Python.
Installation instructions are available at http://idlsave.sourceforge.net/.
Please do not hesitate to submit a bug report if you run into any
problems!

Cheers,

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


multiprocessing and process run time

2009-06-19 Thread Thomas Robitaille

Hi,

I'm making use of the multiprocessing module, and I was wondering if there
is an easy way to find out how long a given process has been running for.
For example, if I do

import multiprocessing as mp
import time

def time_waster():
time.sleep(1000)

p = mp.Process(target=time_waster)

p.start()

Is there a way that I can then find how long p has been running for? I
figured I can use p.pid to get the PID of the process, but I'm not sure
where to go from there. Is there an easy way to do this?

Thanks,

Thomas
-- 
View this message in context: 
http://www.nabble.com/multiprocessing-and-process-run-time-tp24112854p24112854.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Column types with DB API

2009-06-28 Thread Thomas Robitaille

Hi,

I'm trying to use DB API compliant database modules
(psycopg2,MySQLdb,SQLite) to access SQL databases, and I am trying to
determine the type of each column in a table. The DB API defines
cursor.description which contains information about the column names and
types (once .execute() has been used to select part or all of the table),
but the types are expressed as integers. I realize that these numbers can be
checked against the type objects such as MySQLdb.NUMBER to determine whether
a given column is a number, a date, text, etc. However, is there any way to
determine what the sub-type of a column is, for example if a column is a
NUMBER, is there a way to determine if it is a 2, 4, or 8-byte integer or
real number?

Thanks in advance for any advice,

Thomas
-- 
View this message in context: 
http://www.nabble.com/Column-types-with-DB-API-tp24245424p24245424.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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