def updateFileRecords(self, path, localFileSet, remoteFileSet): pathid = None for localFile in localFileSet: if localFile not in remoteFileSet: try: if not pathid: pathid = self.getOrCreateRemotePath(path) log.debug("Attempting to add %s" % (localFile, )) fullPath = stripUnicode(localFile, path=path) try: fullPath = makeFileStreamable(fullPath, appendSuffix=True, removeOriginal=True, dryRun=False) except Exception, e: log.error(e) log.error( "Something bad happened. Attempting to continue") if os.path.exists(fullPath): newFile = File( os.path.basename(fullPath), pathid, os.path.getsize(fullPath), True, ) newFile.post() except Exception, e: log.error(e) continue
def updateFileRecords(self, path, localFileSet, remoteFileSet): pathid = None for localFile in localFileSet: if localFile not in remoteFileSet: try: if not pathid: pathid = self.getOrCreateRemotePath(path) log.debug("Attempting to add %s" % (localFile,)) fullPath = stripUnicode(localFile, path=path) try: fullPath = makeFileStreamable(fullPath, appendSuffix=True, removeOriginal=True, dryRun=False) except Exception, e: log.error(e) log.error("Something bad happened. Attempting to continue") if os.path.exists(fullPath): newFile = File(os.path.basename(fullPath), pathid, os.path.getsize(fullPath), True, ) newFile.post() except Exception, e: log.error(e) continue
def reencodeFilesInDirectory(dir, dryRun=False): errors = list() fullPath = os.path.join(LOCAL_MOVIE_PATH, dir) res = commands.getoutput("find '%s' -maxdepth 10 -not -type d" % fullPath) tokens = res.split('\n') for token in tokens: ext = os.path.splitext(token)[-1].lower() if ext in MEDIA_FILE_EXTENSIONS: try: cleanPath = stripUnicode(token) makeFileStreamable(cleanPath, appendSuffix=True, removeOriginal=True, dryRun=dryRun) except Exception, e: print e errors.append(e)