rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if key != 'channelName': raise
def upgrade116(cursor): """Convert filenames in the status container to unicode.""" cursor.execute("SELECT id, status FROM remote_downloader") filename_fields = ('channelName', 'shortFilename', 'filename') for row in cursor.fetchall(): id, status = row status = eval(status, __builtins__, {'datetime': datetime, 'time': ...
self.start()
self.state = "downloading" self.start_new_download()
def retry_download(self): self.retryDC = None self.start()
status[key] = value.decode("utf-8")
try: status[key] = value.decode("utf-8") except UnicodeError: if key != 'channelName': raise try: status[key] = value.decode("iso-8859-1") except UnicodeError: status[key] = value.decode("utf-8", 'replace')
def upgrade116(cursor): """Convert filenames in the status container to unicode.""" cursor.execute("SELECT id, status FROM remote_downloader") filename_fields = ('channelName', 'shortFilename', 'filename') for row in cursor.fetchall(): id, status = row status = eval(status, __builtins__, {'datetime': datetime, 'time': ...
self._enqueue_message("cancel_running", key=key)
self._enqueue_message("cancel", key=key)
def clear_failed_task(self, key): self._enqueue_message("cancel_running", key=key)
return _("%(size)s gb/s", {"size": value})
return _("%(size)s GB/s", {"size": value})
def download_rate(rate): if rate >= (1 << 30): value = "%1.1f" % (rate / float(1 << 30)) return _("%(size)s gb/s", {"size": value}) elif rate >= (1 << 20): value = "%1.1f" % (rate / float(1 << 20)) return _("%(size)s mb/s", {"size": value}) elif rate >= (1 << 10): value = "%1.1f" % (rate / float(1 << 10)) return _("%(s...
return _("%(size)s mb/s", {"size": value})
return _("%(size)s MB/s", {"size": value})
def download_rate(rate): if rate >= (1 << 30): value = "%1.1f" % (rate / float(1 << 30)) return _("%(size)s gb/s", {"size": value}) elif rate >= (1 << 20): value = "%1.1f" % (rate / float(1 << 20)) return _("%(size)s mb/s", {"size": value}) elif rate >= (1 << 10): value = "%1.1f" % (rate / float(1 << 10)) return _("%(s...
return _("%(size)s kb/s", {"size": value})
return _("%(size)s kB/s", {"size": value})
def download_rate(rate): if rate >= (1 << 30): value = "%1.1f" % (rate / float(1 << 30)) return _("%(size)s gb/s", {"size": value}) elif rate >= (1 << 20): value = "%1.1f" % (rate / float(1 << 20)) return _("%(size)s mb/s", {"size": value}) elif rate >= (1 << 10): value = "%1.1f" % (rate / float(1 << 10)) return _("%(s...
return _("%(size)s b/s", {"size": value})
return _("%(size)s B/s", {"size": value})
def download_rate(rate): if rate >= (1 << 30): value = "%1.1f" % (rate / float(1 << 30)) return _("%(size)s gb/s", {"size": value}) elif rate >= (1 << 20): value = "%1.1f" % (rate / float(1 << 20)) return _("%(size)s mb/s", {"size": value}) elif rate >= (1 << 10): value = "%1.1f" % (rate / float(1 << 10)) return _("%(s...
auto_download_mode = feed_dict.get('auto_download')
auto_download_mode = feed_dict.get('auto_download_mode')
def handle_feed(self, feed_dict, parent_folder): """ Feed subscriptions look like::
source = os.path.join("Miro.app", "Contents", "MacOS", "python") target = os.path.join("Miro.app", "Contents", "Frameworks", "Python.framework", "Versions", PYTHON_VERSION, "bin")
app_root = self._get_app_root() source = os.path.join(app_root, "Contents", "MacOS", "python") target = os.path.join(app_root, "Contents", "Frameworks", "Python.framework", "Versions", PYTHON_VERSION, "bin")
def relocate_python_executable(self): # In certain unknown circumstances, Mac OS will launch the embedded # python executable instead of the Miro executable when the application # is double clicked in the Finder, and since OS X LaunchServices pass # a -psn_X_Y parameter representing the process serial number which # py...
fasttypes_mod = os.path.join("Miro.app", "Contents", "Resources", "lib", "python%s" % PYTHON_VERSION, "lib-dynload", "miro", "fasttypes.so")
app_root = self._get_app_root() fasttypes_mod = os.path.join(app_root, "Contents", "Resources", "lib", "python%s" % PYTHON_VERSION, "lib-dynload", "miro", "fasttypes.so")
def fix_install_names(self): py_install_name = os.path.join("@executable_path", "..", "Frameworks", "Python.framework", "Versions", PYTHON_VERSION, "Python")
libtorrent_so = os.path.join("Miro.app", "Contents", "Resources", "lib", "python%s" % PYTHON_VERSION, "lib-dynload", "libtorrent.so")
libtorrent_so = os.path.join(app_root, "Contents", "Resources", "lib", "python%s" % PYTHON_VERSION, "lib-dynload", "libtorrent.so")
def fix_install_names(self): py_install_name = os.path.join("@executable_path", "..", "Frameworks", "Python.framework", "Versions", PYTHON_VERSION, "Python")
return thumb
return unicode(thumb)
def _get_element_thumbnail(self, element): try: thumb = element["thumbnail"] except KeyError: return None if isinstance(thumb, str): return thumb try: if isinstance(thumb, unicode): return thumb.encode('utf-8') # We can't get the type?? What to do .... return thumb["url"].decode('ascii', 'replace') except (KeyError, A...
"ADD active_filters TEXT")
"ADD active_filters PYTHONREPR")
def upgrade111(cursor): """Create the active_filters column.""" cursor.execute("ALTER TABLE widgets_frontend_state " "ADD active_filters TEXT") cursor.execute("UPDATE widgets_frontend_state " "SET active_filters = '{}'")
print 'checking: ', item
def do_some_updates(self): chunk = list(Item.next_10_incomplete_movie_data_view()) if chunk: for item in chunk: print 'checking: ', item item.check_media_file() else: self.done = True
eventloop.callInThread(onSSLOpen, handleSSLError, socket.ssl,
eventloop.callInThread(onSSLOpen, handleSSLError, convert_to_ssl,
def onSocketOpen(self): self.socket.setblocking(1) eventloop.callInThread(onSSLOpen, handleSSLError, socket.ssl, "AsyncSSL onSocketOpen()", self.socket)
return socket.ssl(self.socket)
return convert_to_ssl(self.socket)
def openProxyConnection(self): headers = {'User-Agent': user_agent(), "Host": host} if config.get(prefs.HTTP_PROXY_AUTHORIZATION_ACTIVE): username = config.get(prefs.HTTP_PROXY_AUTHORIZATION_USERNAME) password = config.get(prefs.HTTP_PROXY_AUTHORIZATION_PASSWORD) authString = username+':'+password authString = b64encod...
PROCESS_TERMINATE = 1 handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, False, pid) ctypes.windll.kernel32.TerminateProcess(handle, -1) ctypes.windll.kernel32.CloseHandle(handle)
try: PROCESS_TERMINATE = 1 handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, False, pid) ctypes.windll.kernel32.TerminateProcess(handle, -1) ctypes.windll.kernel32.CloseHandle(handle) except ValueError: logging.exception("problem killing process")
def kill_process(pid): # Kill the old process, if it exists if pid is not None: # This isn't guaranteed to kill the process, but it's likely the # best we can do # See http://support.microsoft.com/kb/q178893/ # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/347462 PROCESS_TERMINATE = 1 handle = ctypes.windll.k...
error.encode('ascii', 'replace'))
stringify(error))
def _updateErrback(self, error): if not self.ufeed.id_exists(): return logging.info("WARNING: error in Feed.update for %s -- %s", self.ufeed, error.encode('ascii', 'replace')) self.scheduleUpdateEvents(-1) self.updating = False self.ufeed.signal_change(needs_save=False)
self.ufeed, url, error.encode('ascii', 'replace'))
self.ufeed, url, stringify(error))
def _updateErrback(self, error, url): if not self.ufeed.id_exists(): return logging.warn("WARNING: error in Feed.update for %s (%s) -- %s", self.ufeed, url, error.encode('ascii', 'replace')) self.scheduleUpdateEvents(-1) self.updating -= 1 self.checkUpdateFinished() self.ufeed.signal_change(needs_save=False)
hbox = widgetutil.build_hbox((widgetset.Label(_("Language:")), lang_option_menu))
update_button = widgetset.Button(_("Update")) update_button.connect('clicked', update_clicked) hbox = widgetset.HBox() hbox.pack_start(widgetset.Label(_("Language:")), padding=0) hbox.pack_start(lang_option_menu, padding=5) hbox.pack_start(update_button, padding=5)
def next_clicked(widget): config.set(prefs.LANGUAGE, str(lang_options[lang_option_menu.get_selected()][0])) gtcache.init() self.next_page(rebuild=True)
sub_path = sub_path.encode('utf-8')
def select_subtitle_file(self, item, sub_path, handle_successful_select): sub_path = sub_path.encode('utf-8') try: sub_path = copy_subtitle_file(sub_path, item.video_path) except WindowsError: # FIXME - need a better way to deal with this. when this # happens, then the subtitle file isn't in the right place # for VLC ...
sys.getwindowsversion()[-1])
sys.getwindowsversion())
def run(self): logging.info("Windows version: %s %s %s %s", platform.system(), platform.release(), platform.machine(), sys.getwindowsversion()[-1]) logging.info("Python version: %s", sys.version) logging.info("Gtk+ version: %s", gtk.gtk_version) logging.info("PyGObject version: %s", gtk.ver) logging.info("PyG...
NSApplication.sharedApplication().setDelegate_(self.app_controller)
miroapp = MiroApplication.sharedApplication() miroapp.setDelegate_(self.app_controller)
def run(self): logging.info("OSX version: %s %s %s", platform.system(), platform.release(), platform.machine()) try: import libtorrent logging.info("libtorrent: %s", libtorrent.version) except AttributeError: logging.info("libtorrent: unknown version") except ImportError: logging.exception("libtorre...
os.environ["LANG"] = locale.normalize(os.environ["MIRO_LANG"])
os.environ["LANG"] = os.environ["MIRO_LANG"]
def initialize_locale(): global _locale_initialized pool = NSAutoreleasePool.alloc().init() languages = list(NSUserDefaults.standardUserDefaults()["AppleLanguages"]) try: pos = languages.index('en') languages = languages[:pos+1] except: pass if os.environ.get("MIRO_LANG"): os.environ["LANGUAGE"] = os.environ["MIRO_LA...
os.environ["LANG"] = locale.normalize(languages[0])
def initialize_locale(): global _locale_initialized pool = NSAutoreleasePool.alloc().init() languages = list(NSUserDefaults.standardUserDefaults()["AppleLanguages"]) try: pos = languages.index('en') languages = languages[:pos+1] except: pass if os.environ.get("MIRO_LANG"): os.environ["LANGUAGE"] = os.environ["MIRO_LA...
milestone = argv[2]
milestones = argv[2:]
def main(argv): if not(argv): print USAGE print HELP return 0 if len(argv) < 3: print USAGE return 0 logging.basicConfig(level=logging.INFO) prevrev = argv[0] rev = argv[1] milestone = argv[2] git_authors = get_git_authors(prevrev, rev) reporters = get_bugzilla_reporters(milestone) addtl = get_additional_contributo...
reporters = get_bugzilla_reporters(milestone)
reporters = {} for milestone in milestones: reporters.update(get_bugzilla_reporters(milestone))
def main(argv): if not(argv): print USAGE print HELP return 0 if len(argv) < 3: print USAGE return 0 logging.basicConfig(level=logging.INFO) prevrev = argv[0] rev = argv[1] milestone = argv[2] git_authors = get_git_authors(prevrev, rev) reporters = get_bugzilla_reporters(milestone) addtl = get_additional_contributo...
def select_file(self, filename, callback, errback):
def select_file(self, iteminfo, callback, errback):
def select_file(self, filename, callback, errback): """starts playing the specified file"""
possible = [os.path.join(dirname, mem) for mem in os.listdir(dirname) if mem.startswith(basename) and filetypes.is_subtitle_filename(mem)] if len(possible) > 0: subtitle_files.extend(possible)
if os.path.exists(dirname): possible = [os.path.join(dirname, mem) for mem in os.listdir(dirname) if mem.startswith(basename) and filetypes.is_subtitle_filename(mem)] if len(possible) > 0: subtitle_files.extend(possible)
def gather_subtitle_files(movie_path): """Given an absolute path for a video file, this returns a list of filenames of sidecar subtitle file that are in the same directory or in a subtitles directory that are associated with the video file. >>> gather_subtitles_file('/tmp/foo.ogv") [] >>> gather_subtitle_files("/tmp/b...
def __init__(self, id_, ids_to_track):
def __init__(self, id_, ids_to_track, search_text=None):
def __init__(self, id_, ids_to_track): self.id = id_ self.ids_to_track = ids_to_track self.type = 'manual'
return DeviceDatabase() try: db = json.load(file(file_name, 'rb')) except ValueError: logging.exception('error loading JSON db on %s' % mount)
def load_database(mount): """ Returns a dictionary of the JSON database that lives on the given device. The database lives at [MOUNT]/.miro/json """ file_name = os.path.join(mount, '.miro', 'json') if not os.path.exists(file_name): return DeviceDatabase() try: db = json.load(file(file_name, 'rb')) except ValueError: l...
if self.url:
if url:
def navigate(self, url): if self.url: self._browser.get_frame().load_uri(url)
PROGRESS_RE = re.compile(r'frame=.* fps=.* q=.* size=.* time=(.*) bitrate=(.*)')
PROGRESS_RE = re.compile(r'(?:frame=.* fps=.* q=.* )?size=.* time=(.*) bitrate=(.*)')
def interrupt(self): logging.info("killing conversion task %d", self.process_handle.pid) utils.kill_process(self.process_handle.pid) if os.path.exists(self.temp_output_path) and self.progress < 1.0: clean_up(self.temp_output_path, file_and_directory=True)
self.sort_states[self._key(type, id)] = state
self.sort_states[self._key(typ, id_)] = state
def set_sort_state(self, typ, id_, sorter): # we have a ItemSort object and we need to create a string that will # represent it. Use the sort key, with '-' prepended if the sort is # descending (for example: "date", "-name", "-size", ...) state = sorter.KEY if not sorter.is_ascending(): state = '-' + state self.sort_s...
<<<<<<< HEAD
def set_columns_state(self, typ, id_, columns): self.current_columns = columns self.save_state()
def set_sort_state(self, typ, id_, sorter): # we have a ItemSort object and we need to create a string that will # represent it. Use the sort key, with '-' prepended if the sort is # descending (for example: "date", "-name", "-size", ...) state = sorter.KEY if not sorter.is_ascending(): state = '-' + state self.sort_s...
======= def set_columns_state(self, type, id, columns): self.current_columns = columns self.save_state() def set_list_view(self, type, id): self.current_displays.add(self._key(type, id)) >>>>>>> Attach handlers to columns.
def set_list_view(self, typ, id_): self.current_displays.add(self._key(typ, id_))
except RuntimeError:
except (KeyError, RuntimeError):
def got_metainfo(self): # FIXME: If the client is stopped before a BT download gets # its metadata, we never run this. It's not a huge deal # because it only affects the incomplete filename if not self.restarting: try: metainfo = lt.bdecode(self.metainfo) # if we don't get valid torrent metadata back, the...
return item.name.lower()
if item.name: return item.name.lower() return item.name
def sort_key(self, item): return item.name.lower()
(u"http://beta.legaltorrents.com/", u"LegalTorrents"),
(u"http://www.clearbits.net/", u"ClearBits"),
def _install_default_feeds(self): logging.info("Adding default feeds") default_video_feeds = [] default_video_feeds.extend([ (u'http://vodo.net/feeds/promoted', False), (u'http://feeds.feedburner.com/earth-touch_podcast_720p', False), (u'http://www.linktv.org/rss/hq/globalpulse.xml', False), ])
if result is None and encoding is not None:
if result is None and encoding is not None and not encoding == '':
def _to_utf8_bytes(s, encoding=None): """Takes a string and do whatever needs to be done to make it into a UTF-8 string. If a Unicode string is given, it is just encoded in UTF-8. Otherwise, if an encoding hint is given, first try to decode the string as if it were in that encoding; if that fails (or the hint isn't giv...
self.cursor.execute("BEGIN TRANSACTION") for (sql, values, many) in self._statements_in_transaction:
if self._statements_in_transaction: self.cursor.execute("BEGIN TRANSACTION") to_run = self._statements_in_transaction[:] if self._current_select_statement: to_run.append(self._current_select_statement) for (sql, values, many) in to_run:
def _try_rerunning_transaction(self): self.cursor.execute("BEGIN TRANSACTION") for (sql, values, many) in self._statements_in_transaction: try: self._time_execute(sql, values, many) except sqlite3.OperationalError, e: self._log_error(sql, values, many) return False return True
except Exception, e:
except (TypeError, KeyError):
def find(value, key=None): if key is None: try: key = LENGTH_MAP[len(value)] except Exception, e: return None for lang in LANGUAGES_MAP: if key in lang and lang[key] == value: return lang return None
elif not self.info.item_viewed and not self.info.expiration_date and not self.info.is_external:
elif (not self.info.item_viewed and not self.info.expiration_date and not self.info.is_external and not self.info.downloaded):
def render(self, context, layout, selected, hotspot, hover): if self.info.state == 'downloading': icon = self.downloading_icon elif self.info.downloaded and self.info.is_playable and not self.info.video_watched: icon = self.unwatched_icon elif not self.info.item_viewed and not self.info.expiration_date and not self.inf...
user_pwd = '%s:%s' % (self.proxy_auth.username, self.proxy_auth.password)
user_pwd = str('%s:%s' % (self.proxy_auth.username, self.proxy_auth.password))
def _setup_proxy_auth(self): # first try passwords stored by miro. proxy_auth was setup in # _lookup_auth() if self.proxy_auth is not None: user_pwd = '%s:%s' % (self.proxy_auth.username, self.proxy_auth.password) self.handle.setopt(pycurl.PROXYUSERPWD, user_pwd) else: # fallback on system auth info if config.get(pref...
if not flag:
if not app.widgetapp.window.nswindow.isVisible():
def applicationShouldHandleReopen_hasVisibleWindows_(self, appl, flag): if app.widgetapp is not None and app.widgetapp.window is not None: mainWindow = app.widgetapp.window.nswindow if mainWindow is not None: if not flag: app.widgetapp.window.nswindow.makeKeyAndOrderFront_(nil) if mainWindow.isMiniaturized(): mainWindo...
def __init__(self, converter_info, item_info, target_folder):
def __init__(self, converter_info, item_info, target_folder, create_item):
def __init__(self, converter_info, item_info, target_folder): ConversionTask.__init__(self, converter_info, item_info, target_folder) self.platform = app.config.get(prefs.APP_PLATFORM)
target_folder)
target_folder, create_item)
def __init__(self, converter_info, item_info, target_folder): ConversionTask.__init__(self, converter_info, item_info, target_folder) self.platform = app.config.get(prefs.APP_PLATFORM)
if self.display_channel and self.data.feed_name is not None:
if ((not self.data.is_external and self.display_channel and self.data.feed_name is not None)):
def pack_main(self, layout): vbox = cellpack.VBox() layout.set_font(1.1, family=widgetset.ITEM_TITLE_FONT, bold=True) layout.set_text_color(self.ITEM_TITLE_COLOR) title = layout.textbox(self.data.name) # FIXME - title should wrap to the next line instead of being # truncated; ben said this might be hard/impossible if n...
print 'MYSELF %s %s RECEIVED %s %s' % (my_hostname, my_port, host, port)
def mdns_callback(self, added, fullname, host, port): # NB: Filter out myself. added_list = [] removed_list = [] # First check to see if it's myself. my_hostname, my_port = app.sharing_manager.mdns_myself() print 'MYSELF %s %s RECEIVED %s %s' % (my_hostname, my_port, host, port) if my_hostname == host and my_port == po...
return lang
langdict = dict(lang) if parts: langdict["name"] = u"%s (%s)" % (langdict["name"], parts[1]) return langdict
def find(value, key=None): if key is None: try: key = LENGTH_MAP[len(value)] except (TypeError, KeyError): return None for lang in LANGUAGES_MAP: if key in lang and lang[key] == value: return lang return None
{ "alpha2": "", "alpha3": "und", "name": u"Unspecified" }, { "alpha2": "af", "alpha3": "afr", "name": u"Afrikaans" }, { "alpha2": "sq", "alpha3": "alb", "name": u"Albanian" }, { "alpha2": "sq", "alpha3": "sqi", "name": u"Albanian" }, { "alpha2": "am", "alpha3": "amh", "name": u"Amharic" }, { "alpha2": "ar", "alpha3":...
{"alpha2": "", "alpha3": "und", "name": u"Unspecified"}, {"alpha2": "af", "alpha3": "afr", "name": u"Afrikaans"}, {"alpha2": "sq", "alpha3": "alb", "name": u"Albanian"}, {"alpha2": "sq", "alpha3": "sqi", "name": u"Albanian"}, {"alpha2": "am", "alpha3": "amh", "name": u"Amharic"}, {"alpha2": "ar", "alpha3": "ara", "na...
def find(value, key=None): if key is None: try: key = LENGTH_MAP[len(value)] except (TypeError, KeyError): return None for lang in LANGUAGES_MAP: if key in lang and lang[key] == value: return lang return None
os.remove(self.log_file) config.set(prefs.DOWNLOADER_LOG_PATHNAME, self.log_file)
os.remove(self.log_file) config.set(prefs.MOVIES_DIRECTORY, os.path.join(tempfile.tempdir, 'movies-dir'), temporary=True) config.set(prefs.DOWNLOADER_LOG_PATHNAME, self.log_file, temporary=True)
def setUp(self): EventLoopTest.setUp(self) self.url = u'http://pculture.org/feeds_test/unittest-feed-1.rss' self.feed = models.Feed(self.url) downloader.init_controller() downloader.startup_downloader() self.log_file = os.path.join(tempfile.tempdir, 'miro-download-unit-tests') if os.path.exists(self.log_file): os.remov...
self.pixbuf = gtk.gdk.pixbuf_new_from_file(icon_path)
self.engine_pixbuf = gtk.gdk.pixbuf_new_from_file(icon_path) icon_path = resources.path('images/clear-image.png') self.clear_pixbuf = gtk.gdk.pixbuf_new_from_file(icon_path)
def __init__(self): gtk.EventBox.__init__(self) self.add_events(gtk.gdk.EXPOSURE_MASK) self.alignment = gtk.Alignment(yalign=0.5, xscale=1.0) self.entry = gtk.Entry() self.entry.set_has_frame(False) self.alignment.add(self.entry) self._align_entry() self.add(self.alignment) self.alignment.show_all()
self.alignment.set_padding(3, 3, 26, 4)
self.alignment.set_padding(3, 3, 26, 28)
def _align_entry(self): # Make it so we handle the inner border of the entry ourselves. # # By default entries have 3px padding on all sides. Change that to 0, # and make our Alignment widget handle it. # NOTE we use has 4px padding on the right side to compensate for the # fact that GTKEntry draws itself 1 extra pixe...
def _icon_position(self): x = 6 y = (self.allocation.height - 16) / 2 return x, y
def _clear_icon_position(self): return (self.allocation.width - 20, ((self.allocation.height - 16) / 2)) def _engine_icon_position(self): return (6, ((self.allocation.height - 16) / 2))
def _icon_position(self): x = 6 y = (self.allocation.height - 16) / 2 return x, y
x, y = self._icon_position()
x, y = self._clear_icon_position()
def do_expose_event(self, event): gtk.EventBox.do_expose_event(self, event) self.entry.style.paint_shadow(event.window, gtk.STATE_NORMAL, gtk.SHADOW_IN, event.area, self.entry, "entry", 0, 0, self.allocation.width, self.allocation.height) x, y = self._icon_position() exposed = event.area.intersect(gtk.gdk.Rectangle(x, ...
event.window.draw_pixbuf(None, self.pixbuf, exposed.x-x, exposed.y-y, exposed.x, exposed.y, exposed.width, exposed.height)
event.window.draw_pixbuf( None, self.clear_pixbuf, exposed.x-x, exposed.y-y, exposed.x, exposed.y, exposed.width, exposed.height) x, y = self._engine_icon_position() exposed = event.area.intersect(gtk.gdk.Rectangle(x, y, 16, 16)) event.window.draw_pixbuf( None, self.engine_pixbuf, exposed.x-x, exposed.y-y, exposed.x, ...
def do_expose_event(self, event): gtk.EventBox.do_expose_event(self, event) self.entry.style.paint_shadow(event.window, gtk.STATE_NORMAL, gtk.SHADOW_IN, event.area, self.entry, "entry", 0, 0, self.allocation.width, self.allocation.height) x, y = self._icon_position() exposed = event.area.intersect(gtk.gdk.Rectangle(x, ...
self.pixbuf = self._engine_to_pixbuf[engine_name]
self.engine_pixbuf = self._engine_to_pixbuf[engine_name]
def select_engine(self, engine_name): self.pixbuf = self._engine_to_pixbuf[engine_name] self._engine = engine_name self.queue_draw()
def _event_inside_icon(self, event): x, y = self._icon_position()
def _event_inside_engine_icon(self, event): x, y = self._engine_icon_position()
def _event_inside_icon(self, event): x, y = self._icon_position() return (x <= event.x < x + 16) and (y <= event.y < y + 16)
if self._event_inside_icon(event):
if self._event_inside_engine_icon(event):
def do_button_press_event(self, event): if self._event_inside_icon(event): self.menu.popup(None, None, None, event.button, event.time)
title = unicode(params.get("title", ["No title"])[0])
title = params.get("title", ["No title"])[0] try: title = title.decode("utf-8") except UnicodeDecodeError: title = title.decode("ascii", "ignore")
def _youtube_callback_step2(info, video_id, callback): try: body = info['body'] params = cgi.parse_qs(body) if params.get("status", [""])[0] == "fail": logging.info("youtube download failed because: %s", params.get("reason", ["unknown"])[0]) callback(None) return # fmt_url_map is a comma separated list of pipe separat...
msg = "httpclient: saw multiple empty header lines"
msg = "httpclient: saw multiple empty header lines (%s)"
def header_func(self, line): line = line.strip() if line.startswith("HTTP"): curl_manager.call_after_perform(self.check_status_line) return if line == '': if 'location' in self.headers: # doing a redirect, clear out the headers self.headers = {} elif not self.headers_finished: curl_manager.call_after_perform(self.on_he...
if self.entry_title is not None: return self.entry_title
def get_title(self): """Returns the title of the item. """ if self.title: return self.title try: return self.metadata['title'] except (KeyError, TypeError): pass if self.get_filename() is not None: return self._filename_to_title(self.get_filename()) if self.entry_title is not None: return self.entry_title return _('no ...
if os.path.exists(dest_path): os.remove(dest_path) shutil.copyfile(sub_path, dest_path)
if sub_path != dest_path: if os.path.exists(dest_path): os.remove(dest_path) shutil.copyfile(sub_path, dest_path)
def copy_subtitle_file(sub_path, video_path): """Copies the subtitle file located at sub_path alongside the video file located at video_path. It also changes the name so that the subtitle file follows the rules of sidecar files. Returns the path the subtitle file was copied to. """ from miro import iso_639 sub_basen...
("ISO-8859-9", _("Baltic")), ("Windows-1254", _("Baltic")), ("Windows-1252", _("Eastern European")), ("ISO-8859-2", _("Eastern European")), ("ISO-8859-3", _("Russian")), ("Windows-874", _("South-Eastern European")), ("ISO-8859-10", _("Ukrainian")),
('Latin-7', _('Baltic')), ('Windows-1257', _('Baltic')), ('Latin-2', _('Eastern European')), ('Windows-1250', _('Eastern European')), ('KOI8-R', _('Russian')), ('Latin-10', _('South-Eastern European')), ('KOI8-U', _('Ukrainian')),
def setup_subtitle_encoding_menu(self, menubar): menus.add_subtitle_encoding_menu(menubar, _('Eastern European'), ("ISO-8859-9", _("Baltic")), ("Windows-1254", _("Baltic")), ("Windows-1252", _("Eastern European")), ("ISO-8859-2", _("Eastern European")), ("ISO-8859-3", _("Russian")), ("Windows-874", _("South-Eastern Eur...
("ISO-8859-11", _("Celtic")), ("ISO-8859-15", _("Western European")), ("Windows-1250", _("Esperanto")), ("KOI8-U", _("Greek")), ("ISO-8859-6", _("Greek")),
('Latin-8', _('Celtic')), ('Windows-1252', _('Western European')), ('Latin-3', _('Esperanto')), ('ISO 8859-7', _('Greek')), ('Windows-1253', _('Greek')),
def setup_subtitle_encoding_menu(self, menubar): menus.add_subtitle_encoding_menu(menubar, _('Eastern European'), ("ISO-8859-9", _("Baltic")), ("Windows-1254", _("Baltic")), ("Windows-1252", _("Eastern European")), ("ISO-8859-2", _("Eastern European")), ("ISO-8859-3", _("Russian")), ("Windows-874", _("South-Eastern Eur...
("GB18030", _("Universal, Chinese")), ("ISO-8859-13", _("Simplified Chinese")), ("Windows-1257", _("Simplified Chinese Unix")), ("ISO-8859-14", _("Japanese")), ("ISO-8859-16", _("Japanese Unix")), ("ISO-2022-CN-EXT", _("Japanese")), ("EUC-CN", _("Korean")), ("ISO-2022-JP-2", _("Korean")), ("EUC-JP", _("Traditional Chin...
('GB18030', _('Universal Chinese')), ('ISO-2022-CN-EXT', _('Simplified Chinese')), ('EUC-CN', _('Simplified Chinese Unix')), ('7-bits JIS/ISO-2022-JP-2', _('Japanese')), ('EUC-JP', _('Japanese Unix')), ('Shift JIS', _('Japanese')), ('EUC-KR/CP949', _('Korean')), ('ISO-2022-KR', _('Korean')), ('Big5', _('Traditional Chi...
def setup_subtitle_encoding_menu(self, menubar): menus.add_subtitle_encoding_menu(menubar, _('Eastern European'), ("ISO-8859-9", _("Baltic")), ("Windows-1254", _("Baltic")), ("Windows-1252", _("Eastern European")), ("ISO-8859-2", _("Eastern European")), ("ISO-8859-3", _("Russian")), ("Windows-874", _("South-Eastern Eur...
("Windows-1253", _("Turkish")), ("ISO-8859-8", _("Turkish")), ("Windows-1255", _("Thai")), ("ISO-2022-KR", _("Vietnamese")), ("Big5", _("Vietnamese")),
('ISO 8859-9', _('Turkish')), ('Windows-1254', _('Turkish')), ('Windows-874', _('Thai')), ('VISCII', _('Vietnamese')), ('Windows-1258', _('Vietnamese')),
def setup_subtitle_encoding_menu(self, menubar): menus.add_subtitle_encoding_menu(menubar, _('Eastern European'), ("ISO-8859-9", _("Baltic")), ("Windows-1254", _("Baltic")), ("Windows-1252", _("Eastern European")), ("ISO-8859-2", _("Eastern European")), ("ISO-8859-3", _("Russian")), ("Windows-874", _("South-Eastern Eur...
("Windows-1251", _("Arabic")), ("KOI8-R", _("Arabic")), ("Windows-1256", _("Hebrew")), ("ISO-8859-7", _("Hebrew")),
('ISO 8859-6', _('Arabic')), ('Windows-1256', _('Arabic')), ('ISO 8859-8', _('Hebrew')), ('Windows-1255', _('Hebrew')),
def setup_subtitle_encoding_menu(self, menubar): menus.add_subtitle_encoding_menu(menubar, _('Eastern European'), ("ISO-8859-9", _("Baltic")), ("Windows-1254", _("Baltic")), ("Windows-1252", _("Eastern European")), ("ISO-8859-2", _("Eastern European")), ("ISO-8859-3", _("Russian")), ("Windows-874", _("South-Eastern Eur...
("UTF-8", _("Universal")), ("UTF-16", _("Universal")), ("UTF-16BE", _("Universal")), ("UTF-16LE", _("Universal")),
('UTF-8', _('Universal')), ('UTF-16', _('Universal')), ('UTF-16BE', _('Universal')), ('UTF-16LE', _('Universal')),
def setup_subtitle_encoding_menu(self, menubar): menus.add_subtitle_encoding_menu(menubar, _('Eastern European'), ("ISO-8859-9", _("Baltic")), ("Windows-1254", _("Baltic")), ("Windows-1252", _("Eastern European")), ("ISO-8859-2", _("Eastern European")), ("ISO-8859-3", _("Russian")), ("Windows-874", _("South-Eastern Eur...
return (os.path.join(target_folder, target_name), os.path.join(temp_dir, target_name))
full_target_name = os.path.join(target_folder, target_name) return (next_free_filename(full_target_name), os.path.join(temp_dir, target_name))
def build_output_paths(item_info, target_folder, converter_info): """Returns final_output_path and temp_output_path. """ input_path = item_info.video_path temp_dir = utils.FilenameType(tempfile.mkdtemp("miro-conversion")) title = utils.unicode_to_filename(item_info.name, temp_dir) if not title or not title.strip(): tit...
except (OSError, IOError, WindowsError): logging.debug("clean_up: %s kicked up while removing %s", e, temp_file) eventloop.add_timeout(1.0, clean_up, "conversion clean_up attempt", (clean_up, temp_file, file_and_directory, attempts+1))
except (OSError, IOError, WindowsError), e: logging.debug("clean_up: %s kicked up while removing %s", e, temp_file) timeout = 1.0 * attempts eventloop.add_timeout( timeout, clean_up, "conversion clean_up attempt", (temp_file, file_and_directory, attempts+1))
def clean_up(temp_file, file_and_directory=False, attempts=0): if attempts > 5: return if os.path.exists(temp_file): try: os.remove(temp_file) except (OSError, IOError, WindowsError): logging.debug("clean_up: %s kicked up while removing %s", e, temp_file) eventloop.add_timeout(1.0, clean_up, "conversion clean_up attemp...
logging.debug("clean_up: %s kicked up while removing %s", e, path) eventloop.add_timeout(1.0, clean_up, "conversion clean_up attempt", (clean_up, temp_file, file_and_directory, attempts+1))
logging.debug("clean_up: %s kicked up while removing %s", e, path) timeout = 1.0 * attempts eventloop.add_timeout( timeout, clean_up, "conversion clean_up attempt", (temp_file, file_and_directory, attempts+1))
def clean_up(temp_file, file_and_directory=False, attempts=0): if attempts > 5: return if os.path.exists(temp_file): try: os.remove(temp_file) except (OSError, IOError, WindowsError): logging.debug("clean_up: %s kicked up while removing %s", e, temp_file) eventloop.add_timeout(1.0, clean_up, "conversion clean_up attemp...
self.temp_dir = tempfile.mkdtemp("miro-conversion")
self.temp_dir = utils.FilenameType(tempfile.mkdtemp("miro-conversion"))
def __init__(self, converter_info, item_info, target_folder): self.temp_dir = tempfile.mkdtemp("miro-conversion") self.item_info = item_info self.converter_info = converter_info self.input_path = item_info.video_path self.final_output_path, self.temp_output_path = build_output_paths( item_info, self.temp_dir, target_fo...
if count > 0:
if count > 1:
def setup_subtitles(self): self.setup_subtitle_info() if config.get(prefs.ENABLE_SUBTITLES): track_index = self.get_enabled_subtitle_track() if track_index == 0: count = libvlc.libvlc_video_get_spu_count(self.media_player, self.exc.ref()) if count > 0: self.enable_subtitle_track(1) else: self.disable_subtitles()
self.subtitle_info.append((i, desc.contents.name))
if i > 0: self.subtitle_info.append((i, desc.contents.name))
def setup_subtitle_info(self): self.subtitle_info = list() try: desc = libvlc.libvlc_video_get_spu_description(self.media_player, self.exc.ref()) self.exc.check() count = libvlc.libvlc_video_get_spu_count(self.media_player, self.exc.ref()) self.exc.check() first_desc = desc for i in range(0, count): self.subtitle_info....
if not item_info.item_watched:
if not item_info.item_viewed:
def _select_current(self): item_info = self.playlist[self.position] if not app.config.get(prefs.PLAY_IN_MIRO): if self.is_playing: self.stop(save_resume_time=False) # FIXME - do this to avoid "currently playing green thing. # should be a better way. self.playlist = None app.widgetapp.open_file(item_info.video_path) if ...
if not selection.containsIndex_(row):
if row != -1 and not selection.containsIndex_(row):
def handleContextMenu_(self, event): self.window().makeFirstResponder_(self) point = self.convertPoint_fromView_(event.locationInWindow(), nil) row = self.rowAtPoint_(point) selection = self.selectedRowIndexes() if not selection.containsIndex_(row): index_set = NSIndexSet.alloc().initWithIndex_(row) self.selectRowIndex...
if not server:
if not self.server:
def enable_sharing(self): name = app.config.get(prefs.SHARE_NAME) self.server = libdaap.make_daap_server(self.backend, name=name) if not server: self.sharing = False return self.thread = threading.Thread(target=self.server_thread, name='DAAP Server Thread') self.thread.start() self.sharing = True
return ngettext('%(num).0f min', '%(num).0f mins', t_min,
return ngettext('%(num).0f min', '%(num).0f mins', int(t_min),
def time_string(secs): if secs >= (60 * 60 * 24): t_dy = secs * 1.0 / (60 * 60 * 24) return ngettext('%(num).0f day', '%(num).0f days', t_dy, {"num": t_dy}) if secs >= (60 * 60): t_hr = secs * 1.0 / (60 * 60) return ngettext('%(num).0f hr', '%(num).0f hrs', t_hr, {"num": t_hr}) if secs >= 60: t_min = secs * 1.0 / 60 re...
eligibleForAutoDownload=False,
eligibleForAutoDownload=not self.initialUpdate,
def _handleNewEntry(self, entry, fp_values, channel_title): """Handle getting a new entry from a feed.""" enclosure = fp_values.first_video_enclosure if (self.url.startswith('file://') and enclosure and enclosure['url'].startswith('file://')): path = download_utils.get_file_url_path(enclosure['url']) item = models.File...
"WHERE id=?", ('gibberish', 'non.sense', 'w@h$a%t', True,
"WHERE id=?", ('{baddata', 'CANARY', '{baddata', True,
def test_corrupt_display_state(self): app.db.cursor.execute("UPDATE display_state SET " "active_filters=?, sort_state=?, columns=?, is_list_view=? " "WHERE id=?", ('gibberish', 'non.sense', 'w@h$a%t', True, self.display_state.id)) self.check_fixed_value(self.display_state, 'active_filters', None) self.check_fixed_value...
self.check_fixed_value(self.display_state, 'sort_state', None)
def test_corrupt_display_state(self): app.db.cursor.execute("UPDATE display_state SET " "active_filters=?, sort_state=?, columns=?, is_list_view=? " "WHERE id=?", ('gibberish', 'non.sense', 'w@h$a%t', True, self.display_state.id)) self.check_fixed_value(self.display_state, 'active_filters', None) self.check_fixed_value...
self.assertEquals(self.display_state.is_list_view, True)
reloaded = self.reload_object(self.display_state) self.assertEquals(reloaded.sort_state, 'CANARY') self.assertEquals(reloaded.is_list_view, True)
def test_corrupt_display_state(self): app.db.cursor.execute("UPDATE display_state SET " "active_filters=?, sort_state=?, columns=?, is_list_view=? " "WHERE id=?", ('gibberish', 'non.sense', 'w@h$a%t', True, self.display_state.id)) self.check_fixed_value(self.display_state, 'active_filters', None) self.check_fixed_value...
info = meta['info'].__dict__
info = {} if 'info' in meta: info = meta['info'].__dict__
def read_metadata(self, item): meta = mutagen.File(item.filename).__dict__ tags = None if '_DictProxy__dict' in meta['tags'].__dict__: tags = meta['tags'].__dict__['_DictProxy__dict'] else: tags = meta['tags'] info = meta['info'].__dict__ data = {} discard = ('MCDI', 'APIC') for key, value in tags.items(): if not key.s...
discard = ('MCDI', 'APIC')
discard = ('MCDI', 'APIC', 'PRIV')
def read_metadata(self, item): meta = mutagen.File(item.filename).__dict__ tags = None if '_DictProxy__dict' in meta['tags'].__dict__: tags = meta['tags'].__dict__['_DictProxy__dict'] else: tags = meta['tags'] info = meta['info'].__dict__ data = {} discard = ('MCDI', 'APIC') for key, value in tags.items(): if not key.s...
data[str(key)] = str(value)
data[unicode(key)] = unicode(value)
def read_metadata(self, item): meta = mutagen.File(item.filename).__dict__ tags = None if '_DictProxy__dict' in meta['tags'].__dict__: tags = meta['tags'].__dict__['_DictProxy__dict'] else: tags = meta['tags'] info = meta['info'].__dict__ data = {} discard = ('MCDI', 'APIC') for key, value in tags.items(): if not key.s...
data['info_', key] = str(value)
data[u'info_' + key] = unicode(value)
def read_metadata(self, item): meta = mutagen.File(item.filename).__dict__ tags = None if '_DictProxy__dict' in meta['tags'].__dict__: tags = meta['tags'].__dict__['_DictProxy__dict'] else: tags = meta['tags'] info = meta['info'].__dict__ data = {} discard = ('MCDI', 'APIC') for key, value in tags.items(): if not key.s...
if "<" not in s: return (s.strip(), [])
def strip(self, s): """Takes a string ``s`` and returns the stripped version. """ if not isinstance(s, basestring): return ("", [])
print 'query: ', query
def _calc_query(multi_url): url_list = multi_url[len("dtv:multi:"):] url_list = [urllib.unquote (x) for x in url_list.split(",")] revver_prefix = 'http://feeds.revver.com/2.0/mrss/qt/search/' for url in url_list: if url.startswith(revver_prefix): query = url[len(revver_prefix):] # the decoding gymnastics on the next li...
widgetset.Alignment.__init__(self, xalign=0.5, xscale=0.0)
widgetset.Alignment.__init__(self, xalign=0.5, xscale=0.5) self.set_padding(18)
def __init__(self, text): widgetset.Alignment.__init__(self, xalign=0.5, xscale=0.0) self.label = widgetset.Label(text) self.label.set_color((0.8, 0.8, 0.8)) self.label.set_wrap(True) self.add(self.label)
self.playbin.set_property("volume", level)
self.playbin.set_property("volume", level / MAX_VOLUME)
def set_volume(self, level): self.playbin.set_property("volume", level)
add_panel("conversions", _("Conversions"), ConversionsPanel, 'image/pref-tab-conversions.png')
add_panel("conversions", _("Conversions"), ConversionsPanel, 'images/pref-tab-conversions.png')
def build_widget(self): grid = dialogwidgets.ControlGrid() count = get_logical_cpu_count() max_concurrent = [] for i in range(0, count): max_concurrent.append((i+1, str(i+1))) max_concurrent_menu = widgetset.OptionMenu([op[1] for op in max_concurrent]) attach_combo(max_concurrent_menu, prefs.MAX_CONCURRENT_CONVERSIONS...
i2 = item.FileItem('/foo/bar.txt', feed_id=f.id)
i2 = item.FileItem(FilenameType('/foo/bar.txt'), feed_id=f.id)
def test_phantom_feed_checking(self): f = feed.Feed(u"http://feed.uk") i = item.Item(item.FeedParserValues({}), feed_id=f.id) i2 = item.FileItem('/foo/bar.txt', feed_id=f.id) self.check_object_list_fails_test([i]) self.check_fix_if_possible([i, i2], []) self.check_object_list_passes_test([i, f]) self.check_object_list_...
self.fastSeek(-1)
app.playback_manager.fast_backward() self.suspendAutoHiding()
def fastBackward_(self, sender): self.fastSeek(-1)
self.fastSeek(1) def fastSeek(self, direction): rate = 3 * direction app.playback_manager.set_playback_rate(rate)
app.playback_manager.fast_forward()
def fastForward_(self, sender): self.fastSeek(1)
self.target().fastSeek(self.direction)
self.target().suspendAutoHiding() self.fast_seek_func()
def fastSeek_(self, timer): self.target().fastSeek(self.direction) self.resetSeekTimer()
sub_path = copy_subtitle_file(sub_path, self.item_info)
sub_path = copy_subtitle_file(sub_path, self.item_info.video_path)
def select_subtitle_file(self, sub_path): sub_path = copy_subtitle_file(sub_path, self.item_info)
logging.warn("Task not in list: %s (state: %s)", msg['key'], task.state)
logging.warn("Task not in list: %s", msg['key'])
def _process_message_queue(self): try: msg = self.message_queue.get_nowait()