Check that inputs from command line exist
Check that the inputs specified on the command line (i.e. with the option '-i' or '--input') exist and print a warning when they don't. If no valid inputs are found, exit.
This commit is contained in:
parent
ff70358496
commit
4d23bde906
@ -1,3 +1,3 @@
|
|||||||
"""Init."""
|
"""Init."""
|
||||||
|
|
||||||
__version__ = '3.4.0'
|
__version__ = '3.4.1'
|
||||||
|
@ -186,12 +186,28 @@ class Backup:
|
|||||||
self.create_backup_dir()
|
self.create_backup_dir()
|
||||||
|
|
||||||
_, self._inputs_path = mkstemp(prefix='tmp_inputs', text=True)
|
_, self._inputs_path = mkstemp(prefix='tmp_inputs', text=True)
|
||||||
_, self._exclude_path = mkstemp(prefix='tmp_exclude', text=True)
|
count = 0
|
||||||
|
|
||||||
with open(self._inputs_path, 'w') as fp:
|
with open(self._inputs_path, 'w') as fp:
|
||||||
for i in self.inputs:
|
for i in self.inputs:
|
||||||
fp.write(i)
|
if not os.path.exists(i):
|
||||||
fp.write('\n')
|
logger.warning(f'Input {i} not found. Skipping')
|
||||||
|
else:
|
||||||
|
fp.write(i)
|
||||||
|
fp.write('\n')
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
if count == 0:
|
||||||
|
logger.info('No existing files or directories specified for backup. Nothing to do')
|
||||||
|
|
||||||
|
try:
|
||||||
|
notify('Backup finished. No files copied')
|
||||||
|
except NameError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return 1
|
||||||
|
|
||||||
|
_, self._exclude_path = mkstemp(prefix='tmp_exclude', text=True)
|
||||||
|
|
||||||
with open(self._exclude_path, 'w') as fp:
|
with open(self._exclude_path, 'w') as fp:
|
||||||
if self.exclude is not None:
|
if self.exclude is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user