def delete_files(processPath, notwantedFiles, result, force=False):
 if ((not result.result) and force):
  result.output += logHelper(u'Forcing deletion of files, even though last result was not success', sickrage.srCore.srLogger.DEBUG)
 elif (not result.result):
  return
 for cur_file in notwantedFiles:
  cur_file_path = os.path.join(processPath, cur_file)
  if (not os.path.isfile(cur_file_path)):
   continue
  result.output += logHelper((u'Deleting file %s' % cur_file), sickrage.srCore.srLogger.DEBUG)
  file_attribute = os.stat(cur_file_path)[0]
  if (not (file_attribute & stat.S_IWRITE)):
   result.output += logHelper((u'Changing ReadOnly Flag for file %s' % cur_file), sickrage.srCore.srLogger.DEBUG)
   try:
    os.chmod(cur_file_path, stat.S_IWRITE)
   except OSError as e:
    result.output += logHelper((u'Cannot change permissions of %s: %s' % (cur_file, str(e.strerror).decode(sickrage.SYS_ENCODING))), sickrage.srCore.srLogger.DEBUG)
  try:
   os.remove(cur_file_path)
  except OSError as e:
   result.output += logHelper((u'Unable to delete file %s: %s' % (cur_file, str(e.strerror).decode(sickrage.SYS_ENCODING))), sickrage.srCore.srLogger.DEBUG)

def delete_files ( processPath , notwantedFiles , result , force = False ) : if ( ( not result . result ) and force ) : result . output += logHelper ( u'Forcing deletion of files, even though last result was not success' , sickrage . srCore . srLogger . DEBUG ) elif ( not result . result ) : return for cur_file in notwantedFiles : cur_file_path = os . path . join ( processPath , cur_file ) if ( not os . path . isfile ( cur_file_path ) ) : continue result . output += logHelper ( ( u'Deleting file %s' % cur_file ) , sickrage . srCore . srLogger . DEBUG ) file_attribute = os . stat ( cur_file_path ) [ 0 ] if ( not ( file_attribute & stat . S_IWRITE ) ) : result . output += logHelper ( ( u'Changing ReadOnly Flag for file %s' % cur_file ) , sickrage . srCore . srLogger . DEBUG ) try : os . chmod ( cur_file_path , stat . S_IWRITE ) except OSError as e : result . output += logHelper ( ( u'Cannot change permissions of %s: %s' % ( cur_file , str ( e . strerror ) . decode ( sickrage . SYS_ENCODING ) ) ) , sickrage . srCore . srLogger . DEBUG ) try : os . remove ( cur_file_path ) except OSError as e : result . output += logHelper ( ( u'Unable to delete file %s: %s' % ( cur_file , str ( e . strerror ) . decode ( sickrage . SYS_ENCODING ) ) ) , sickrage . srCore . srLogger . DEBUG )
filelist - 待删除的文件/目录列表 .