4242if not VERSION_PATH .exists ():
4343 with open (f"{ VERSION_PATH } " , "w" ) as version_file :
4444 version_file .write (json .dumps ({"currentVersion" : "v1.0.0 - Release" }))
45+ # close
46+ version_file .close ()
4547
4648with open (f"{ VERSION_PATH } " , "r+" ) as version_file :
4749 version_data = json .load (version_file )
5456 version_file .write (json .dumps ({"currentVersion" : "v1.0.0 - Release" }))
5557
5658 current_version = version_data ["currentVersion" ]
59+ version_file .close ()
5760
5861
5962def relative_to_logs (path : str ) -> Path :
@@ -152,6 +155,7 @@ def log_routine(log: str, time_needed: bool = True, hide_pid: bool = True):
152155 # append log_header to the file.
153156 with open (f"{ relative_to_logs (f'{ file_log_name } .log' )} " , "a" ) as log_file :
154157 log_file .write (log_header )
158+ log_file .close ()
155159
156160 # if the first line of {file_log_name}.log is different from current_version
157161 with open (f"{ relative_to_logs (f'{ file_log_name } .log' )} " ) as check_ver :
@@ -165,6 +169,7 @@ def log_routine(log: str, time_needed: bool = True, hide_pid: bool = True):
165169 log_file .write (
166170 "\n \n [NOTICE] Log file has been deleted or cleaned.\n "
167171 )
172+ log_file .close ()
168173 else :
169174 # Delete everything inside the file and append log_header.
170175 with open (
@@ -174,6 +179,7 @@ def log_routine(log: str, time_needed: bool = True, hide_pid: bool = True):
174179 log_file .write (
175180 f"\n \n [NOTICE] PROGRAM HAS BEEN UPDATED TO { current_version } !\n "
176181 )
182+ log_file .close ()
177183
178184 # if the file exceeds 1000 lines, delete everything and append log_header to the file.
179185 with open (f"{ relative_to_logs (f'{ file_log_name } .log' )} " , "r" ) as log_file :
@@ -207,3 +213,4 @@ def log_routine(log: str, time_needed: bool = True, hide_pid: bool = True):
207213
208214if __name__ == "__main__" :
209215 print (__copyright__ )
216+ exit ()
0 commit comments