def get_quota(self): """ If quota active, return check-function, hour, minute """ if self.have_quota: self.q_period = cfg.quota_period()[0].lower() self.q_day = 1 self.q_hour = self.q_minute = 0 txt = cfg.quota_day().lower() m = self.__re_day.search(txt) if m: self.q_day = int(m.group(1)) m = self.__re_hm.search(txt) if m: self.q_hour = int(m.group(1)) self.q_minute = int(m.group(2)) if self.q_period == 'w': self.q_day = max(1, self.q_day) self.q_day = min(7, self.q_day) elif self.q_period == 'm': self.q_day = max(1, self.q_day) self.q_day = min(31, self.q_day) else: self.q_day = 1 self.change_quota(allow_resume=False) return quota_handler, self.q_hour, self.q_minute else: return None, 0, 0
def change_quota(self, allow_resume=True): """ Update quota, potentially pausing downloader """ if not self.have_quota and self.quota < 0.5: # Never set, use last period's size per = cfg.quota_period() sums = self.get_sums() if per == 'd': self.left = sums[3] elif per == 'w': self.left = sums[2] elif per == 'm': self.left = sums[1] self.have_quota = bool(cfg.quota_size()) if self.have_quota: quota = cfg.quota_size.get_float() if self.quota: # Quota change, recalculate amount left self.left = quota - (self.quota - self.left) else: # If previously no quota, self.left holds this period's usage self.left = quota - self.left self.quota = quota else: self.quota = self.left = 0L self.update(0) self.next_reset() if self.left > 0.5 and allow_resume: self.resume()
def get_quota(self): """ If quota active, return check-function, hour, minute """ if self.have_quota: self.q_period = cfg.quota_period()[0].lower() self.q_day = 1 self.q_hour = self.q_minute = 0 txt = cfg.quota_day().lower() m = self.__re_day.search(txt) if m: self.q_day = int(m.group(1)) m = self.__re_hm.search(txt) if m: self.q_hour = int(m.group(1)) self.q_minute = int(m.group(2)) if self.q_period == "w": self.q_day = max(1, self.q_day) self.q_day = min(7, self.q_day) elif self.q_period == "m": self.q_day = max(1, self.q_day) self.q_day = min(31, self.q_day) else: self.q_day = 1 self.change_quota(allow_resume=False) return quota_handler, self.q_hour, self.q_minute else: return None, 0, 0
def change_quota(self, allow_resume=True): """ Update quota, potentially pausing downloader """ if not self.have_quota and self.quota < 0.5: # Never set, use last period's size per = cfg.quota_period() sums = self.get_sums() if per == "d": self.left = sums[3] elif per == "w": self.left = sums[2] elif per == "m": self.left = sums[1] self.have_quota = bool(cfg.quota_size()) if self.have_quota: quota = cfg.quota_size.get_float() if self.quota: # Quota change, recalculate amount left self.left = quota - (self.quota - self.left) else: # If previously no quota, self.left holds this period's usage self.left = quota - self.left self.quota = quota else: self.quota = self.left = 0 self.update(0) self.next_reset() if self.left > 0.5 and allow_resume: self.resume()
def change_quota(self, allow_resume=True): """ Update quota, potentially pausing downloader """ if not self.have_quota and self.quota < 0.5: # Never set, use last period's size per = cfg.quota_period() sums = self.get_sums() if per == 'd': self.left = sums[3] elif per == 'w': self.left = sums[2] elif per == 'm': self.left = sums[1] self.have_quota = bool(cfg.quota_size()) if self.have_quota: quota = cfg.quota_size.get_float() self.left = quota - (self.quota - self.left) self.quota = quota else: self.quota = self.left = 0L self.update(0) self.next_reset() if self.left > 0.5: from sabnzbd.downloader import Downloader if allow_resume and cfg.quota_resume() and Downloader.do and Downloader.do.paused: Downloader.do.resume()
def get_quota(self): """ If quota active, return check-function, hour, minute """ if self.have_quota: self.q_period = cfg.quota_period()[0].lower() self.q_day = 1 self.q_hour = self.q_minute = 0 # Pattern = <day#> <hh:mm> # The <day> and <hh:mm> part can both be optional txt = cfg.quota_day().lower() m = RE_DAY.search(txt) if m: self.q_day = int(m.group(1)) m = RE_HHMM.search(txt) if m: self.q_hour = int(m.group(1)) self.q_minute = int(m.group(2)) if self.q_period == "w": self.q_day = max(1, self.q_day) self.q_day = min(7, self.q_day) elif self.q_period == "m": self.q_day = max(1, self.q_day) self.q_day = min(31, self.q_day) else: self.q_day = 1 self.change_quota(allow_resume=False) return quota_handler, self.q_hour, self.q_minute else: return None, 0, 0