def start_upload(self): """ Start an upload (seeding). """ if self.get_type() != u'bittorrent': logging.warn("called start_upload for non-bittorrent downloader") return if self.child_deleted: title = "Can't Resume Seeding" msg = ("Seeding cannot resume because part of this torrent " "has been deleted.") dialogs.MessageBoxDialog(title, msg).run() return if self.get_state() not in (u'finished', u'uploading-paused'): logging.warn("called start_upload when downloader state is: %s", self.get_state()) return self.manualUpload = True if _downloads.has_key(self.dlid): c = command.StartDownloadCommand(RemoteDownloader.dldaemon, self.dlid) c.send() else: self.before_changing_status() self.status['state'] = u'uploading' self.after_changing_status() self.restart() self.signal_change()
def start_upload(self): """ Start an upload (seeding). """ if self.get_type() != u'bittorrent': logging.warn("called start_upload for non-bittorrent downloader") return if self.child_deleted: title = "Can't Resume Seeding" msg = ("Seeding cannot resume because part of this torrent " "has been deleted.") dialogs.MessageBoxDialog(title, msg).run() return if self.get_state() not in (u'finished', u'uploading-paused'): logging.warn("called start_upload when downloader state is: %s", self.get_state()) return self.manualUpload = True if app.download_state_manager.get_download(self.dlid): args = dict(url=self.url, content_type=self.content_type, channel_name=self.channel_name) app.download_state_manager.queue(self.dlid, app.download_state_manager.RESUME, args) else: self.before_changing_rates() self.state = u'uploading' self.after_changing_rates() self.restart() self.signal_change()
def _show_corrupt_db_dialog(self): title = _("%(appname)s database corrupt.", {"appname": app.config.get(prefs.SHORT_APP_NAME)}) description = _( "Your %(appname)s database is corrupt. It will be " "backed up in your Miro database directory and a new " "database will be created now.", {"appname": app.config.get(prefs.SHORT_APP_NAME)}) dialogs.MessageBoxDialog(title, description).run_blocking()
def show_import_summary(self): imported_feeds = len(self.result[0].get('feed', [])) ignored_feeds = len(self.result[1].get('feed', [])) title = _("OPML Import summary") message = ngettext("Successfully imported %(count)d podcast.", "Successfully imported %(count)d podcasts.", imported_feeds, {"count": imported_feeds}) if self.ignored_feeds > 0: message += "\n" message += ngettext("Skipped %(count)d podcast already present.", "Skipped %(count)d podcasts already present.", ignored_feeds, {"count": ignored_feeds}) dialog = dialogs.MessageBoxDialog(title, message) dialog.run()
def check_url_exists(url): """Checks to see if there's an item with this url already downloaded. In the case of the item existing in the manual feed, this pops up a dialog box with the status of the item. :param url: the url to check :returns: True if there is already an item for that url downloaded and False otherwise. """ manual_feed = feed.Feed.get_manual_feed() #item urls have the + sign escaped escaped_url = url.replace('+', '%20') for i in manual_feed.items: if i.get_url() == escaped_url: title = _("Download already exists") text1 = _("That URL is already an external download.") download_state = None if i.downloader is not None: download_state = i.downloader.get_state() if download_state in ('paused', 'stopped', 'failed'): i.download() text2 = _("%(appname)s will begin downloading it now.", {"appname": app.config.get(prefs.SHORT_APP_NAME)}) elif download_state == 'downloading': text2 = _("It is downloading now.") else: text2 = _("It has already been downloaded.") dialogs.MessageBoxDialog(title, "%s %s" % (text1, text2)).run() return True existing_feed = feed.lookup_feed(url) if existing_feed is not None: return True return False
def errback(error): title = _("Download Error") text = _( "%(appname)s is not able to download a file at this URL:\n" "\n" "URL: %(url)s\n" "\n" "Error: %(error)s (%(errordesc)s)", { "url": url, "appname": app.config.get(prefs.SHORT_APP_NAME), "error": error.getFriendlyDescription(), "errordesc": error.getLongDescription() }) logging.info("can't download '%s'", url) if not isinstance(error, httpclient.PossiblyTemporaryError): dialogs.MessageBoxDialog(title, text).run() else: def callback(dialog): if dialog.choice == dialogs.BUTTON_RETRY: httpclient.grab_headers(url, callback, errback) dialogs.ChoiceDialog(title, text, dialogs.BUTTON_RETRY, dialogs.BUTTON_CANCEL).run(callback)
# Make sure we re-run our SELECT statement so that the call to # fetchall() at the end of this method works. (#12885) self._current_select_statement = (sql, values, many) self._handle_operational_error(e) if self._quitting_from_operational_error and not is_update: # This is a very bad state to be in because code calling # us expects a return value. I think the best we can do # is re-raise the exception (BDK) raise if failed and not self._quitting_from_operational_error: title = _("%(appname)s database save succeeded", {"appname": app.config.get(prefs.SHORT_APP_NAME)}) description = _("The database has been successfully saved. " "It is now safe to quit without losing any data.") dialogs.MessageBoxDialog(title, description).run() if is_update: return None else: return self.cursor.fetchall() def _time_execute(self, sql, values, many): start = time.time() if many: self.cursor.executemany(sql, values) else: self.cursor.execute(sql, values) end = time.time() self._check_time(sql, end-start) def _log_error(self, sql, values, many):
def parse_command_line_args(args): """ This goes through a list of files which could be arguments passed in on the command line or a list of files from other source. """ if not _started_up: _command_line_args.extend(args) return for i in xrange(len(args)): if args[i].startswith('file://'): args[i] = args[i][len('file://'):] reset_command_line_view() added_videos = False added_downloads = False for arg in args: if arg.startswith('file://'): arg = download_utils.get_file_url_path(arg) elif arg.startswith('miro:'): add_subscription_url('miro:', 'application/x-miro', arg) elif arg.startswith('democracy:'): add_subscription_url('democracy:', 'application/x-democracy', arg) elif (arg.startswith('http:') or arg.startswith('https:') or arg.startswith('feed:') or arg.startswith('feeds:') or is_magnet_uri(arg)): singleclick.add_download(filename_to_unicode(arg)) elif os.path.exists(arg): ext = os.path.splitext(arg)[1].lower() if ext in ('.torrent', '.tor'): try: torrent_infohash = get_torrent_info_hash(arg) except ValueError: title = _("Invalid Torrent") msg = _( "The torrent file %(filename)s appears to be corrupt " "and cannot be opened.", {"filename": os.path.basename(arg)}) dialogs.MessageBoxDialog(title, msg).run() continue except (IOError, OSError): title = _("File Error") msg = _( "The torrent file %(filename)s could not be opened. " "Please ensure it exists and you have permission to " "access this file.", {"filename": os.path.basename(arg)}) dialogs.MessageBoxDialog(title, msg).run() continue add_torrent(arg, torrent_infohash) added_downloads = True elif ext in ('.rss', '.rdf', '.atom', '.ato'): feed.add_feed_from_file(arg) elif ext in ('.miro', '.democracy', '.dem', '.opml'): opml.Importer().import_subscriptions(arg, show_summary=False) else: add_video(arg) added_videos = True else: logging.warning("parse_command_line_args: %s doesn't exist", arg) # if the user has Miro set up to play all videos externally, then # we don't want to play videos added by the command line. # # this fixes bug 12362 where if the user has his/her system set up # to use Miro to play videos and Miro goes to play a video # externally, then it causes an infinite loop and dies. if added_videos and app.config.get(prefs.PLAY_IN_MIRO): item_ids = [i.id for i in _command_line_videos] item_infos = app.db.fetch_item_infos(item_ids) messages.PlayMovies(item_infos).send_to_frontend() if added_downloads: # FIXME - switch to downloads tab? pass
def _complain_about_subscription_url(message_text): title = _("Subscription error") dialogs.MessageBoxDialog(title, message_text).run()
def show_file_error(self): title = _("OPML Import failed") message = _("The selected OPML file could not be read. " "Import was interrupted.") dialog = dialogs.MessageBoxDialog(title, message) dialog.run()
def show_xml_error(self): title = _("OPML Import failed") message = _("The selected OPML file appears to be invalid. " "Import was interrupted.") dialog = dialogs.MessageBoxDialog(title, message) dialog.run()