def __init__(self, parent, ip_renewer): """""" self.ip_renewer = ip_renewer self.weak_parent = weakref.ref(parent) self.id_item_list = [] self.is_working = True if self.can_change_ip(): self.id_item_list = [ download_item.id for download_item in api.get_active_downloads().values() + api.get_queue_downloads().values() ] signals.on_stop_all.emit() if conf.get_addon_option(OPTION_RENEW_SCRIPT_ACTIVE, default=False, is_bool=True): self.ip_renewer.start_shell_script() else: self.ip_renewer.start_default_ip_renew() self.status_msg = _("Changing IP...") signals.status_bar_push_msg.emit(self.status_msg) self.timer = self.parent.idle_timeout(1000, self.update) else: self.is_working = False
def can_change_ip(self): """""" for download_item in api.get_active_downloads().itervalues(): #p = plugins_parser.get_plugin_item(download_item.host) if (not download_item.can_resume and download_item.time): # or (p.get_captcha_required() and not download_item.is_premium and download_item.time): return False return True
def __init__(self, parent, ip_renewer_cls): """""" self.id_list = [] self.stop_all = parent.downloads_list_gui.on_stop_all if self.can_change_ip(): self.pending_events() self.id_list = [ download_item.id for download_item in api.get_active_downloads().values() + api.get_queue_downloads().values() ] self.pending_events() self.stop_all() self.pending_events() self.change_ip_th = ip_renewer_cls if conf.get_addon_option(OPTION_RENEW_SCRIPT_ACTIVE, default=False, is_bool=True): self.change_ip_th.start( conf.get_addon_option(OPTION_IP_RENEW_SCRIPT_PATH, default="")) else: self.change_ip_th.start() gobject.timeout_add(1000, self.update_status, parent) self.msg_id = parent.status_bar.push_msg(_("Changing IP..."))
def update_(self): active_downloads = api.get_active_downloads() api.update_active_downloads() for download_item in active_downloads.itervalues(): row = self.rows_buffer[download_item.id] #row[0] = download_item.id row[1] = self.icons_dict[download_item.status] row[2] = download_item.name #row[3][0] = download_item.host row[3][1] = self.icons_dict[ cons.DL_RESUME] if download_item.can_resume else None row[3][2] = self.icons_dict[ cons.DL_PREMIUM] if download_item.is_premium else None row[4] = utils.size_format( download_item.size) if download_item.size else None row[5] = utils.size_format( download_item.size_complete ) if download_item.size_complete else None row[6] = download_item.progress row[7] = utils.time_format( download_item.time) if download_item.time else None row[8] = utils.time_format(download_item.time_remain ) if download_item.time_remain else None row[9] = utils.speed_format( download_item.speed) if download_item.speed else None row[10] = self.get_status_msg(download_item) self.__model.refresh()
def __init__(self, parent, ip_renewer_cls): """""" self.change_ip_th = ip_renewer_cls self.parent = parent self.id_list = [] self.stop_all = self.parent.downloads.on_stop_all if self.can_change_ip(): self.id_list = [ download_item.id for download_item in api.get_active_downloads().values() + api.get_queue_downloads().values() ] self.stop_all() if conf.get_addon_option(OPTION_RENEW_SCRIPT_ACTIVE, default=False, is_bool=True): self.change_ip_th.start( conf.get_addon_option(OPTION_IP_RENEW_SCRIPT_PATH, default="")) else: self.change_ip_th.start() self.status_msg = _("Changing IP...") self.parent.status_bar.push_msg(self.status_msg) self.timer = self.parent.idle_timeout(1000, self.update)
def has_segments_left(self, name): """""" for download_item in api.get_active_downloads().values() + api.get_queue_downloads().values() + api.get_stopped_downloads().values(): m = re.match(unrar.RAR_FILE_PATTERN, download_item.name) if m is not None: if name == m.group('name'): return True return False
def can_change_ip(self): """""" for download_item in api.get_active_downloads().itervalues(): #p = plugins_parser.get_plugin_item(download_item.host) if ( not download_item.can_resume and download_item.time ): # or (p.get_captcha_required() and not download_item.is_premium and download_item.time): return False return True
def has_segments_left(self, name, pattern): """""" NAME, PART, EXT = range(3) for download_item in api.get_active_downloads().values() + api.get_queue_downloads().values() + api.get_stopped_downloads().values(): match_name = re.match(pattern, download_item.name) if match_name is not None: if name == match_name.groups()[NAME]: return True return False
def has_segments_left(self, name): """""" for download_item in api.get_active_downloads().values( ) + api.get_queue_downloads().values() + api.get_stopped_downloads( ).values(): m = re.match(unrar.RAR_FILE_PATTERN, download_item.name) if m is not None: if name == m.group('name'): return True return False
def has_segments_left(self, name, pattern): """""" NAME, PART, EXT = range(3) for download_item in api.get_active_downloads().values( ) + api.get_queue_downloads().values() + api.get_stopped_downloads( ).values(): match_name = re.match(pattern, download_item.name) if match_name is not None: if name == match_name.groups()[NAME]: return True return False
def on_quit(self, widget=None, other=None): """""" if api.get_active_downloads(): message = _("ochDownload still has some active downloads. Do you want to quit anyway?") m = DlgGui(self, gtk.STOCK_DIALOG_WARNING, _("Active Downloads"), message, True, True) if m.accepted: self.on_close() else: return True else: self.on_close()
def on_cancel(self): filter_host = [download_item.host for download_item in api.get_active_downloads().itervalues() if download_item.time > 0] filter_id_items = [id_item for id_item, download_item in api.get_queue_downloads().iteritems() if download_item.host in filter_host] api.stop_all(filter_host) rows_buffer = self.parent.downloads.rows_buffer stopped_icon = self.parent.downloads.icons_dict[cons.STATUS_STOPPED] queue_icon = self.parent.downloads.icons_dict[cons.STATUS_QUEUE] for id_item, row in rows_buffer.items(): if row[1] == queue_icon and id_item not in filter_id_items: row[1] = stopped_icon self.reject()
def on_cancel(self): id_item_list = [] # stop all downloads from this host for id_item, download_item in api.get_active_downloads().iteritems(): if download_item.host == self.host and not download_item.start_time: api.stop_download(id_item) for id_item, download_item in api.get_queue_downloads().iteritems(): if download_item.host == self.host: api.stop_download(id_item) id_item_list.append(id_item) # change queue icon to stopped for id_item in id_item_list: row = self.parent.downloads.rows_buffer[id_item] row[1] = self.parent.downloads.icons_dict[cons.STATUS_STOPPED] self.reject()
def on_cancel(self, widget, parent): """""" filter_host = [download_item.host for download_item in api.get_active_downloads().itervalues() if download_item.time > 0] filter_id_items = [id_item for id_item, downloader_item in api.get_queue_downloads().iteritems() if download_item.host in filter_host] self.pending_events() api.stop_all(filter_host) self.pending_events() rows_buffer = parent.downloads_list_gui.rows_buffer stopped_icon = parent.downloads_list_gui.icons_dict[cons.STATUS_STOPPED] queue_icon = parent.downloads_list_gui.icons_dict[cons.STATUS_QUEUE] for id_item, row in rows_buffer.items(): if row[1] == queue_icon and id_item not in filter_id_items: row[1] = stopped_icon self.on_close()
def update_(self): active_downloads = api.get_active_downloads() api.update_active_downloads() for download_item in active_downloads.itervalues(): row = self.rows_buffer[download_item.id] #row[0] = download_item.id row[1] = self.icons_dict[download_item.status] row[2] = download_item.name #row[3][0] = download_item.host row[3][1] = self.icons_dict[cons.DL_RESUME] if download_item.can_resume else None row[3][2] = self.icons_dict[cons.DL_PREMIUM] if download_item.is_premium else None row[4] = utils.size_format(download_item.size) if download_item.size else None row[5] = utils.size_format(download_item.size_complete) if download_item.size_complete else None row[6] = download_item.progress row[7] = utils.time_format(download_item.time) if download_item.time else None row[8] = utils.time_format(download_item.time_remain) if download_item.time_remain else None row[9] = utils.speed_format(download_item.speed) if download_item.speed else None row[10] = self.get_status_msg(download_item) self.__model.refresh()
def __init__(self, parent, ip_renewer_cls): """""" self.id_list = [] self.stop_all = parent.downloads_list_gui.on_stop_all if self.can_change_ip(): self.pending_events() self.id_list = [download_item.id for download_item in api.get_active_downloads().values() + api.get_queue_downloads().values()] self.pending_events() self.stop_all() self.pending_events() self.change_ip_th = ip_renewer_cls if conf.get_addon_option(OPTION_RENEW_SCRIPT_ACTIVE, default=False, is_bool=True): self.change_ip_th.start(conf.get_addon_option(OPTION_IP_RENEW_SCRIPT_PATH, default="")) else: self.change_ip_th.start() gobject.timeout_add(1000, self.update_status, parent) self.msg_id = parent.status_bar.push_msg(_("Changing IP..."))
def __init__(self, parent, ip_renewer_cls): """""" self.change_ip_th = ip_renewer_cls self.parent = parent self.id_list = [] self.stop_all = self.parent.downloads.on_stop_all if self.can_change_ip(): self.id_list = [download_item.id for download_item in api.get_active_downloads().values() + api.get_queue_downloads().values()] self.stop_all() if conf.get_addon_option(OPTION_RENEW_SCRIPT_ACTIVE, default=False, is_bool=True): self.change_ip_th.start(conf.get_addon_option(OPTION_IP_RENEW_SCRIPT_PATH, default="")) else: self.change_ip_th.start() self.status_msg = _("Changing IP...") self.parent.status_bar.push_msg(self.status_msg) self.timer = self.parent.idle_timeout(1000, self.update)
def __init__(self, parent, ip_renewer): """""" self.ip_renewer = ip_renewer self.weak_parent = weakref.ref(parent) self.id_item_list = [] self.is_working = True if self.can_change_ip(): self.id_item_list = [download_item.id for download_item in api.get_active_downloads().values() + api.get_queue_downloads().values()] signals.on_stop_all.emit() if conf.get_addon_option(OPTION_RENEW_SCRIPT_ACTIVE, default=False, is_bool=True): self.ip_renewer.start_shell_script() else: self.ip_renewer.start_default_ip_renew() self.status_msg = _("Changing IP...") signals.status_bar_push_msg.emit(self.status_msg) self.timer = self.parent.idle_timeout(1000, self.update) else: self.is_working = False
def update_(self): active_downloads = api.get_active_downloads() api.update_active_downloads() for download_item in active_downloads.itervalues(): try: row = self.rows_buffer[download_item.id] #row[0] = download_item.id #this column is hidden and wont be modificated. row[1] = self.icons_dict[download_item.status] #col 1 row[2] = download_item.name #col 2 #row[3][0] = download_item.host #download_item.host #col 3 row[3][1] = self.icons_dict[cons.DL_RESUME] if download_item.can_resume else None #download_item.host #col 3 row[3][2] = self.icons_dict[cons.DL_PREMIUM] if download_item.is_premium else None #download_item.host #col 3 row[4] = misc.size_format(download_item.size) if download_item.size else None row[5] = misc.size_format(download_item.size_complete) if download_item.size_complete else None row[6] = download_item.progress row[7] = misc.time_format(download_item.time) if download_item.time else None row[8] = misc.time_format(download_item.time_remain) if download_item.time_remain else None row[9] = misc.speed_format(download_item.speed) if download_item.speed else None row[10] = self.get_status_msg(download_item) except KeyError as err: logger.debug(err) #uncomment if model doesnt get upated. self.__model.refresh()
def on_cancel(self, widget, parent): """""" filter_host = [ download_item.host for download_item in api.get_active_downloads().itervalues() if download_item.time > 0 ] filter_id_items = [ id_item for id_item, downloader_item in api.get_queue_downloads().iteritems() if download_item.host in filter_host ] self.pending_events() api.stop_all(filter_host) self.pending_events() rows_buffer = parent.downloads_list_gui.rows_buffer stopped_icon = parent.downloads_list_gui.icons_dict[ cons.STATUS_STOPPED] queue_icon = parent.downloads_list_gui.icons_dict[cons.STATUS_QUEUE] for id_item, row in rows_buffer.items(): if row[1] == queue_icon and id_item not in filter_id_items: row[1] = stopped_icon self.on_close()
def can_change_ip(self): """""" for download_item in api.get_active_downloads().itervalues(): if download_item.start_time: return False return True