Beispiel #1
0
    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
Beispiel #2
0
    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
Beispiel #3
0
    def run(self, iterations=1, dryRun=False):
        fileGen = self.getUnstreamableFiles()
        for i in xrange(iterations):
            try:
                fileList = fileGen.next()
            except StopIteration:
                break

            for file in fileList:
                if file['ismovie']:
                    errors = reencodeFilesInDirectory(file['filename'], dryRun=dryRun)
                    if errors:
                        log.error("Something bad happened. Attempting to continue")
                        for error in errors:
                            log.error(errors)
                    else:
                        if not dryRun:
                            self.putData(file['pk'], file['filename'])
                else:
                    # Running update on a tv show
                    fullPath = os.path.join(file['localpath'], file['filename'])
                    try:
                        fullPath = makeFileStreamable(fullPath,
                                                      appendSuffix=True,
                                                      removeOriginal=True,
                                                      dryRun=dryRun)
                    except Exception, e:
                        print e
                        log.error(e)
                        log.error("Something bad happened. Attempting to continue")

                    if os.path.exists(fullPath) and not dryRun:
                        #TODO: Make call to update filename
                        newFilename = os.path.basename(fullPath)
                        if newFilename != file['filename']:
                            self.putData(file['pk'], os.path.basename(fullPath))