[fcntl]how to lock a file
Hello I need to do this: 1 opening a file for writing/appending 2 to lock the file as for writing (i mean: the program that lock can keep writing, all others programs can't ) 3 wtite and close/unlock Even better would be changing the order of steps 1 and 2 (that is,first locking than writing, but it seems to me that in order to block i need the id of the file...) Untill now i have tried to do smthing like : import fcntl f=open("prova.txt", 'w') fcntl.flock(f.fileno(),fcntl.LOCK_EX) f.write("aaa") #meanwhile i open prova.txt with an editor in another window #and write in "bbb" (without getting any error/warning)and then follow #in the python shell with f.close() But then opening the file i can see "bbb" instead of "aaa" I'm wandering, am i completely lost(misled?)Am i waiting for fcntl to do what it doesn't? I have tried too with: f1=os.open('prova.txt',os.O_EXCL|os.O_APPEND) os.write(f1,"qlcosa") that should solve the problem of the order of the step, but i not even can write from the python shell with that. python 2.2 linux kernel 2.4 glibc-2.3.2-95.6 Thanks in advance for any help. sorry for my bad english Grazie Marcello -- http://mail.python.org/mailman/listinfo/python-list
Re: [fcntl]how to lock a file
thank you a lot for your answering Bye Marcello -- http://mail.python.org/mailman/listinfo/python-list
Re: [fcntl]how to lock a file
Carl J. Van Arsdall wrote: > [...] > > If you end up having problems working with the python fcntl module let > me know your configuration I'd be interested to see if anyone else had > similar problems to me. Python 2.2.3 (#1, Aug 8 2003, 08:44:02) [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-13)] on linux2 kernel 2.4.21-4.0.1.ELsmp glibc-2.3.2-95.6 What else can i add? best regards Marcello -- http://mail.python.org/mailman/listinfo/python-list
Re: A way to wait Python event
Chang LI wrote: I tried to launch "python.exe test.py" in another program. After the launch the console was showed and exited on Windows. I want the console stay there. Is there a Python statement to wait an event loop like Tcl's "after forever"? If you need to keep a cmd window open maybe you can try this. Unfortunately I don't have time to screen which lines are exactly the ones you need. I don't remember why it is like that. For example I guess you can remove it the line realated to notepad You'll figure out the best way to use it. But I suggest you to first look at the preexisting values of those keys. So you can come back to the preexisting situation if you don't like it ( you'll see Take the following lines and put them in .reg file. Then run it. After that when you right click on a file you'll have the option to open it with Notepad or with a Command prompt that stays open. Hope it helps. Cheers, Marcello REGEDIT4 [HKEY_CLASSES_ROOT\*] [HKEY_CLASSES_ROOT\*\shell] [HKEY_CLASSES_ROOT\*\shell\dos_box] @="DOS Box" [HKEY_CLASSES_ROOT\*\shell\dos_box\command] @="cmd" [HKEY_CLASSES_ROOT\*\shell\open] @="Notepad" [HKEY_CLASSES_ROOT\*\shell\open\command] @="Notepad.exe %1" [HKEY_CLASSES_ROOT\Folder\shell] [HKEY_CLASSES_ROOT\Folder\shell\dos_box] @="DOS Box" [HKEY_CLASSES_ROOT\Folder\shell\dos_box\command] @="cmd /k cd %1" [HKEY_CLASSES_ROOT\batfile\shell] [HKEY_CLASSES_ROOT\batfile\shell\runstayopen] @="R&un - Stay open" [HKEY_CLASSES_ROOT\batfile\shell\runstayopen\command] @="cmd /k %1" [HKEY_CLASSES_ROOT\comfile\shell] [HKEY_CLASSES_ROOT\comfile\shell\runstayopen] @="R&un - Stay open" [HKEY_CLASSES_ROOT\comfile\shell\runstayopen\command] @="cmd /k %1" [HKEY_CLASSES_ROOT\exefile\shell] [HKEY_CLASSES_ROOT\exefile\shell\runstayopen] @="R&un - Stay open" [HKEY_CLASSES_ROOT\exefile\shell\runstayopen\command] @="cmd /k %1" --- -- http://mail.python.org/mailman/listinfo/python-list
SOAPpy - send xml data
Hi, I'm trying to send some xml data to a WSDL server. Here's my code: xmldata = "Test di messaggio 1 + 3202181465 17.5.2007 12:59:53 """ SOAPpy.WSDL.Config.namespaceStyle = '2001' server = SOAPpy.WSDL.Proxy('https://www.oesystem.net/services/oeservice.asmx?WSDL') print server.insertMessages(xmlRequest=xmldata) parsing the output I've got two problems, about the tag, that is the tag that contains my xml data: - soappy escape xmlRequest tag, in my output I've got _x_xmlRequest as xml is _x_ - I didn't find a way to specify the type of the data that I send to my WSDL server => <_x_xmlRequest xsi3:type="xsd3:string"> In other words, I'd like to include my xmldata into a simple and I don't know how to do it with SOAPpy library. thank you -- http://mail.python.org/mailman/listinfo/python-list
SOAPpy - send xml data
Hi, I'm trying to send some xml data to a WSDL server. Here's my code: xmldata = "Test di messaggio 1 + 2 17.5.2007 12:59:53 """ SOAPpy.WSDL.Config.namespaceStyle = '2001' server = SOAPpy.WSDL.Proxy('https://www.mywdslserver.com/foo.asp?WSDL') print server.insertMessages(xmlRequest=xmldata) parsing the output I've got two problems, about the tag, that is the tag that contains my xml data: - soappy escape xmlRequest tag, in my output I've got _x_xmlRequest as xml is _x_ - I didn't find a way to specify the type of the data that I send to my WSDL server => <_x_xmlRequest xsi3:type="xsd3:string"> In other words, I'd like to include my xmldata into a simple and I don't know how to do it with SOAPpy library. thank you -- http://mail.python.org/mailman/listinfo/python-list