mò DµMc@sòdZdkZdkZdkZeidƒZdZydkZdZWnnXy%dk Z dk Z dk Z dZWnnXedjo:e i Z dZe iZe iƒZd„Zd„Zn”edjo1ei Z eiZeiZd„Zd „ZnVeiƒd joeid ƒneid ƒdZ dZdZd „Zd„Zedjo…dklZlZlZdkZeddƒZeee ƒedeeƒƒƒZei eƒdGHei!i"ƒZ#ei$ƒndS(sÛ Cross-platform (posix/nt) API for flock-style file locking. Synopsis: import portalocker file = open("somefile", "r+") portalocker.lock(file, portalocker.LOCK_EX) file.seek(12) file.write("foo") file.close() If you know what you're doing, you may choose to portalocker.unlock(file) before closing the file, but why? Methods: lock( file, flags ) unlock( file ) Constants: LOCK_EX LOCK_SH LOCK_NB I learned the win32 technique for locking files from sample code provided by John Nielsen in the documentation that accompanies the win32 modules. Author: Jonathan Feinberg Version: $Id: portalocker.py,v 1.3 2001/05/29 18:47:55 Administrator Exp $ Ntweb2pytposixtwindowsicCs2ti|iƒƒ}ti||ddtƒdS(Niiÿ(t win32filet_get_osfhandletfiletfilenothfilet LockFileExtflagst __overlapped(RR R((t;/home/camdpams_www/Products_Activation/gluon/portalocker.pytlockGscCs/ti|iƒƒ}ti|ddtƒdS(Niiÿ(RRRRRt UnlockFileExR (RR((R tunlockKscCsti|iƒ|ƒdS(N(tfcntltflockRRR (RR ((R R UscCsti|iƒtiƒdS(N(RRRRtLOCK_UN(R((R RXstWindowsskno file locking, you must install the win32 extensions from: http://sourceforge.net/projects/pywin32/files/s)no file locking, this will cause problemscCsdS(N((RR ((R R fscCsdS(N((R((R Rist__main__(stimesstrftimes localtimeslog.txtsa+s%m/%d/%Y %H:%M:%S s'Wrote lines. Hit enter to release lock.(%t__doc__tostloggingtplatformt getLoggertloggertNonet os_lockingRtwin32conRt pywintypestLOCKFILE_EXCLUSIVE_LOCKtLOCK_EXtLOCK_SHtLOCKFILE_FAIL_IMMEDIATELYtLOCK_NBt OVERLAPPEDR R Rtsystemterrortdebugt__name__ttimetstrftimet localtimetsystopentlogt timestamptwritetstdintreadlinetdummytclose(R RRRR R-RR"RR R*RR.RR+RR2RRR(RR)((R t?)s`