Example #1
0
    def delete(self):
        if "filename" in self.status:
            filename = self.status['filename']
        else:
            return
        try:
            fileutil.delete(filename)
        except OSError:
            logging.exception("Error deleting downloaded file: %s",
                              to_uni(filename))

        parent = os.path.join(fileutil.expand_filename(filename),
                              os.path.pardir)
        parent = os.path.normpath(parent)
        movies_dir = fileutil.expand_filename(
            app.config.get(prefs.MOVIES_DIRECTORY))
        if ((os.path.exists(parent) and os.path.exists(movies_dir)
             and not samefile(parent, movies_dir)
             and len(os.listdir(parent)) == 0)):
            try:
                os.rmdir(parent)
            except OSError:
                logging.exception(
                    "Error deleting empty download directory: %s",
                    to_uni(parent))
Example #2
0
 def remove_(index):
     size, file_type, id_ = sizes.pop(index)
     del self.device.database[file_type][id_]
     fileutil.delete(os.path.join(self.device.mount,
                                  utf8_to_filename(
                 id_.encode('utf8'))))
     self.device.remaining += size
     return keys.pop(index)
Example #3
0
 def _move_finished_file(self, source, destination):
     try:
         shutil.move(source, destination)
     except OSError, e:
         if fileutil.is_windows_file_in_use_error(e):
             # File is in use on windows (#15312) try to copy the
             # file, then use fileutil.delete.
             shutil.copy(source, destination)
             fileutil.delete(source)
         else:
             raise
Example #4
0
 def _move_finished_file(self, source, destination):
     try:
         shutil.move(source, destination)
     except OSError, e:
         if fileutil.is_windows_file_in_use_error(e):
             # File is in use on windows (#15312) try to copy the
             # file, then use fileutil.delete.
             shutil.copy(source, destination)
             fileutil.delete(source)
         else:
             raise
Example #5
0
    def delete(self):
        if self.filename is None:
            return
        try:
            fileutil.delete(self.filename)
        except OSError:
            logging.exception("Error deleting downloaded file: %s",
                              to_uni(self.filename))

        parent = os.path.join(fileutil.expand_filename(self.filename),
                              os.path.pardir)
        parent = os.path.normpath(parent)
        movies_dir = fileutil.expand_filename(app.config.get(prefs.MOVIES_DIRECTORY))
        if ((os.path.exists(parent) and os.path.exists(movies_dir)
             and not samefile(parent, movies_dir)
             and len(os.listdir(parent)) == 0)):
            try:
                os.rmdir(parent)
            except OSError:
                logging.exception("Error deleting empty download directory: %s",
                                  to_uni(parent))
        self.filename = None
Example #6
0
 def expire_items(self, item_infos):
     for info in item_infos:
         del self.device.database[info.file_type][info.id]
         fileutil.delete(info.video_path)
         self.device.remaining += info.size
     self._check_finished()