Changeset 41060 for branches/ipp-350_add_to_jira_conf_backups/backup.py
- Timestamp:
- Nov 5, 2019, 10:34:28 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ipp-350_add_to_jira_conf_backups/backup.py
r41059 r41060 33 33 [ ConfigSchemaLine('sources', True, list, SpecialSchemaProcessing.commma_separated) 34 34 , ConfigSchemaLine('additional_args', False, list, SpecialSchemaProcessing.space_separated) 35 , ConfigSchemaLine('sub-dirs', False, list, SpecialSchemaProcessing.commma_separated) 35 36 ] 36 37 ) … … 205 206 sources = self.rsync_dict['sources'] 206 207 for i in range(0, len(sources)): 207 s = sources[i]208 if not path.exists(s ):209 raise errs.ValidationError(f"ValidationError: target path does not exist: {s }")208 source = sources[i] 209 if not path.exists(source): 210 raise errs.ValidationError(f"ValidationError: target path does not exist: {source}") 210 211 211 212 for bp in backup_paths: 212 213 try: 213 args = [s, bp] 214 214 additional_args = [] 215 215 if 'additional_args' in self.rsync_dict.keys(): 216 args = args + self.rsync_dict['additional_args'] 216 additional_args = self.rsync_dict['additional_args'] 217 218 source_and_target_args = [source, bp] 219 220 # sub-dirs option allows items to be backed up to subdirs within 221 # the source for better naming 222 if 'sub-dirs' in self.rsync_dict: 223 sub_dirs = self.rsync_dict['sub-dirs'] 224 if len(sub_dirs) != len(sources): 225 raise errs.ValidationError(f"ValidationError: if using " + 226 "subdirs the number of subdirs must equal the number of sources") 227 bp_with_subdir = os.path.join(bp, sub_dirs[i]) 228 if not os.path.exists(bp_with_subdir): 229 os.makedirs(bp_with_subdir) 230 source_and_target_args = [source, bp_with_subdir] 231 232 args = source_and_target_args + additional_args 217 233 sub_utils.local_rsync_wrapper(args) 218 234 219 235 except errs.SubprocessError as e: 220 236 raise errs.SubprocessError( f"Error: rsync\n" 221 f" from: {s }\n"222 f" to: { bp}\n"237 f" from: {source_and_target_args[0]}\n" 238 f" to: {source_and_target_args[1]}\n" 223 239 ) from e 224 240 return 0
Note:
See TracChangeset
for help on using the changeset viewer.
