@@ -96,7 +96,7 @@ def save(results, checkpoint):
9696 except PermissionError :
9797 time .sleep (0.01 )
9898 else :
99- print ( "Warning: Could not save results due to persistent PermissionError." )
99+ raise PermissionError ( " Could not save results due to persistent PermissionError." )
100100
101101 with open (checkpointPath + '.tmp' , 'wb' ) as file :
102102 pickle .dump (checkpoint , file )
@@ -107,7 +107,7 @@ def save(results, checkpoint):
107107 except PermissionError :
108108 time .sleep (0.01 )
109109 else :
110- print ( "Warning: Could not save checkpoint due to persistent PermissionError." )
110+ raise PermissionError ( " Could not save checkpoint due to persistent PermissionError." )
111111
112112 def loadResults ():
113113 if os .path .exists (resultsPath ):
@@ -135,9 +135,13 @@ def importConfigModule():
135135
136136def getWorkingDir ():
137137 global working_dir
138+ global resultsPath
139+ global checkpointPath
138140 while True :
139141 working_dir = os .path .abspath (input ("Enter the working directory: " ).strip ())
140142 if os .path .isdir (working_dir ):
143+ resultsPath = os .path .join (working_dir , 'results.pkl' )
144+ checkpointPath = os .path .join (working_dir , 'checkpoint.pkl' )
141145 return working_dir
142146 else :
143147 print (f"Directory { working_dir } does not exist. Please try again." )
@@ -191,8 +195,6 @@ def simulatePrisoners():
191195 working_dir = getWorkingDir ()
192196 config = importConfigModule ()
193197 cfg = config .getConfig ()
194- resultsPath = os .path .join (working_dir , 'results.pkl' )
195- checkpointPath = os .path .join (working_dir , 'checkpoint.pkl' )
196198
197199 while True :
198200 print (f"\n Working directory: { working_dir } " )
0 commit comments