本文整理汇总了Python中sickbeard.helpers.delete_empty_folders函数的典型用法代码示例。如果您正苦于以下问题:Python delete_empty_folders函数的具体用法?Python delete_empty_folders怎么用?Python delete_empty_folders使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_empty_folders函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _delete
def _delete(self, file_path, associated_files=False):
"""
Deletes the file and optionally all associated files.
file_path: The file to delete
associated_files: True to delete all files which differ only by extension, False to leave them
"""
if not file_path:
return
# figure out which files we want to delete
file_list = [file_path]
if associated_files:
file_list = file_list + self._list_associated_files(file_path)
if not file_list:
self._log(u"There were no files associated with " + file_path + ", not deleting anything", logger.DEBUG)
return
# delete the file and any other files which we want to delete
for cur_file in file_list:
self._log(u"Deleting file "+cur_file, logger.DEBUG)
if ek.ek(os.path.isfile, cur_file):
ek.ek(os.remove, cur_file)
# do the library update for synoindex
notifiers.synoindex_notifier.deleteFile(cur_file)
# clean up any left over folders
helpers.delete_empty_folders(ek.ek(os.path.dirname, file_path))
开发者ID:tsubus,项目名称:Sick-Beard-backup,代码行数:31,代码来源:postProcessor.py
示例2: process
def process(self):
"""
Post-process a given file
"""
self._log(u"Processing " + self.file_path + " (" + str(self.nzb_name) + ")")
if os.path.isdir(self.file_path):
self._log(u"File " + self.file_path + " seems to be a directory")
return False
for ignore_file in self.IGNORED_FILESTRINGS:
if ignore_file in self.file_path:
self._log(u"File " + self.file_path + " is ignored type, skipping")
return False
# reset per-file stuff
self.in_history = False
# try to find the file info
(tvdb_id, season, episodes) = self._find_info()
# if we don't have it then give up
if not tvdb_id or season == None or not episodes:
return False
# retrieve/create the corresponding TVEpisode objects
ep_obj = self._get_ep_obj(tvdb_id, season, episodes)
# get the quality of the episode we're processing
new_ep_quality = self._get_quality(ep_obj)
logger.log(u"Quality of the episode we're processing: " + str(new_ep_quality), logger.DEBUG)
# see if this is a priority download (is it snatched, in history, or PROPER)
priority_download = self._is_priority(ep_obj, new_ep_quality)
self._log(u"Is ep a priority download: " + str(priority_download), logger.DEBUG)
# set the status of the episodes
for curEp in [ep_obj] + ep_obj.relatedEps:
curEp.status = common.Quality.compositeStatus(common.SNATCHED, new_ep_quality)
# check for an existing file
existing_file_status = self._checkForExistingFile(ep_obj.location)
# if it's not priority then we don't want to replace smaller files in case it was a mistake
if not priority_download:
# if there's an existing file that we don't want to replace stop here
if existing_file_status in (PostProcessor.EXISTS_LARGER, PostProcessor.EXISTS_SAME):
self._log(u"File exists and we are not going to replace it because it's not smaller, quitting post-processing", logger.DEBUG)
return False
elif existing_file_status == PostProcessor.EXISTS_SMALLER:
self._log(u"File exists and is smaller than the new file so I'm going to replace it", logger.DEBUG)
elif existing_file_status != PostProcessor.DOESNT_EXIST:
self._log(u"Unknown existing file status. This should never happen, please log this as a bug.", logger.ERROR)
return False
# if the file is priority then we're going to replace it even if it exists
else:
self._log(u"This download is marked a priority download so I'm going to replace an existing file if I find one", logger.DEBUG)
# delete the existing file (and company)
for cur_ep in [ep_obj] + ep_obj.relatedEps:
try:
self._delete(cur_ep.location, associated_files=True)
# clean up any left over folders
if cur_ep.location:
helpers.delete_empty_folders(ek.ek(os.path.dirname, cur_ep.location), keep_dir=ep_obj.show._location)
except (OSError, IOError):
raise exceptions.PostProcessingFailed("Unable to delete the existing files")
# if the show directory doesn't exist then make it if allowed
if not ek.ek(os.path.isdir, ep_obj.show._location) and sickbeard.CREATE_MISSING_SHOW_DIRS:
self._log(u"Show directory doesn't exist, creating it", logger.DEBUG)
try:
ek.ek(os.mkdir, ep_obj.show._location)
# do the library update for synoindex
notifiers.synoindex_notifier.addFolder(ep_obj.show._location)
except (OSError, IOError):
raise exceptions.PostProcessingFailed("Unable to create the show directory: " + ep_obj.show._location)
# get metadata for the show (but not episode because it hasn't been fully processed)
ep_obj.show.writeMetadata(True)
# update the ep info before we rename so the quality & release name go into the name properly
for cur_ep in [ep_obj] + ep_obj.relatedEps:
with cur_ep.lock:
cur_release_name = None
# use the best possible representation of the release name
if self.good_results[self.NZB_NAME]:
cur_release_name = self.nzb_name
if cur_release_name.lower().endswith('.nzb'):
cur_release_name = cur_release_name.rpartition('.')[0]
elif self.good_results[self.FOLDER_NAME]:
cur_release_name = self.folder_name
elif self.good_results[self.FILE_NAME]:
cur_release_name = self.file_name
# take the extension off the filename, it's not needed
if '.' in self.file_name:
cur_release_name = self.file_name.rpartition('.')[0]
#.........这里部分代码省略.........
开发者ID:brinbois,项目名称:Sick-Beard,代码行数:101,代码来源:postProcessor.py
示例3: process
def process(self):
"""
Post-process a given file
"""
self._log(u"Processing " + self.file_path + " (" + str(self.nzb_name) + ")")
if ek.ek(os.path.isdir, self.file_path):
self._log(u"File " + self.file_path + " seems to be a directory")
return False
for ignore_file in self.IGNORED_FILESTRINGS:
if ignore_file in self.file_path:
self._log(u"File " + self.file_path + " is ignored type, skipping")
return False
# reset per-file stuff
self.in_history = False
# try to find the file info
(indexer_id, season, episodes) = self._find_info()
if not (indexer_id and season and len(episodes)):
self._log(u"Can't find the show on any of the Indexers, skipping",
logger.WARNING)
return False
# retrieve/create the corresponding TVEpisode objects
ep_obj = self._get_ep_obj(indexer_id, season, episodes)
# get the quality of the episode we're processing
new_ep_quality = self._get_quality(ep_obj)
logger.log(u"Quality of the episode we're processing: " + str(new_ep_quality), logger.DEBUG)
# see if this is a priority download (is it snatched, in history, PROPER, or BEST)
priority_download = self._is_priority(ep_obj, new_ep_quality)
self._log(u"Is ep a priority download: " + str(priority_download), logger.DEBUG)
# set the status of the episodes
for curEp in [ep_obj] + ep_obj.relatedEps:
curEp.status = common.Quality.compositeStatus(common.SNATCHED, new_ep_quality)
# check for an existing file
existing_file_status = self._checkForExistingFile(ep_obj.location)
# if it's not priority then we don't want to replace smaller files in case it was a mistake
if not priority_download:
# if there's an existing file that we don't want to replace stop here
if existing_file_status in (PostProcessor.EXISTS_LARGER, PostProcessor.EXISTS_SAME):
self._log(
u"File exists and we are not going to replace it because it's not smaller, quitting post-processing",
logger.ERROR)
return False
elif existing_file_status == PostProcessor.EXISTS_SMALLER:
self._log(u"File exists and is smaller than the new file so I'm going to replace it", logger.DEBUG)
elif existing_file_status != PostProcessor.DOESNT_EXIST:
self._log(u"Unknown existing file status. This should never happen, please log this as a bug.",
logger.ERROR)
return False
# if the file is priority then we're going to replace it even if it exists
else:
self._log(
u"This download is marked a priority download so I'm going to replace an existing file if I find one",
logger.DEBUG)
# delete the existing file (and company)
for cur_ep in [ep_obj] + ep_obj.relatedEps:
try:
self._delete(cur_ep.location, associated_files=True)
# clean up any left over folders
if cur_ep.location:
helpers.delete_empty_folders(ek.ek(os.path.dirname, cur_ep.location),
keep_dir=ep_obj.show._location)
except (OSError, IOError):
raise exceptions.PostProcessingFailed("Unable to delete the existing files")
# if the show directory doesn't exist then make it if allowed
if not ek.ek(os.path.isdir, ep_obj.show._location) and sickbeard.CREATE_MISSING_SHOW_DIRS:
self._log(u"Show directory doesn't exist, creating it", logger.DEBUG)
try:
ek.ek(os.mkdir, ep_obj.show._location)
# do the library update for synoindex
notifiers.synoindex_notifier.addFolder(ep_obj.show._location)
except (OSError, IOError):
raise exceptions.PostProcessingFailed("Unable to create the show directory: " + ep_obj.show._location)
# get metadata for the show (but not episode because it hasn't been fully processed)
ep_obj.show.writeMetadata(True)
# update the ep info before we rename so the quality & release name go into the name properly
for cur_ep in [ep_obj] + ep_obj.relatedEps:
with cur_ep.lock:
cur_release_name = None
# use the best possible representation of the release name
if self.good_results[self.NZB_NAME]:
cur_release_name = self.nzb_name
if cur_release_name.lower().endswith('.nzb'):
cur_release_name = cur_release_name.rpartition('.')[0]
elif self.good_results[self.FOLDER_NAME]:
#.........这里部分代码省略.........
开发者ID:WoLpH,项目名称:SickBeard-TVRage,代码行数:101,代码来源:postProcessor.py
示例4: process
def process(self):
"""
Post-process a given file
"""
self._log(u"Processing " + self.file_path + " (" + str(self.nzb_name) + ")")
if os.path.isdir(self.file_path):
self._log(u"File " + self.file_path + " seems to be a directory")
return False
for ignore_file in self.IGNORED_FILESTRINGS:
if ignore_file in self.file_path:
self._log(u"File " + self.file_path + " is ignored type, skipping")
return False
# reset per-file stuff
self.in_history = False
# try to find the file info
(tvdb_id, season, episodes) = self._find_info()
# if we don't have it then give up
if not tvdb_id or season == None or not episodes:
return False
# retrieve/create the corresponding TVEpisode objects
ep_obj = self._get_ep_obj(tvdb_id, season, episodes)
# get the quality of the episode we're processing
new_ep_quality = self._get_quality(ep_obj)
logger.log(u"Quality of the episode we're processing: " + str(new_ep_quality), logger.DEBUG)
# see if this is a priority download (is it snatched, in history, or PROPER)
priority_download = self._is_priority(ep_obj, new_ep_quality)
self._log(u"Is ep a priority download: " + str(priority_download), logger.DEBUG)
# set the status of the episodes
for curEp in [ep_obj] + ep_obj.relatedEps:
curEp.status = common.Quality.compositeStatus(common.SNATCHED, new_ep_quality)
# check for an existing file
existing_file_status = self._checkForExistingFile(ep_obj.location)
# if it's not priority then we don't want to replace smaller files in case it was a mistake
if not priority_download:
# if there's an existing file that we don't want to replace stop here
if existing_file_status in (PostProcessor.EXISTS_LARGER, PostProcessor.EXISTS_SAME):
self._log(u"File exists and we are not going to replace it because it's not smaller, quitting post-processing", logger.DEBUG)
return False
elif existing_file_status == PostProcessor.EXISTS_SMALLER:
self._log(u"File exists and is smaller than the new file so I'm going to replace it", logger.DEBUG)
elif existing_file_status != PostProcessor.DOESNT_EXIST:
self._log(u"Unknown existing file status. This should never happen, please log this as a bug.", logger.ERROR)
return False
# if the file is priority then we're going to replace it even if it exists
else:
self._log(u"This download is marked a priority download so I'm going to replace an existing file if I find one", logger.DEBUG)
# delete the existing file (and company)
for cur_ep in [ep_obj] + ep_obj.relatedEps:
try:
self._delete(cur_ep.location, associated_files=True)
# clean up any left over folders
if cur_ep.location:
helpers.delete_empty_folders(ek.ek(os.path.dirname, cur_ep.location), keep_dir=ep_obj.show._location)
except (OSError, IOError):
raise exceptions.PostProcessingFailed("Unable to delete the existing files")
# if the show directory doesn't exist then make it if allowed
if not ek.ek(os.path.isdir, ep_obj.show._location) and sickbeard.CREATE_MISSING_SHOW_DIRS:
self._log(u"Show directory doesn't exist, creating it", logger.DEBUG)
try:
ek.ek(os.mkdir, ep_obj.show._location)
except (OSError, IOError):
raise exceptions.PostProcessingFailed("Unable to create the show directory: " + ep_obj.show._location)
# get metadata for the show (but not episode because it hasn't been fully processed)
ep_obj.show.writeMetadata(True)
# update the ep info before we rename so the quality & release name go into the name properly
for cur_ep in [ep_obj] + ep_obj.relatedEps:
with cur_ep.lock:
cur_release_name = None
# use the best possible representation of the release name
if self.good_results[self.NZB_NAME]:
cur_release_name = self.nzb_name
if cur_release_name.lower().endswith('.nzb'):
cur_release_name = cur_release_name.rpartition('.')[0]
elif self.good_results[self.FOLDER_NAME]:
cur_release_name = self.folder_name
elif self.good_results[self.FILE_NAME]:
cur_release_name = self.file_name
# take the extension off the filename, it's not needed
if '.' in self.file_name:
cur_release_name = self.file_name.rpartition('.')[0]
if cur_release_name:
#.........这里部分代码省略.........
开发者ID:Malleho,项目名称:sickbeard,代码行数:101,代码来源:postProcessor.py
示例5: process
def process(self):
"""
Post-process a given file
"""
self._log(u"Processing " + self.file_path + " (" + str(self.nzb_name) + ")")
if ek.ek(os.path.isdir, self.file_path):
self._log(u"File " + self.file_path + " seems to be a directory")
return False
for ignore_file in self.IGNORED_FILESTRINGS:
if ignore_file in self.file_path:
self._log(u"File " + self.file_path + " is ignored type, skipping")
return False
# reset per-file stuff
self.in_history = False
# reset the anidb episode object
self.anidbEpisode = None
# try to find the file info
(show, season, episodes, quality, version) = self._find_info()
if not show:
self._log(u"This show isn't in your list, you need to add it to SB before post-processing an episode",
logger.WARNING)
raise exceptions.PostProcessingFailed()
elif season == None or not episodes:
self._log(u"Not enough information to determine what episode this is", logger.DEBUG)
self._log(u"Quitting post-processing", logger.DEBUG)
return False
# retrieve/create the corresponding TVEpisode objects
ep_obj = self._get_ep_obj(show, season, episodes)
# get the quality of the episode we're processing
if quality:
self._log(u"Snatch history had a quality in it, using that: " + common.Quality.qualityStrings[quality],
logger.DEBUG)
new_ep_quality = quality
else:
new_ep_quality = self._get_quality(ep_obj)
logger.log(u"Quality of the episode we're processing: " + str(new_ep_quality), logger.DEBUG)
# see if this is a priority download (is it snatched, in history, PROPER, or BEST)
priority_download = self._is_priority(ep_obj, new_ep_quality)
self._log(u"Is ep a priority download: " + str(priority_download), logger.DEBUG)
# get the version of the episode we're processing
if version:
self._log(u"Snatch history had a version in it, using that: v" + str(version),
logger.DEBUG)
new_ep_version = version
else:
new_ep_version = -1
# check for an existing file
existing_file_status = self._checkForExistingFile(ep_obj.location)
# if it's not priority then we don't want to replace smaller files in case it was a mistake
if not priority_download:
# if there's an existing file that we don't want to replace stop here
if existing_file_status == PostProcessor.EXISTS_LARGER:
if self.is_proper:
self._log(
u"File exists and new file is smaller, new file is a proper/repack, marking it safe to replace",
logger.DEBUG)
return True
else:
self._log(u"File exists and new file is smaller, marking it unsafe to replace", logger.DEBUG)
return False
elif existing_file_status == PostProcessor.EXISTS_SAME:
self._log(u"File exists and new file is same size, marking it unsafe to replace", logger.DEBUG)
return False
# if the file is priority then we're going to replace it even if it exists
else:
self._log(
u"This download is marked a priority download so I'm going to replace an existing file if I find one",
logger.DEBUG)
# delete the existing file (and company)
for cur_ep in [ep_obj] + ep_obj.relatedEps:
try:
self._delete(cur_ep.location, associated_files=True)
# clean up any left over folders
if cur_ep.location:
helpers.delete_empty_folders(ek.ek(os.path.dirname, cur_ep.location),
keep_dir=ep_obj.show._location)
except (OSError, IOError):
raise exceptions.PostProcessingFailed("Unable to delete the existing files")
# set the status of the episodes
# for curEp in [ep_obj] + ep_obj.relatedEps:
#.........这里部分代码省略.........
开发者ID:Hellowlol,项目名称:SickRage,代码行数:101,代码来源:postProcessor.py
示例6: process
def process(self):
"""
Post-process a given file
"""
self._log(u'Processing %s%s' % (self.file_path, (u'<br />.. from nzb %s' % str(self.nzb_name), u'')[None is self.nzb_name]))
if ek.ek(os.path.isdir, self.file_path):
self._log(u'File %s<br />.. seems to be a directory' % self.file_path)
return False
for ignore_file in self.IGNORED_FILESTRINGS:
if ignore_file in self.file_path:
self._log(u'File %s<br />.. is ignored type, skipping' % self.file_path)
return False
# reset per-file stuff
self.in_history = False
self.anidbEpisode = None
# try to find the file info
(show, season, episodes, quality) = self._find_info()
# if we don't have it then give up
if not show:
self._log(u'Please add the show to your SickGear then try to post process an episode', logger.WARNING)
raise exceptions.PostProcessingFailed()
elif None is season or not episodes:
self._log(u'Quitting this post process, could not determine what episode this is', logger.DEBUG)
return False
# retrieve/create the corresponding TVEpisode objects
ep_obj = self._get_ep_obj(show, season, episodes)
# get the quality of the episode we're processing
if common.Quality.UNKNOWN == quality:
new_ep_quality = self._get_quality(ep_obj)
else:
new_ep_quality = quality
self._log(u'Using "%s" quality from the snatch history' % common.Quality.qualityStrings[new_ep_quality], logger.DEBUG)
# see if it's safe to replace existing episode (is download snatched, PROPER, better quality)
if not self._safe_replace(ep_obj, new_ep_quality):
# if it's not safe to replace, stop here
self._log(u'Quitting this post process', logger.DEBUG)
return False
# delete the existing file (and company)
for cur_ep in [ep_obj] + ep_obj.relatedEps:
try:
self._delete(cur_ep.location, associated_files=True)
# clean up any left over folders
if cur_ep.location:
helpers.delete_empty_folders(ek.ek(os.path.dirname, cur_ep.location),
keep_dir=ep_obj.show.location)
except (OSError, IOError):
raise exceptions.PostProcessingFailed(u'Unable to delete the existing files')
# set the status of the episodes
# for curEp in [ep_obj] + ep_obj.relatedEps:
# curEp.status = common.Quality.compositeStatus(common.SNATCHED, new_ep_quality)
# if the show directory doesn't exist then make it if allowed
if not ek.ek(os.path.isdir, ep_obj.show.location) and sickbeard.CREATE_MISSING_SHOW_DIRS:
self._log(u'Show directory does not exist, creating it', logger.DEBUG)
try:
ek.ek(os.mkdir, ep_obj.show.location)
# do the library update for synoindex
notifiers.synoindex_notifier.addFolder(ep_obj.show.location)
except (OSError, IOError):
raise exceptions.PostProcessingFailed(u'Unable to create show directory: ' + ep_obj.show.location)
# get metadata for the show (but not episode because it hasn't been fully processed)
ep_obj.show.writeMetadata(True)
# if we're processing an episode of type anime, get the anime version
anime_version = (-1, self.anime_version)[ep_obj.show.is_anime and None is not self.anime_version and self.anime_version]
# update the ep info before we rename so the quality & release name go into the name properly
sql_l = []
for cur_ep in [ep_obj] + ep_obj.relatedEps:
with cur_ep.lock:
if self.release_name:
self._log(u'Found release name ' + self.release_name, logger.DEBUG)
cur_ep.release_name = self.release_name or ''
cur_ep.status = common.Quality.compositeStatus(
**({'status': common.DOWNLOADED, 'quality': new_ep_quality},
{'status': common.ARCHIVED, 'quality': new_ep_quality})
[ep_obj.status in common.Quality.SNATCHED_BEST])
cur_ep.release_group = self.release_group or ''
cur_ep.is_proper = self.is_proper
cur_ep.version = anime_version
#.........这里部分代码省略.........
开发者ID:Koernia,项目名称:SickGear,代码行数:101,代码来源:postProcessor.py
示例7: process
def process(self):
"""
Post-process a given file or (if failed) dir/nzb
"""
self._log(u"Processing " + self.file_path + " (" + str(self.nzb_name) + ")")
if os.path.isdir(self.file_path) and not self.failed:
self._log(u"File " + self.file_path + " seems to be a directory")
return False
for ignore_file in self.IGNORED_FILESTRINGS:
if ignore_file in self.file_path:
self._log(u"File " + self.file_path + " is ignored type, skipping")
return False
# reset per-file stuff
self.in_history = False
# try to find the file info
(tvdb_id, season, episodes) = self._find_info()
# if we don't have it then give up
if not tvdb_id or season == None or not episodes:
return False
# retrieve/create the corresponding TVEpisode objects
ep_obj = self._get_ep_obj(tvdb_id, season, episodes)
if self.failed:
release_name = self._get_release_name()
if release_name is not None:
self._log(u"Marking release as bad: " + release_name, logger.DEBUG)
myDB = db.DBConnection("failed.db")
myDB.select("INSERT INTO failed (release) VALUES (?)", [re.sub("[\.\-\ ]", "_", release_name)])
else:
self._log(u"Release name not found. Can't mark as invalid. REPORT THIS", logger.ERROR)
return False
logger.log(u"Setting episode(s) back to Wanted", logger.DEBUG)
for curEp in [ep_obj] + ep_obj.relatedEps:
self._log(u"Setting episode back to wanted: " + curEp.name)
with curEp.lock:
curEp.status = int(common.WANTED)
curEp.saveToDB()
# we 'succeeded' in the sense that no errors were encountered
return True
# get the quality of the episode we're processing
new_ep_quality = self._get_quality(ep_obj)
logger.log(u"Quality of the episode we're processing: " + str(new_ep_quality), logger.DEBUG)
# see if this is a priority download (is it snatched, in history, or PROPER)
priority_download = self._is_priority(ep_obj, new_ep_quality)
self._log(u"Is ep a priority download: " + str(priority_download), logger.DEBUG)
# set the status of the episodes
for curEp in [ep_obj] + ep_obj.relatedEps:
curEp.status = common.Quality.compositeStatus(common.SNATCHED, new_ep_quality)
# check for an existing file
existing_file_status = self._checkForExistingFile(ep_obj.location)
# if it's not priority then we don't want to replace smaller files in case it was a mistake
if not priority_download:
# if there's an existing file that we don't want to replace stop here
if existing_file_status in (PostProcessor.EXISTS_LARGER, PostProcessor.EXISTS_SAME):
self._log(
u"File exists and we are not going to replace it because it's not smaller, quitting post-processing",
logger.DEBUG,
)
return False
elif existing_file_status == PostProcessor.EXISTS_SMALLER:
self._log(u"File exists and is smaller than the new file so I'm going to replace it", logger.DEBUG)
elif existing_file_status != PostProcessor.DOESNT_EXIST:
self._log(
u"Unknown existing file status. This should never happen, please log this as a bug.", logger.ERROR
)
return False
# if the file is priority then we're going to replace it even if it exists
else:
self._log(
u"This download is marked a priority download so I'm going to replace an existing file if I find one",
logger.DEBUG,
)
# delete the existing file (and company)
for cur_ep in [ep_obj] + ep_obj.relatedEps:
try:
self._delete(cur_ep.location, associated_files=True)
# clean up any left over folders
if cur_ep.location:
helpers.delete_empty_folders(
ek.ek(os.path.dirname, cur_ep.location), keep_dir=ep_obj.show._location
)
except (OSError, IOError):
raise exceptions.PostProcessingFailed("Unable to delete the existing files")
#.........这里部分代码省略.........
开发者ID:prometheus247,项目名称:Sick-Beard,代码行数:101,代码来源:postProcessor.py
示例8: file
self._log(u"File exists and is smaller than the new file so I'm going to replace it", logger.DEBUG)
elif existing_file_status != PostProcessor.DOESNT_EXIST:
self._log(u"Unknown existing file status. This should never happen, please log this as a bug.", logger.ERROR)
return False
# if the file is priority then we're going to replace it even if it exists
else:
self._log(u"This download is marked a priority download so I'm going to replace an existing file if I find one", logger.DEBUG)
# delete the existing file (and company)
for cur_ep in [ep_obj] + ep_obj.relatedEps:
try:
self._delete(cur_ep.location, associated_files=True)
# clean up any left over folders
if cur_ep.location:
helpers.delete_empty_folders(ek.ek(os.path.dirname, cur_ep.location), keep_dir=ep_obj.show._location)
except (OSError, IOError):
raise exceptions.PostProcessingFailed("Unable to delete the existing files")
# if the show directory doesn't exist then make it if allowed
if not ek.ek(os.path.isdir, ep_obj.show._location) and sickbeard.CREATE_MISSING_SHOW_DIRS:
self._log(u"Show directory doesn't exist, creating it", logger.DEBUG)
try:
ek.ek(os.mkdir, ep_obj.show._location)
except (OSError, IOError):
raise exceptions.PostProcessingFailed("Unable to create the show directory: " + ep_obj.show._location)
# get metadata for the show (but not episode because it hasn't been fully processed)
ep_obj.show.writeMetadata(True)
开发者ID:kaimyn,项目名称:Sick-Beard,代码行数:30,代码来源:postProcessor.py
注:本文中的sickbeard.helpers.delete_empty_folders函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论