Example #1
0
 def _copy_file(self):
     cur_item = self._tree.focus()
     cur_path = self._item_paths.get(cur_item, '')
     if cur_path != '':
         new_path = os.path.join(self._state.device_to_path, os.path.basename(cur_path))
         try:
             if os.path.exists(new_path):
                 if ConfirmFrame.show(
                     self._master, self._config,
                     'The file already exists in the destination.\n'
                     'Would you like to overwrite it?',
                     'Yes', 'No'
                 ):
                     shutil.copyfile(cur_path, new_path)
             else:
                 shutil.copyfile(cur_path, new_path)
         except PermissionError:
             OkFrame.show(
                 self._master, self._config,
                 'Error copying file:\n\nInvalid permissions'
             )
         except Exception as e:
             OkFrame.show(
                 self._master, self._config,
                 'An error occurred while copying the file:\n\n{}'.format(e)
             )
Example #2
0
 def _delete_file(self):
     cur_item = self._tree.focus()
     cur_path = self._item_paths.get(cur_item, '')
     if cur_path != '':
         disp_path = cur_path[len(self._state.to_device.part().mount()):]
         try:
             if ConfirmFrame.show(
                 self._master, self._config,
                 'Are you sure you\'d like to delete this file?\n{}'.format(disp_path),
                 'Yes', 'No'
             ):
                 os.remove(cur_path)
                 self._tree.delete(self._tree.focus())
         except PermissionError:
             OkFrame.show(
                 self._master, self._config,
                 'Error deleting file:\n\nInvalid permissions'
             )
         except Exception as e:
             OkFrame.show(
                 self._master, self._config,
                 'An error occurred while deleting the file:\n\n{}'.format(e)
             )