예제 #1
0
    def assignJob(self):
        """assign a job to a thread if possible"""

        if self.pause or not self.core.api.isTimeDownload(): return

        #if self.downloaded > 20:
        #    if not self.cleanPyCurl(): return

        free = [x for x in self.threads if not x.active]

        inuse = [(x.active.pluginname, x.active.plugin.getDownloadLimit())
                 for x in self.threads if x.active and x.active.hasPlugin()]
        inuse = [(x[0], x[1],
                  len([
                      y for y in self.threads
                      if y.active and y.active.pluginname == x[0]
                  ])) for x in inuse]
        occ = tuple(sorted(uniqify([x[0] for x in inuse if 0 < x[1] <= x[2]])))

        job = self.core.files.getJob(occ)
        if job:
            try:
                job.initPlugin()
            except Exception, e:
                self.log.critical(str(e))
                print_exc()
                job.setStatus("failed")
                job.error = str(e)
                job.release()
                return

            spaceLeft = free_space(
                self.core.config["general"]["download_folder"]) / 1024 / 1024
            if spaceLeft < self.core.config["general"]["min_free_space"]:
                self.log.warning(_("Not enough space left on device"))
                self.pause = True

            if free and not self.pause:
                thread = free[0]
                #self.downloaded += 1
                thread.put(job)
            else:
                #put job back
                if occ not in self.core.files.jobCache:
                    self.core.files.jobCache[occ] = []
                self.core.files.jobCache[occ].append(job.id)
예제 #2
0
    def assignJob(self):
        """assign a job to a thread if possible"""

        if self.pause or not self.core.api.isTimeDownload(): return

        #if self.downloaded > 20:
        #    if not self.cleanPyCurl(): return

        free = [x for x in self.threads if not x.active]

        inuse = [(x.active.pluginname, x.active.plugin.getDownloadLimit()) for x in self.threads if x.active and x.active.hasPlugin()]
        inuse = [(x[0], x[1], len([y for y in self.threads if y.active and y.active.pluginname == x[0]])) for x in inuse]
        occ = tuple(sorted(uniqify([x[0] for x in inuse if 0 < x[1] <= x[2]])))
        
        job = self.core.files.getJob(occ)
        if job:
            try:
                job.initPlugin()
            except Exception, e:
                self.log.critical(str(e))
                print_exc()
                job.setStatus("failed")
                job.error = str(e)
                job.release()
                return

            spaceLeft = free_space(self.core.config["general"]["download_folder"]) / 1024 / 1024
            if spaceLeft < self.core.config["general"]["min_free_space"]:
                self.log.warning(_("Not enough space left on device"))
                self.pause = True

            if free and not self.pause:
                thread = free[0]
                #self.downloaded += 1
                thread.put(job)
            else:
                #put job back
                if occ not in self.core.files.jobCache:
                    self.core.files.jobCache[occ] = []
                self.core.files.jobCache[occ].append(job.id)
예제 #3
0
파일: CoreApi.py 프로젝트: beefone/pyload
 def freeSpace(self):
     """Available free space at download directory in bytes"""
     return free_space(self.core.config["general"]["download_folder"])
예제 #4
0
 def freeSpace(self):
     """Available free space at download directory in bytes"""
     return free_space(self.core.config["general"]["download_folder"])