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:
daniele 2023-06-15 18:44:22 +02:00
parent ff70358496
commit 4d23bde906
Signed by: fuxino
GPG Key ID: 981A2B2A3BBF5514
2 changed files with 20 additions and 4 deletions

View File

@ -1,3 +1,3 @@
"""Init."""
__version__ = '3.4.0'
__version__ = '3.4.1'

View File

@ -186,12 +186,28 @@ class Backup:
self.create_backup_dir()
_, 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:
for i in self.inputs:
fp.write(i)
fp.write('\n')
if not os.path.exists(i):
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:
if self.exclude is not None: