def _on_connect_fail(self, reason, host_id, try_counter): log.debug('Failed to connect: %s', reason.value) if reason.check(AuthenticationRequired, BadLoginError): log.debug('PasswordRequired exception') dialog = AuthenticationDialog(reason.value.message, reason.value.username) def dialog_finished(response_id): if response_id == gtk.RESPONSE_OK: self._connect(host_id, dialog.get_username(), dialog.get_password()) return dialog.run().addCallback(dialog_finished) elif reason.check(IncompatibleClient): return ErrorDialog(_('Incompatible Client'), reason.value.message).run() if try_counter: log.info('Retrying connection.. Retries left: %s', try_counter) return reactor.callLater(0.5, self._connect, host_id, try_counter=try_counter - 1) msg = str(reason.value) if not self.gtkui_config['autostart_localhost']: msg += '\n' + _('Auto-starting the daemon locally is not enabled. ' 'See "Options" on the "Connection Manager".') ErrorDialog(_('Failed To Connect'), msg).run()
def failed_change_owner(failure): ErrorDialog( _('Ownership Change Error'), _('There was an error while trying changing ownership.'), self.mainwindow.window, details=failure.value.logable(), ).run()
def on_button_addhost_clicked(self, widget): log.debug("on_button_addhost_clicked") dialog = self.builder.get_object("addhost_dialog") dialog.set_transient_for(self.connection_manager) dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) hostname_entry = self.builder.get_object("entry_hostname") port_spinbutton = self.builder.get_object("spinbutton_port") username_entry = self.builder.get_object("entry_username") password_entry = self.builder.get_object("entry_password") button_addhost_save = self.builder.get_object("button_addhost_save") button_addhost_save.hide() button_addhost_add = self.builder.get_object("button_addhost_add") button_addhost_add.show() response = dialog.run() if response == 1: username = username_entry.get_text() password = password_entry.get_text() hostname = hostname_entry.get_text() # We add the host try: self.add_host(hostname, port_spinbutton.get_value_as_int(), username, password) except Exception, e: from deluge.ui.gtkui.dialogs import ErrorDialog ErrorDialog(_("Error Adding Host"), e).run()
def on_button_edithost_clicked(self, widget=None): log.debug('on_button_edithost_clicked') model, row = self.treeview.get_selection().get_selected() status = model[row][HOSTLIST_COL_STATUS] host_id = model[row][HOSTLIST_COL_ID] if status == 'Connected': def on_disconnect(reason): self._update_host_status() client.disconnect().addCallback(on_disconnect) return host_info = [ self.liststore[row][HOSTLIST_COL_HOST], self.liststore[row][HOSTLIST_COL_PORT], self.liststore[row][HOSTLIST_COL_USER], self.liststore[row][HOSTLIST_COL_PASS] ] new_host_info = self._run_addhost_dialog(edit_host_info=host_info) if new_host_info: hostname, port, username, password = new_host_info try: self.hostlist.update_host(host_id, hostname, port, username, password) except ValueError as ex: ErrorDialog(_('Error Updating Host'), ex).run() else: self.liststore[ row] = host_id, hostname, port, username, password, '', '' self._update_host_status()
def on_download_fail(result): log.debug('Download failed: %s', result) dialog.destroy() ErrorDialog(_('Download Failed'), '%s %s' % (_('Failed to download:'), url), details=result.getErrorMessage(), parent=self.dialog).run() return result
def show_already_added_dialog(self, count): """Show a message about trying to add duplicate torrents.""" log.debug('Tried to add %d duplicate torrents!', count) ErrorDialog( _('Duplicate torrent(s)'), _('You cannot add the same torrent twice.' ' %d torrents were already added.' % count), self.dialog, ).run()
def add_from_files(self, filenames): new_row = None already_added = 0 for filename in filenames: # Get the torrent data from the torrent file try: info = TorrentInfo(filename) except Exception as ex: log.debug('Unable to open torrent file: %s', ex) ErrorDialog(_('Invalid File'), ex, self.dialog).run() continue if info.info_hash in self.files: already_added += 1 continue new_row = self.torrent_liststore.append( [info.info_hash, info.name, xml_escape(filename)]) self.files[info.info_hash] = info.files self.infos[info.info_hash] = info.filedata self.listview_torrents.get_selection().select_iter(new_row) self.set_default_options() self.save_torrent_options(new_row) (model, row) = self.listview_torrents.get_selection().get_selected() if not row and new_row: self.listview_torrents.get_selection().select_iter(new_row) self.dialog.set_title( _('Add Torrents (%d)') % len(self.torrent_liststore)) if already_added: log.debug('Tried to add %d duplicate torrents!', already_added) ErrorDialog( _('Duplicate Torrent(s)'), _('You cannot add the same torrent twice. %d torrents were already added.' % already_added), self.dialog).run()
def on_button_addhost_clicked(self, widget): log.debug('on_button_addhost_clicked') host_info = self._run_addhost_dialog() if host_info: hostname, port, username, password = host_info try: host_id = self.hostlist.add_host(hostname, port, username, password) except ValueError as ex: ErrorDialog(_('Error Adding Host'), ex).run() else: self.liststore.append([ host_id, hostname, port, username, password, 'Offline', '' ]) self._update_host_status()
def add_from_files(self, filenames): already_added = 0 for filename in filenames: # Get the torrent data from the torrent file try: info = TorrentInfo(filename) except Exception as ex: log.debug('Unable to open torrent file: %s', ex) ErrorDialog(_('Invalid File'), ex, self.dialog).run() continue if not self._add_torrent_liststore(info.info_hash, info.name, filename, info.files, info.filedata): already_added += 1 if already_added: self.show_already_added_dialog(already_added)
def start_daemon(self, port, config): """Attempts to start local daemon process and will show an ErrorDialog if not. Args: port (int): Port for the daemon to listen on. config (str): Config path to pass to daemon. Returns: bool: True is successfully started the daemon, False otherwise. """ if client.start_daemon(port, config): log.debug('Localhost daemon started') reactor.callLater(1, self._update_host_status) return True else: ErrorDialog( _('Unable to start daemon!'), _('Check deluged package is installed and logs for further details' )).run() return False
def on_button_url_clicked(self, widget): log.debug('on_button_url_clicked') dialog = self.builder.get_object('url_dialog') entry = self.builder.get_object('entry_url') dialog.set_default_response(gtk.RESPONSE_OK) dialog.set_transient_for(self.dialog) entry.grab_focus() text = get_clipboard_text() if text and deluge.common.is_url(text) or deluge.common.is_magnet( text): entry.set_text(text) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_OK: url = entry.get_text().decode('utf-8') else: url = None entry.set_text('') dialog.hide() # This is where we need to fetch the .torrent file from the URL and # add it to the list. log.debug('url: %s', url) if url: if deluge.common.is_url(url): self.add_from_url(url) elif deluge.common.is_magnet(url): self.add_from_magnets([url]) else: ErrorDialog( _('Invalid URL'), '%s %s' % (url, _('is not a valid URL.')), self.dialog, ).run()