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 __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 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 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_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 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 __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_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): """""" 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