6464
6565 # --- the code is taken from pyserial project ---
6666 #
67- # detect size of ULONG_PTR
67+ # detect size of ULONG_PTR
6868 def is_64bit ():
6969 return ctypes .sizeof (ctypes .c_ulong ) != ctypes .sizeof (ctypes .c_void_p )
7070 if is_64bit ():
@@ -102,7 +102,7 @@ class OVERLAPPED(ctypes.Structure):
102102 UnlockFileEx = windll .kernel32 .UnlockFileEx
103103 UnlockFileEx .restype = BOOL
104104 UnlockFileEx .argtypes = [HANDLE , DWORD , DWORD , DWORD , LPOVERLAPPED ]
105-
105+
106106elif os .name == 'posix' :
107107 import fcntl
108108 LOCK_SH = fcntl .LOCK_SH # shared lock
@@ -116,7 +116,8 @@ def lock(file, flags):
116116 """ Return True on success, False otherwise """
117117 hfile = msvcrt .get_osfhandle (file .fileno ())
118118 overlapped = OVERLAPPED ()
119- if LockFileEx (hfile , flags , 0 , 0 , 0xFFFF0000 , ctypes .byref (overlapped )):
119+ if LockFileEx (hfile , flags , 0 , 0 , 0xFFFF0000 ,
120+ ctypes .byref (overlapped )):
120121 return True
121122 else :
122123 return False
@@ -129,7 +130,7 @@ def unlock(file):
129130 else :
130131 return False
131132
132- elif os .name == 'posix' :
133+ elif os .name == 'posix' :
133134 def lock (file , flags ):
134135 if fcntl .flock (file .fileno (), flags ) == 0 :
135136 return True
@@ -150,10 +151,9 @@ def unlock(file):
150151 lock (log , LOCK_EX )
151152
152153 timestamp = strftime ("%m/%d/%Y %H:%M:%S\n " , localtime (time ()))
153- log .write ( timestamp )
154+ log .write (timestamp )
154155
155156 print ("Wrote lines. Hit enter to release lock." )
156157 dummy = sys .stdin .readline ()
157158
158159 log .close ()
159-
0 commit comments