@@ -131,15 +131,23 @@ def copy_files(self):
131131 self .log .info ("Source: {}" .format (self .src_path ))
132132 self .log .info ("Destination: {}" .format (dest_path ))
133133
134+ errors = []
135+
134136 # copy to the real location
135137 self .check_filename_diff ()
136- self .do_copy (self .src_path , dest_path )
137- with open (os .path .join (dest_path , "timestamp.txt" ), "w" ) as fh :
138- fh .write (self .timestamp )
139- self .set_perms (
140- dest_path ,
141- fileperms = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ),
142- dirperms = (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH ))
138+ try :
139+ self .do_copy (self .src_path , dest_path )
140+ except OSError as err :
141+ errors .append (err )
142+
143+ # Create timestamp even if copying is incomplete to not break later functions
144+ if os .path .isdir (dest_path ):
145+ with open (os .path .join (dest_path , "timestamp.txt" ), "w" ) as fh :
146+ fh .write (self .timestamp )
147+ self .set_perms (
148+ dest_path ,
149+ fileperms = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ),
150+ dirperms = (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH ))
143151
144152 # Make this 0777=ugo=rwx so the instructor can delete later. Hidden from other users by the timestamp.
145153 os .chmod (
@@ -150,10 +158,16 @@ def copy_files(self):
150158 # also copy to the cache
151159 if not os .path .isdir (self .cache_path ):
152160 os .makedirs (self .cache_path )
153- self .do_copy (self .src_path , cache_path )
161+ try :
162+ self .do_copy (self .src_path , cache_path )
163+ except OSError as err :
164+ errors .append (err ) # probably duplicates from above
154165 with open (os .path .join (cache_path , "timestamp.txt" ), "w" ) as fh :
155166 fh .write (self .timestamp )
156167
157168 self .log .info ("Submitted as: {} {} {}" .format (
158169 self .coursedir .course_id , self .coursedir .assignment_id , str (self .timestamp )
159170 ))
171+
172+ if errors :
173+ raise OSError (errors )
0 commit comments