def selectAccount(self): """ returns an valid account name and data""" usable = [] for user, data in self.accounts.iteritems(): if not data['valid']: continue if "time" in data['options'] and data['options']['time']: time_data = "" try: time_data = data['options']['time'][0] start, end = time_data.split("-") if not compare_time(start.split(":"), end.split(":")): continue except Exception: self.logWarning( _("Your Time %s has wrong format, use: 1:22-3:44") % time_data) if user in self.infos: if "validuntil" in self.infos[user]: if self.infos[user]['validuntil'] > 0 and time( ) > self.infos[user]['validuntil']: continue if "trafficleft" in self.infos[user]: if self.infos[user]['trafficleft'] == 0: continue usable.append((user, data)) if not usable: return None, None return choice(usable)
def selectAccount(self): """ returns an valid account name and data""" usable = [] for user, data in self.accounts.iteritems(): if not data['valid']: continue if "time" in data['options'] and data['options']['time']: time_data = "" try: time_data = data['options']['time'][0] start, end = time_data.split("-") if not compare_time(start.split(":"), end.split(":")): continue except Exception: self.logWarning(_("Your Time %s has wrong format, use: 1:22-3:44") % time_data) if user in self.infos: if "validuntil" in self.infos[user]: if self.infos[user]['validuntil'] > 0 and time() > self.infos[user]['validuntil']: continue if "trafficleft" in self.infos[user]: if self.infos[user]['trafficleft'] == 0: continue usable.append((user, data)) if not usable: return None, None return choice(usable)
def isTimeReconnect(self): """Checks if pyload will try to make a reconnect :return: bool """ start = self.core.config.get("reconnect", "startTime").split(":") end = self.core.config.get("reconnect", "endTime").split(":") return compare_time(start, end) and self.core.config.get("reconnect", "activated")
def isTimeDownload(self): """Checks if pyload will start new downloads according to time in config. :return: bool """ start = self.core.config.get("downloadTime", "start").split(":") end = self.core.config.get("downloadTime", "end").split(":") return compare_time(start, end)
def isTimeReconnect(self): """Checks if pyload will try to make a reconnect :return: bool """ start = self.core.config['reconnect']['startTime'].split(":") end = self.core.config['reconnect']['endTime'].split(":") return compare_time(start, end) and self.core.config["reconnect"]["activated"]
def isTimeDownload(self): """Checks if pyload will start new downloads according to time in config. :return: bool """ start = self.core.config['downloadTime']['start'].split(":") end = self.core.config['downloadTime']['end'].split(":") return compare_time(start, end)
def isUsable(self): """Check several constraints to determine if account should be used""" if not self.valid or not self.activated: return False if self.options["time"]: time_data = "" try: time_data = self.options["time"] start, end = time_data.split("-") if not compare_time(start.split(":"), end.split(":")): return False except: self.logWarning(_("Your Time %s has a wrong format, use: 1:22-3:44") % time_data) if 0 <= self.validuntil < time(): return False if self.trafficleft is 0: # test explicitly for 0 return False return True
def isUsable(self): """Check several constraints to determine if account should be used""" if not self.valid or not self.activated: return False if self.options["time"]: time_data = "" try: time_data = self.options["time"] start, end = time_data.split("-") if not compare_time(start.split(":"), end.split(":")): return False except: self.logWarning( _("Your Time %s has a wrong format, use: 1:22-3:44") % time_data) if 0 <= self.validuntil < time(): return False if self.trafficleft is 0: # test explicitly for 0 return False return True