How to check whether file is open or not

2007-03-06 Thread Ros
There are 10 files in the folder. I wish to process all the files one
by one. But if the files are open or some processing is going on them
then I do not want to disturb that process. In that case I would
ignore processing that particular file and move to next file.

How can I check whether the file is open or not?

I tried os.stat and os.access but I am not getting the expected
results.
Also I checked in IO exceptions, IO error handler doesnt raise any
error if the file is open.
There are some options to check but they are platform dependent (works
only with unix)

Your help would be highly appreciated.

Thanks,
Ros

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


Re: How to check whether file is open or not

2007-03-08 Thread Ros

Thanks a lot Gabriel.
ctypes is working!

Regards,
Ros


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


Writing xml file from MS SQL

2007-03-08 Thread Ros
I am using pymssql for storing data into MS SQL. (I am using pymssql
first time so dont know much about it)
I wish to write/create XML file from database.
There are few examples available for mysql but not much information
about pymssql and MS SQL.

I have worked with cElementTree with SAX and I guess it can parse data
in the most efficient manner if you compare it with other parsers. How
can I use cElementTree to write xml file with the combination of
pymssql(MS SQL) and pyxml.

If you know any links, examples then please post them.

Regards,
Ros

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


sql to xml

2007-04-17 Thread Ros
Hi,

I wish to write xml file after validating data from mssql database.
I am using xml data mapping list and would use it for validating data.
Here is the program :

Map_list.xml :


 
 
 
 


Program :

from cElementTree import iterparse
import pymssql

# Database connection details
host = '192.168.1.1'
db = 'Books'
usr = 'ros_albert'
pwd = 'ros_albert'
conn = pymssql.connect(host=host, user=usr, password=pwd, database=db)
table = "books_details"
cursor = conn.cursor()

cursor.execute( 'select * from books_details')
for row in cursor.fetchall():
fname = row[0]

# Here is the code to validate the minimum length & maximum length of
data, if its ok then I would write the data into xml file

context = iterparse('Map_list.xml', events=("start", "end"))
root = None
for event, child in context:
if event == "start":
if child.tag == 'loop':
w.push_loop(child.attrib['id'])

if child.tag == 'ele':
w.push_ele(child.attrib['id'])

# Here I am validating the data using "Map_list.xml" file, validation
part is working fine.

if event == "end":
if child.tag == 'ele':
writer.pop_ele()

if child.tag == 'loop':
writer.pop_loop()


I am able to write a data from 1 xml file to another but not getting
how to write & validate data from sql to xml.
May be I am not sure what mapping is. I wish to map the data columns
in sql database with the xml data.

any help would be highly appreciated.

Regards,
Ros

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