rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
client = TestHTTPClient('http://participatoryculture.org/democracytest/normal.txt', | client = TestHTTPClient('http://pculture.org/normal.txt', | def test_get_charset_from_response(self): client = TestHTTPClient('http://participatoryculture.org/democracytest/normal.txt', self.callback, self.errback) def get_it(content_type): if content_type: response = {'content-type': content_type} else: response = {} return client.getCharsetFromResponse(response) self.assertEq... |
self.add_request("http://participatoryculture.org/") self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("https://participatoryculture.org/") | self.add_request("http://pculture.org/") self.add_request("http://pculture.org/normalpage.txt") self.add_request("https://pculture.org/") | def test_counts(self): self.add_request("http://participatoryculture.org/") self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("https://participatoryculture.org/") self.check_counts(3, 0, 0) self.finish_connection_for_url('http://participatoryculture.org') self.check_count... |
self.finish_connection_for_url('http://participatoryculture.org') | self.finish_connection_for_url('http://pculture.org/') | def test_counts(self): self.add_request("http://participatoryculture.org/") self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("https://participatoryculture.org/") self.check_counts(3, 0, 0) self.finish_connection_for_url('http://participatoryculture.org') self.check_count... |
self.close_connection_for_url('https://participatoryculture.org/') | self.close_connection_for_url('https://pculture.org/') | def test_counts(self): self.add_request("http://participatoryculture.org/") self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("https://participatoryculture.org/") self.check_counts(3, 0, 0) self.finish_connection_for_url('http://participatoryculture.org') self.check_count... |
self.close_connection_for_url('http://participatoryculture.org/') | self.close_connection_for_url('http://pculture.org/') | def test_counts(self): self.add_request("http://participatoryculture.org/") self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("https://participatoryculture.org/") self.check_counts(3, 0, 0) self.finish_connection_for_url('http://participatoryculture.org') self.check_count... |
self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("http://participatoryculture.org/democracytest/normalpage2.txt") self.add_request("https://participatoryculture.org/democracytest/normalpage.txt") | self.add_request("http://pculture.org/normalpage.txt") self.add_request("http://pculture.org/normalpage2.txt") self.add_request("https://pculture.org/normalpage.txt") | def test_server_limit(self): self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("http://participatoryculture.org/democracytest/normalpage2.txt") self.add_request("https://participatoryculture.org/democracytest/normalpage.txt") self.check_counts(3, 0, 0) self.add_request("h... |
self.add_request("http://participatoryculture.org/democracytest/normalpage3.txt") | self.add_request("http://pculture.org/normalpage3.txt") | def test_server_limit(self): self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("http://participatoryculture.org/democracytest/normalpage2.txt") self.add_request("https://participatoryculture.org/democracytest/normalpage.txt") self.check_counts(3, 0, 0) self.add_request("h... |
self.pool.assertConnectionNotStarted('http://participatoryculture.org/democracytest/normalpage3.txt') self.finish_connection_for_url("http://participatoryculture.org/democracytest/normalpage.txt") | self.pool.assertConnectionNotStarted('http://pculture.org/normalpage3.txt') self.finish_connection_for_url("http://pculture.org/normalpage.txt") | def test_server_limit(self): self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("http://participatoryculture.org/democracytest/normalpage2.txt") self.add_request("https://participatoryculture.org/democracytest/normalpage.txt") self.check_counts(3, 0, 0) self.add_request("h... |
self.finish_connection_for_url("http://participatoryculture.org/democracytest/normalpage2.txt") self.pool.assertConnectionStarted('http://participatoryculture.org/democracytest/normalpage3.txt') | self.finish_connection_for_url("http://pculture.org/normalpage2.txt") self.pool.assertConnectionStarted('http://pculture.org/normalpage3.txt') | def test_server_limit(self): self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("http://participatoryculture.org/democracytest/normalpage2.txt") self.add_request("https://participatoryculture.org/democracytest/normalpage.txt") self.check_counts(3, 0, 0) self.add_request("h... |
self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("http://participatoryculture.org/democracytest/normalpage2.txt") | self.add_request("http://pculture.org/normalpage.txt") self.add_request("http://pculture.org/normalpage2.txt") | def test_total_limit(self): self.add_request("http://participatoryculture.org/democracytest/normalpage.txt") self.add_request("http://participatoryculture.org/democracytest/normalpage2.txt") self.add_request("http://www.bar.com/") self.add_request("http://www.bar.com/2") self.add_request("http://www.baz.com/") self.add... |
self.add_request("http://participatoryculture.org/") self.add_request("http://participatoryculture.org/2") self.add_request("http://participatoryculture.org/3") | self.add_request("http://pculture.org/") self.add_request("http://pculture.org/2") self.add_request("http://pculture.org/3") | def test_both_limits(self): # This test is kind of pointless now, but I can't see a way to # test it as well as before. self.add_request("http://participatoryculture.org/") self.add_request("http://participatoryculture.org/2") self.add_request("http://participatoryculture.org/3") self.check_counts(2, 0, 1) self.pool.as... |
self.pool.assertConnectionNotStarted('http://participatoryculture.org/3') | self.pool.assertConnectionNotStarted('http://pculture.org/3') | def test_both_limits(self): # This test is kind of pointless now, but I can't see a way to # test it as well as before. self.add_request("http://participatoryculture.org/") self.add_request("http://participatoryculture.org/2") self.add_request("http://participatoryculture.org/3") self.check_counts(2, 0, 1) self.pool.as... |
self.pool.assertConnectionNotStarted('http://participatoryculture.org/3') self.finish_connection_for_url('http://participatoryculture.org/') | self.pool.assertConnectionNotStarted('http://pculture.org/3') self.finish_connection_for_url('http://pculture.org/') | def test_both_limits(self): # This test is kind of pointless now, but I can't see a way to # test it as well as before. self.add_request("http://participatoryculture.org/") self.add_request("http://participatoryculture.org/2") self.add_request("http://participatoryculture.org/3") self.check_counts(2, 0, 1) self.pool.as... |
self.add_request("http://participatoryculture.org/") | self.add_request("http://pculture.org/") | def test_drop_the_lru(self): # Check that the first connection dropped when we run out of # connections is the least recently used self.add_request("http://www.baz.com/") self.add_request("http://participatoryculture.org/") self.add_request("http://www.bar.com/") self.add_request("http://www.froz.com/") self.finish_con... |
httpclient.grabURL('https://www.gibill.va.gov/wave/', self.callback, self.errback, | httpclient.grabURL('https://pculture.org/secure.txt', self.callback, self.errback, | def test_grab_url(self): # this is faking things since we're using our TestHTTPClient httpclient.grabURL('https://www.gibill.va.gov/wave/', self.callback, self.errback, clientClass=TestHTTPClient) self.runEventLoop() self.assertEquals(self.data['status'], 200) self.assert_(self.callbackCalled) |
url = 'http://participatoryculture.org/democracytest/normalpage.txt' httpclient.grabURL(url, self.callback, self.errback, | url = 'http://pculture.org/normalpage.txt' httpclient.grabURL(url, self.callback, self.errback, | def test_start(self): url = 'http://participatoryculture.org/democracytest/normalpage.txt' httpclient.grabURL(url, self.callback, self.errback, clientClass=TestHTTPClient) self.runEventLoop() self.orig_data = self.data httpclient.grabURL(url, self.callback, self.errback, start=4, clientClass=TestHTTPClient) self.runEve... |
class EtagTest(AsyncSocketTest): def test_etag(self): url = 'http://pculture.org/etag.txt' httpclient.grabURL(url, self.callback, self.errback, clientClass=TestHTTPClient) self.runEventLoop() etag = self.data['etag'] httpclient.grabURL(url, self.callback, self.errback, etag=etag, clientClass=TestHTTPClient) self.run... | # def testEtag(self): | |
def testScheme(self): url = 'participatoryculture.org/democracytest/normalpage.txt' httpclient.grabURL(url, self.callback, self.errback, clientClass=TestHTTPClient) | def test_scheme(self): url = 'pculture.org/normalpage.txt' httpclient.grabURL(url, self.callback, self.errback, clientClass=TestHTTPClient) | def testScheme(self): url = 'participatoryculture.org/democracytest/normalpage.txt' httpclient.grabURL(url, self.callback, self.errback, clientClass=TestHTTPClient) self.runPendingIdles() self.assertEquals(self.errbackCalled, True) self.assertEquals(self.callbackCalled, False) |
def testSlashes(self): | def test_slashes(self): | def testSlashes(self): url = 'http:jigsaw.w3.org/HTTP/' httpclient.grabURL(url, self.callback, self.errback, clientClass=TestHTTPClient) self.runPendingIdles() self.assertEquals(self.errbackCalled, True) self.assertEquals(self.callbackCalled, False) |
def testHost(self): | def test_host(self): | def testHost(self): url = 'http:///HTTP/' httpclient.grabURL(url, self.callback, self.errback, clientClass=TestHTTPClient) self.runPendingIdles() self.assertEquals(self.errbackCalled, True) self.assertEquals(self.callbackCalled, False) |
def testOtherScheme(self): | def test_other_scheme(self): | def testOtherScheme(self): url = 'rtsp://jigsaw.w3.org/' httpclient.grabURL(url, self.callback, self.errback, clientClass=TestHTTPClient) self.runPendingIdles() self.assertEquals(self.errbackCalled, True) self.assertEquals(self.callbackCalled, False) |
class SocketCallbackTest(EventLoopTest): def setUp(self): EventLoopTest.setUp(self) def make_socket(self): sock = socket.socket() sock.connect(('pculture.org', 80)) return sock | def testOtherScheme(self): url = 'rtsp://jigsaw.w3.org/' httpclient.grabURL(url, self.callback, self.errback, clientClass=TestHTTPClient) self.runPendingIdles() self.assertEquals(self.errbackCalled, True) self.assertEquals(self.callbackCalled, False) | |
def test_remove_then_add(self): """Test adding a write callback right after we remove one. This case isn't so bad actually, the really bad case (which I don't know how to simulate, is if we closed s2, then made a new socket, s3 that had the same fileno as s2 used to have. """ s1 = self.make_socket() s2 = self.make_sock... | # def testRemoveThenAdd(self): | |
def testCookieExpirationDate(self): """Tests get_cookie_expiration_date to make sure it's returning sane values and handles cookie expiration formats we've had problems with. | def test_cookie_expiration_date(self): """Tests get_cookie_expiration_date to make sure it's returning sane values and handles cookie expiration formats we've had problems with. | def testCookieExpirationDate(self): """Tests get_cookie_expiration_date to make sure it's returning sane values and handles cookie expiration formats we've had problems with. """ from time import mktime, strptime, localtime from miro.httpclient import get_cookie_expiration_date |
for cd in ( ("Thu, 03-May-07 22:48:52 GMT", "2007-05-03 22:48:52 GMT"), ("Fri, 03-Jun-11 13:41:15 GMT", "2011-06-03 13:41:15 GMT"), ("Sun, 17-Jan-2038 19:14:07 GMT", "2038-01-17 19:14:07 GMT"), ("Mon, 09-Apr-07 23:50:49 GMT", "2007-04-09 23:50:49 GMT"), ("Tue, 01-Jan-2030 10:00:00 GMT", "2030-01-01 10:00:00 GMT"), ("Tu... | for cd in [("Thu, 03-May-07 22:48:52 GMT", "2007-05-03 22:48:52 GMT"), ("Fri, 03-Jun-11 13:41:15 GMT", "2011-06-03 13:41:15 GMT"), ("Sun, 17-Jan-2038 19:14:07 GMT", "2038-01-17 19:14:07 GMT"), ("Mon, 09-Apr-07 23:50:49 GMT", "2007-04-09 23:50:49 GMT"), ("Tue, 01-Jan-2030 10:00:00 GMT", "2030-01-01 10:00:00 GMT"), ("Tue... | def testCookieExpirationDate(self): """Tests get_cookie_expiration_date to make sure it's returning sane values and handles cookie expiration formats we've had problems with. """ from time import mktime, strptime, localtime from miro.httpclient import get_cookie_expiration_date |
self.assertEquals( localtime(get_cookie_expiration_date("Tue, 26-Jul-2050 10:00:00 GMT")), localtime(httpclient.DATEINFUTURE) ) | dt = "Tue, 26-Jul-2050 10:00:00 GMT" self.assertEquals(localtime(get_cookie_expiration_date(dt)), localtime(httpclient.DATEINFUTURE)) | def testOverflowCookieExpirationDate(self): """tests the case of get_cookie_expiration_date where the cookie expiration date causes an overflow error when parsing it. """ if sys.maxint > 2**31-1: # this test can't be executed on 64 bit systems return from time import localtime from miro.httpclient import get_cookie_exp... |
self.playbin.set_property("text-sink", self.textsink) | try: self.playbin.set_property("text-sink", self.textsink) except TypeError: logging.warning("this platform has an old version of playbin2--no subtitle support.") self.supports_subtitles = False | def build_playbin(self): Renderer.build_playbin(self) self.watch_ids.append(self.bus.connect('sync-message::element', self.on_sync_message)) self.playbin.set_property("video-sink", self.videosink) self.playbin.set_property("text-sink", self.textsink) |
if sub_filename != "": | if sub_filename != "" and self.supports_subtitles: | def select_file(self, filename, callback, errback, sub_filename=""): Renderer.select_file(self, filename, callback, errback, sub_filename) if sub_filename != "": self.pick_subtitle_track = 0 |
if hasattr(self, "pick_subtitle_track"): | if hasattr(self, "pick_subtitle_track") and self.supports_subtitles: | def finish_select_file(self): Renderer.finish_select_file(self) if hasattr(self, "pick_subtitle_track"): flags = self.playbin.get_property('flags') self.playbin.set_properties(flags=flags | GST_PLAY_FLAG_TEXT, current_text=0) del self.__dict__["pick_subtitle_track"] return |
if config.get(prefs.ENABLE_SUBTITLES): | if config.get(prefs.ENABLE_SUBTITLES) and self.supports_subtitles: | def finish_select_file(self): Renderer.finish_select_file(self) if hasattr(self, "pick_subtitle_track"): flags = self.playbin.get_property('flags') self.playbin.set_properties(flags=flags | GST_PLAY_FLAG_TEXT, current_text=0) del self.__dict__["pick_subtitle_track"] return |
if not self.playbin: | if not self.playbin or not self.supports_subtitles: | def get_subtitles(self): """Returns a dict of index -> (language, filename) for available tracks. """ if not self.playbin: return {} |
data_files.append(('', iglob(os.path.join(VCREDIST71_PATH, '*')))) | def fill_template(templatepath, outpath, **vars): s = open(templatepath, 'rt').read() s = string.Template(s).safe_substitute(**vars) f = open(outpath, "wt") f.write(s) f.close() | |
return False | return True | def isSystemDLL(pathname): if os.path.basename(pathname).lower() in DLLS_TO_INCLUDE: return False else: return origIsSystemDLL(pathname) |
"(is_file_item OR " | "((is_file_item AND NOT deleted) OR " | def newly_downloaded_view(cls): return cls.make_view("NOT item.seen AND " "(item.file_type != 'other') AND " "(is_file_item OR " "rd.state in ('finished', 'uploading', 'uploading-paused'))", joins={'remote_downloader AS rd': 'item.downloader_id=rd.id'}) |
if "_" in value: | if hasattr(value, '__iter__') and "_" in value: | def find(value, key=None): """For a given language code value, returns the language name. >>> find('en') {'alpha2': 'en', 'alpha3': 'eng', 'name': u'English'} >>> find('foo', THREE_LETTERS_CODE) None :param value: language code value. example: 'en' :param key: either None, ``TWO_LETTER_CODE`` or ``THREE_LETTERS_COD... |
if not self.playlist[self.postion].item_watched: | if not self.playlist[self.position].item_viewed: | def _on_ready_to_play(self, obj): self.open_finished = True if not self.playlist[self.postion].item_watched: self.schedule_mark_as_watched(self.playlist[self.position].id) if isinstance(self.player, widgetset.VideoPlayer): self.player.select_subtitle_encoding(self.initial_subtitle_encoding) self.play() |
top_pad=10, left_pad=20, bottom_pad=10), expand=True) | top_pad=10, bottom_pad=10, left_pad=20), expand=True) | def __init__(self): DisplayToolbar.__init__(self) |
first_label.set_size_request(max(width1, width2), -1) | first_label.set_size_request(width1, -1) | def __init__(self): DisplayToolbar.__init__(self) |
h.pack_start(widgetutil.align_right(self._first_label, left_pad=10, top_pad=10, bottom_pad=10, right_pad=10)) | h.pack_start(widgetutil.align_middle(widgetutil.align_right( self._first_label, right_pad=20))) second_image = widgetutil.HideableWidget(widgetset.ImageDisplay( widgetset.Image(resources.path('images/down.png')))) self._second_image = second_image h.pack_start(widgetutil.align_middle(widgetutil.align_right( self._seco... | def __init__(self): DisplayToolbar.__init__(self) |
second_label.set_size_request(max(width1, width2), -1) | second_label.set_size_request(width2, -1) | def __init__(self): DisplayToolbar.__init__(self) |
h.pack_start(widgetutil.align_right(self._second_label, top_pad=10, bottom_pad=10, right_pad=20, left_pad=10)) | h.pack_start(widgetutil.align_middle(widgetutil.align_right( self._second_label, right_pad=20))) | def __init__(self): DisplayToolbar.__init__(self) |
if text_up and text_down: self._first_label.set_text(text_down) self._second_label.set_text(text_up) elif text_up: self._first_label.set_text(text_up) self._second_label.set_text('') elif text_down: self._first_label.set_text(text_down) self._second_label.set_text('') | self._first_label.set_text(text_up) self._second_label.set_text(text_down) if text_up: self._first_image.show() | def update_rates(self, down_bps, up_bps): text_up = text_down = '' if up_bps >= 10: text_up = _("%(rate)s uploading", {"rate": displaytext.download_rate(up_bps)}) if down_bps >= 10: text_down = _("%(rate)s downloading", {"rate": displaytext.download_rate(down_bps)}) |
self._first_label.set_text('') self._second_label.set_text('') | self._first_image.hide() if text_down: self._second_image.show() else: self._second_image.hide() | def update_rates(self, down_bps, up_bps): text_up = text_down = '' if up_bps >= 10: text_up = _("%(rate)s uploading", {"rate": displaytext.download_rate(up_bps)}) if down_bps >= 10: text_down = _("%(rate)s downloading", {"rate": displaytext.download_rate(down_bps)}) |
self.detached_window = DetachedWindow("", detached_window_frame) | title = self.playlist[self.position].name self.detached_window = DetachedWindow(title, detached_window_frame) | def prepare_detached_playback(self): self.emit('will-play-detached') detached_window_frame = config.get(prefs.DETACHED_WINDOW_FRAME) if detached_window_frame is None: detached_window_frame = widgetset.Rect(0, 0, 800, 600) else: detached_window_frame = widgetset.Rect.from_string(detached_window_frame) self.detached_wind... |
('list_view_column_widths', SchemaDict(SchemaString(), SchemaInt())), | ('list_view_column_widths', SchemaDict(SchemaString(), SchemaInt(), noneOk=True)), | def handle_malformed_pastThemes(row): return [] |
s.write(*args) | try: s.write(*args) except IOError: pass | def write(self, *args): for s in self.streams: s.write(*args) self.flush() |
s.flush() | try: s.flush() except IOError: pass | def flush(self): for s in self.streams: s.flush() |
return self.status.get('filename', FilenameType('')) | return FilenameType(self.status.get('filename', '')) | def get_filename(self): """Returns the filename that we're downloading to. Should not be called until state is "finished." """ self.confirm_db_thread() # FIXME - FilenameType('') is a bogus value, but looks like a # filename. should return None. return self.status.get('filename', FilenameType('')) |
def show_auto_tab(self, name, count): if count > 0 and name in self.auto_tabs: try: tab = self.get_tab(name) except KeyError, e: self.add(self.auto_tabs[name]) | def update_auto_tab_count(self, name, count): if count > 0: self.auto_tabs_to_show.add(name) self.show_auto_tab(name) else: self.auto_tabs_to_show.discard(name) self.remove_auto_tab_if_not_selected(name) def show_auto_tab(self, name): try: tab = self.get_tab(name) except KeyError, e: self.add(self.auto_tabs[name]) | def show_auto_tab(self, name, count): if count > 0 and name in self.auto_tabs: try: tab = self.get_tab(name) except KeyError, e: self.add(self.auto_tabs[name]) |
def hide_auto_tab(self, name, count): if count == 0 and name in self.auto_tabs: self.remove(name) | def remove_auto_tab_if_not_selected(self, name): if name not in self.iter_map: return for iter in self.view.get_selection(): info = self.view.model[iter][0] if info.id == name: return self.remove(name) def on_selection_changed(self, view): for name in self.auto_tabs: if name in self.iter_map and name not in self.auto... | def hide_auto_tab(self, name, count): if count == 0 and name in self.auto_tabs: self.remove(name) |
self.show_auto_tab(key, count+other_count) | if key in self.auto_tabs: self.update_auto_tab_count(key, count+other_count) | def update_count(self, key, attr, count, other_count=0): self.show_auto_tab(key, count+other_count) try: iter = self.iter_map[key] except KeyError, e: pass else: tab = self.view.model[iter][0] setattr(tab, attr, count) self.view.update_tab(iter, tab) self.hide_auto_tab(key, count+other_count) self.view.model_changed() |
self.hide_auto_tab(key, count+other_count) | def update_count(self, key, attr, count, other_count=0): self.show_auto_tab(key, count+other_count) try: iter = self.iter_map[key] except KeyError, e: pass else: tab = self.view.model[iter][0] setattr(tab, attr, count) self.view.update_tab(iter, tab) self.hide_auto_tab(key, count+other_count) self.view.model_changed() | |
if YOUTUBE_URL_PATTERN.match(self.url): titleMatch = YOUTUBE_TITLE_PATTERN.match(channelTitle) if titleMatch: channelTitle = titleMatch.groups('name')[0] elif REVVER_URL_PATTERN.match(self.url): channelTitle = channelTitle.encode("iso-8859-1") channelTitle = channelTitle.decode("utf-8") | def _createItemsForParsed(self, parsed): # This is a HACK for Yahoo! search which doesn't provide # enclosures for entry in parsed['entries']: if 'enclosures' not in entry: try: url = entry['link'] except KeyError: continue mimetype = filetypes.guess_mime_type(url) if mimetype is not None: entry['enclosures'] = [{'url'... | |
self.prevent_system_sleep(True) | self.prevent_system_sleep(False) | def pause(self): threads.warn_if_not_on_main_thread('VideoPlayer.pause') self.video_view.pause_(nil) self.prevent_system_sleep(True) |
return _uses_httpclient | return functools.update_wrapper(_uses_httpclient, fun) | def _uses_httpclient(*args, **kwargs): httpclient.start_thread() try: return fun(*args, **kwargs) finally: httpclient.stop_thread() |
for row in item.Item.select('filename', 'filename IS NOT NULL AND filename LIKE ?', (path,)): if samefile(row[0], path): return True | for item_ in item.Item.make_view('filename LIKE ?', (path,)): if samefile(item_.filename, path): return item_ | def _item_exists_for_path(path): # in SQLite, LIKE is case insensitive, so we can use it to only look at # filenames that possibly will match for row in item.Item.select('filename', 'filename IS NOT NULL AND filename LIKE ?', (path,)): if samefile(row[0], path): return True return False |
if _item_exists_for_path(path): | item_for_path = _item_exists_for_path(path) if item_for_path: | def add_video(path, manual_feed=None): path = os.path.abspath(path) if _item_exists_for_path(path): logging.warn("Not adding duplicate video: %s", path.decode('ascii', 'ignore')) if _command_line_videos is not None: item_ = item.Item.make_view('filename=?', (path,)).get_singleton() _command_line_videos.add(item_) retur... |
item_ = item.Item.make_view('filename=?', (path,)).get_singleton() _command_line_videos.add(item_) | _command_line_videos.add(item_for_path) | def add_video(path, manual_feed=None): path = os.path.abspath(path) if _item_exists_for_path(path): logging.warn("Not adding duplicate video: %s", path.decode('ascii', 'ignore')) if _command_line_videos is not None: item_ = item.Item.make_view('filename=?', (path,)).get_singleton() _command_line_videos.add(item_) retur... |
data = '0' * (100 * 1024) | data = '0' * (1000 * 1024) | def test_upload_progress(self): # upload a 100k file data = '0' * (100 * 1024) f1 = {'filename': 'testing.txt', 'mimetype': 'text/plain', 'handle': StringIO(data), } self.event_loop_timeout = 5 progress_stats = [] |
self.assertEquals(progress.uploaded, 0) | self.assertEquals(progress.uploaded, -1) eventloop.add_timeout(TIMEOUT, check_upload_progress, 'upload progress timeout') | def check_upload_progress(): progress = self.client.get_stats() if progress.upload_total == -1: # client didn't know the total upload at this point. self.assertEquals(progress.uploaded, 0) return self.saw_total = True |
eventloop.add_timeout(0.5, check_upload_progress, | eventloop.add_timeout(TIMEOUT, check_upload_progress, | def check_upload_progress(): progress = self.client.get_stats() if progress.upload_total == -1: # client didn't know the total upload at this point. self.assertEquals(progress.uploaded, 0) return self.saw_total = True |
if info.video_watched: | if info.device: device.append(info) elif info.video_watched: | def _make_context_menu_multiple(self, selection): """Make the context menu for multiple items.""" watched = [] unwatched = [] downloaded = [] downloading = [] available = [] paused = [] uploadable = [] expiring = [] for info in selection: if info.downloaded: downloaded.append(info) if info.video_watched: watched.append... |
menu.append((ngettext('%(count)d Downloaded Item', '%(count)d Downloaded Items', len(downloaded), {"count": len(downloaded)}), None)) | if device: menu.append((ngettext('%(count)d Device Item', '%(count)d Device Items', len(downloaded), {"count": len(downloaded)}), None)) else: menu.append((ngettext('%(count)d Downloaded Item', '%(count)d Downloaded Items', len(downloaded), {"count": len(downloaded)}), None)) | def _make_context_menu_multiple(self, selection): """Make the context menu for multiple items.""" watched = [] unwatched = [] downloaded = [] downloading = [] available = [] paused = [] uploadable = [] expiring = [] for info in selection: if info.downloaded: downloaded.append(info) if info.video_watched: watched.append... |
menu.append((_('Add to Playlist'), app.widgetapp.add_to_playlist)) | if not device: menu.append((_('Add to Playlist'), app.widgetapp.add_to_playlist)) | def _make_context_menu_multiple(self, selection): """Make the context menu for multiple items.""" watched = [] unwatched = [] downloaded = [] downloading = [] available = [] paused = [] uploadable = [] expiring = [] for info in selection: if info.downloaded: downloaded.append(info) if info.video_watched: watched.append... |
menu.append(None) convert_menu = self._make_convert_menu() menu.append((_('Convert to...'), convert_menu)) | if not device: menu.append(None) convert_menu = self._make_convert_menu() menu.append((_('Convert to...'), convert_menu)) | def keep_videos(): for item in expiring: if item.expiration_date: messages.KeepVideo(item.id).send_to_backend() |
def select_subtitle_file(self, path): res = libvlc.libvlc_video_set_subtitle_file( self.media_player, path, self.exc.ref()) | def select_subtitle_file(self, item, path): path = path.encode('utf-8') res = libvlc.libvlc_video_set_subtitle_file(self.media_player, ctypes.c_char_p(path), self.exc.ref()) | def select_subtitle_file(self, path): res = libvlc.libvlc_video_set_subtitle_file( self.media_player, path, self.exc.ref()) try: self.exc.check() except VLCError, e: logging.warn("exception when setting subtitle track to file: %s", e) |
title = os.path.basename(input_path) title, ext = os.path.splitext(title) | title = basename | 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... |
full_target_name = os.path.join(target_folder, target_name) return (full_target_name, os.path.join(temp_dir, target_name)) | final_path = utils.FilenameType(os.path.join(target_folder, target_name)) temp_path = os.path.join(temp_dir, basename) return (final_path, temp_path) | 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... |
if self.get_state() in (u'uploading'): | if self.get_state() == u'uploading': | def restart_on_startup_if_needed(self): if not self.id_exists(): return if _downloads.has_key(self.dlid): # something has caused us to restart already, (for # example, the user selects "resume seeding"). squelch # any automatic behaviour (#12462) return if self.get_state() in (u'downloading', u'offline'): self.restart... |
if drag_source is None: self.data_source.setDragSource_(None) else: self.data_source.setDragSource_(drag_source) | self.data_source.setDragSource_(drag_source) | def set_drag_source(self, drag_source): self.drag_source = drag_source if drag_source is None: self.data_source.setDragSource_(None) else: self.data_source.setDragSource_(drag_source) |
self.ufeed.invalidate_counts() | self.ufeed.recalc_counts() | def update_finished(self): """ Called by subclasses to finish the update. """ if self.initialUpdate: self.initialUpdate = False startfrom = None itemToUpdate = None for latest in models.Item.latest_in_feed_view(self.ufeed_id): latest.eligibleForAutoDownload = True latest.signal_change() if self.ufeed.is_autodownloadabl... |
self.ufeed.signal_change(needs_save=False) | def feedparser_finished(self): self.updating = False self.ufeed.signal_change(needs_save=False) self.schedule_update_events(-1) | |
self.update_finished() | def feedparser_callback(self, parsed): self.ufeed.confirm_db_thread() if not self.ufeed.id_exists(): return if len(parsed.entries) == len(parsed.feed) == 0: logging.warn("Empty feed, not updating: %s", self.url) self.feedparser_finished() return start = clock() parsed = self.parsed = unicodify(parsed) self.remember_old... | |
requestURL = self.url.replace(u"%s", urlencode(query)) requestURL = requestURL.replace(u"%a", unicode(int(not filterAdultContents))) requestURL = requestURL.replace(u"%l", unicode(int(limit))) return requestURL | request_url = self.url.replace(u"%s", urlencode(query)) request_url = request_url.replace(u"%a", unicode(int(not filterAdultContents))) request_url = request_url.replace(u"%l", unicode(int(limit))) return request_url | def get_request_url(self, query, filterAdultContents, limit): """Returns the request url expanding the query, filter adult content, and results limit place holders. """ requestURL = self.url.replace(u"%s", urlencode(query)) requestURL = requestURL.replace(u"%a", unicode(int(not filterAdultContents))) requestURL = reque... |
someVariable = intentionallyUndefinedVariableToTestCrashReporter return u"" | raise IntentionalCrash("intentional error here") | def get_request_url(engine_name, query, filter_adult_contents=True, limit=50): """Returns the url for the given search engine, query, filter_adult_contents, and limit. There are two "magic" queries: * ``LET'S TEST DTV'S CRASH REPORTER TODAY`` which rases a NameError thus allowing us to test the crash reporter * ``LE... |
def select_subtitle_file(self, item, path): path = path.encode('utf-8') | def select_subtitle_file(self, item, sub_path): sub_path = sub_path.encode('utf-8') try: sub_path = copy_subtitle_file(sub_path, item.video_path) except WindowsError: logging.exception("exception thrown when copying subtitle file") | def select_subtitle_file(self, item, path): path = path.encode('utf-8') res = libvlc.libvlc_video_set_subtitle_file( self.media_player, ctypes.c_char_p(path), self.exc.ref()) try: self.exc.check() except VLCError, e: logging.warn("exception when setting subtitle track to file: %s", e) else: self.setup_subtitles() |
self.media_player, ctypes.c_char_p(path), self.exc.ref()) | self.media_player, ctypes.c_char_p(sub_path), self.exc.ref()) | def select_subtitle_file(self, item, path): path = path.encode('utf-8') res = libvlc.libvlc_video_set_subtitle_file( self.media_player, ctypes.c_char_p(path), self.exc.ref()) try: self.exc.check() except VLCError, e: logging.warn("exception when setting subtitle track to file: %s", e) else: self.setup_subtitles() |
self.truncate_old_items() del self.old_items | if hasattr(self, "old_items"): self.truncate_old_items() del self.old_items | def update_finished(self): """ Called by subclasses to finish the update. """ if self.initialUpdate: self.initialUpdate = False startfrom = None itemToUpdate = None for latest in models.Item.latest_in_feed_view(self.ufeed_id): latest.eligibleForAutoDownload = True latest.signal_change() if self.ufeed.is_autodownloadabl... |
return 4 | return (4, item.expiration_date) | def sort_key(self, item): if item.state == 'downloading': return 2 # downloading elif item.downloaded and not item.video_watched: return 3 # unwatched elif item.expiration_date: return 4 # expiring elif not item.item_viewed: return 0 # new else: return 1 # other |
self.runPendingIdles() | app.db.finish_transaction() | def test_commit_without_close(self): # we should commit using an idle callback. self.runPendingIdles() # close the database connection without giving LiveStorage the # oppertunity to commit when it's closed. app.db.connection.close() app.db = storedatabase.LiveStorage(self.save_path, schema_version=0, object_schemas=se... |
raise AssertionError("Ben's Phoney Error") | def upgrade_database(self): """Run any database upgrades that haven't been run.""" try: raise AssertionError("Ben's Phoney Error") self._upgrade_database() except (KeyError, SystemError, databaseupgrade.DatabaseTooNewError): raise except Exception, e: logging.exception('error when upgrading database: %s', e) self._hand... | |
if len(sys.argv) < 2: | if len(sys.argv) < 3: | def make_snapshot(video_path, thumbnail_path): if os.path.exists(thumbnail_path): os.remove(thumbnail_path) if isinstance(video_path, unicode): video_path = video_path.encode("utf-8") video_path = urllib.quote(video_path) mrl = 'file:///%s' % video_path vlc = init_vlc( "vlc", "--noaudio", '--vout', 'dummy', '--no-vi... |
print 'adding', info.name | def device_connected(self, id_, **kwargs): if id_ in self.connected: raise RuntimeError('device_connected() called on connected device') | |
"active_filters=?, sort_state=?, columns=?", (self.display_state.id, 'gibberish', 'nonsense', 'what')) | "active_filters=?, sort_state=?, columns=? " "WHERE id=?", ('gibberish', 'non.sense', 'w@h$a%t', self.display_state.id)) | def test_corrupt_display_state(self): app.db.cursor.execute("UPDATE display_state SET " "active_filters=?, sort_state=?, columns=?", (self.display_state.id, 'gibberish', 'nonsense', 'what')) self.check_fixed_value(self.display_state, 'active_filters', None) self.check_fixed_value(self.display_state, 'sort_state', None)... |
def get_parameters(self): parameters = VideoConversionTask.get_parameters(self) parameters.insert(0, "-y") return parameters | def get_parameters(self): parameters = VideoConversionTask.get_parameters(self) parameters.insert(0, "-y") return parameters | |
if rv is None: | if not rv: | def _calc_raw_description(self): rv = None try: if hasattr(self.first_video_enclosure, "text"): rv = self.first_video_enclosure["text"] elif hasattr(self.entry, "description"): rv = self.entry.description except Exception: logging.exception("_calc_raw_description threw exception:") if rv is None: return u'' else: retur... |
return None | return u'' | def get_raw_description(self): """Returns the raw description of the video (unicode). """ if self.raw_descrption: if self.is_downloaded_torrent(): return (_('Contents appear in the library') + '<BR>' + self.raw_descrption) else: return self.raw_descrption elif self.is_external() and self.is_downloaded_torrent(): lines ... |
gtk.DrawingArea.do_configure_event(self, event) | def do_configure_event(self, event): self.persistent_window.resize(event.width, event.height) gtk.DrawingArea.do_configure_event(self, event) | |
if utils.getMajorOSVersion() == 8: | if utils.getMajorOSVersion() < 10: | def extractThumbnail(qtmovie, target, width=0, height=0): try: qttime = qtmovie.duration() qttime = utils.qttimevalue_set(qttime, int(utils.qttimevalue(qttime) * 0.5)) frame = qtmovie.frameImageAtTime_(qttime) if frame is objc.nil: return "Failure" frameSize = frame.size() if frameSize.width == 0 or frameSize.height =... |
view = PlaylistItemMap.playlist_view(playlist_id) | view = item.Item.playlist_view(playlist_id) | def handle_device_sync_feeds(self, message): items = set() for video_id in message.video_ids: feed_ = feed.Feed.get_by_id(video_id) if message.video_type == 'all': view = feed_.downloaded_items else: view = feed_.unwatched_items for item_ in view: items.add(item_) |
muta = mutagen.File(item.filename) | muta = mutagen.File(item.get_filename()) | def read_metadata(self, item): VIDEO_EXTENSIONS = ('.m4v','.mp4') mediatype = None duration = -1 tags = {} info = {} data = {} |
if os.path.splitext(item.filename)[1].lower() in VIDEO_EXTENSIONS: | if os.path.splitext( item.get_filename())[1].lower() in VIDEO_EXTENSIONS: | def read_metadata(self, item): VIDEO_EXTENSIONS = ('.m4v','.mp4') mediatype = None duration = -1 tags = {} info = {} data = {} |
self.select_subtitle_file(self.iteminfo, filename) | pos = self.get_current_time() def select_success(): self.set_current_time(pos) self.play() self.select_subtitle_file(self.iteminfo, filename, select_success) | def enable_subtitle_track(self, track_index): tracks = self.get_subtitles() if tracks.get(track_index) is None: return |
if self._sort_name_to_column['name'] is not column: return None info = self.item_list.model[iter][0] if info.description_text: text = info.description_text if len(text) > 1000: text = text[:994] + ' [...]' return text else: return None | if column == self._sort_name_to_column['name']: info = self.item_list.model[iter][0] if info.description_text: text = info.description_text if len(text) > 1000: text = text[:994] + ' [...]' return text elif column == self._sort_name_to_column['state']: info = self.item_list.model[iter][0] if info.state == 'downloadi... | def get_tooltip(self, iter, column): if self._sort_name_to_column['name'] is not column: return None info = self.item_list.model[iter][0] if info.description_text: text = info.description_text if len(text) > 1000: text = text[:994] + ' [...]' return text else: return None |
app.application.quit() | app.widgetapp.quit() | def on_delete(self, widget, event): app.application.quit() return True |
self.select_callbacks[1]() self.select_callbacks = None | self.invoke_select_callback(success=False) | def on_bus_message(self, bus, message): """receives message posted on the GstBus""" if message.src is not self.playbin: return |
logging.error("on_bus_message: gstreamer error: %s", err) | logging.error("on_bus_message (after callbacks): gstreamer error: %s", err) | def on_bus_message(self, bus, message): """receives message posted on the GstBus""" if message.src is not self.playbin: return |
self.select_callbacks[0]() self.select_callbacks = None | self.invoke_select_callback(success=True) | def on_bus_message(self, bus, message): """receives message posted on the GstBus""" if message.src is not self.playbin: return |
messages.ItemList(self.type, self.id, infos).send_to_frontend() | messages.ItemList(self.type, self.tab, infos).send_to_frontend() | def send_initial_list(self): infos = self.tracker.get_items() messages.ItemList(self.type, self.id, infos).send_to_frontend() |
_command_line_videos.add(i) | item_ = item.Item.make_view('filename=?', (path,)).get_singleton() _command_line_videos.add(item_) | def add_video(path, manual_feed=None): path = os.path.abspath(path) if _item_exists_for_path(path): logging.warn("Not adding duplicate video: %s", path.decode('ascii', 'ignore')) if _command_line_videos is not None: _command_line_videos.add(i) return if manual_feed is None: manual_feed = feed.Feed.get_manual_feed() fil... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.