rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
for name in enabled_columns: | for name in display_columns: | def __init__(self, item_list, enabled_columns, column_widths, display_channel=True, display_download_info=True): widgetset.TableView.__init__(self, item_list.model) self.display_channel = display_channel self.display_download_info = display_download_info self.enabled_columns = enabled_columns self.create_signal('sort-c... |
self.tempdir = tempfile.mkdtemp() | self.tempdir = FilenameType(tempfile.mkdtemp()) | def setUp(self): MiroTestCase.setUp(self) self.feed = Feed(u'dtv:manualFeed', initiallyAutoDownloadable=False) self.tempdir = tempfile.mkdtemp() self._make_fake_item("pcf.mpeg") self._make_fake_item("dean.avi") self._make_fake_item("npr.txt") self.container_item = FileItem(self.tempdir, self.feed.id) |
self.show_controls() | show_it_all = False if event is None: show_it_all = True else: if app.playback_manager.detached_window is not None: gtkwindow = app.playback_manager.detached_window._window else: gtkwindow = app.widgetapp.window._window gdkwindow = gtkwindow.window screen = gtkwindow.get_screen() monitor = screen.get_monitor_at_win... | def on_mouse_motion(self, widget, event): if not self.overlay: return if not self.overlay.is_visible(): self.show_controls() self.schedule_hide_controls(self.HIDE_CONTROLS_TIMEOUT) else: self.last_motion_time = time.time() |
_window().window.set_cursor(None) | logging.info("show_controls") self.show_mouse() | def show_controls(self): _window().window.set_cursor(None) self.overlay.show() |
self.overlay.close() | if self.overlay and self.overlay.is_visible(): self.overlay.close() | def hide_controls(self): _window().window.set_cursor(self.hidden_cursor) self.overlay.close() |
def initvars(self): | def setup_new(self): | def initvars(self): self.list_view_displays = list() self.sort_states = dict() self.active_filters = dict() |
def setup_new(self): self.initvars() def setup_restored(self): self.initvars() | def initvars(self): self.list_view_displays = list() self.sort_states = dict() self.active_filters = dict() | |
widgetutil.build_hbox((widgetset.Label(_("Language:")), lang_option_menu)))) | widgetutil.build_control_line((widgetset.Label(_("Language:")), lang_option_menu)))) | def build_widget(self): v = widgetset.VBox(8) |
return FilenameType(self.status.get('filename', '')) | return self.status.get('filename', FilenameType('')) | 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 - '' is a bogus value, but looks like a filename. # should return None. return FilenameType(self.status.get('filename', '')) |
logging.basicConfig(level=level, format='%(levelname)-8s %(message)s') handler = logging.StreamHandler(sys.stdout) logging.getLogger('').addHandler(handler) logging.getLogger('').setLevel(level) else: level = logging.WARN | else: log_name = config.get(prefs.LOG_PATHNAME) | def setup_logging (in_downloader=False): if in_downloader: level = logging.INFO logging.basicConfig(level=level, format='%(levelname)-8s %(message)s') handler = logging.StreamHandler(sys.stdout) logging.getLogger('').addHandler(handler) logging.getLogger('').setLevel(level) else: level = logging.WARN if config.get(pref... |
logging.basicConfig(level=level, format='%(levelname)-8s %(message)s') rotater = logging.handlers.RotatingFileHandler(config.get(prefs.LOG_PATHNAME), mode="w", maxBytes=100000, backupCount=5) formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s') rotater.setFormatter(formatter) logging.getLogger('').a... | else: level = logging.WARN logging.basicConfig(level=level, format='%(levelname)-8s %(message)s') rotater = logging.handlers.RotatingFileHandler( log_name, mode="w", maxBytes=100000, backupCount=5) formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s') rotater.setFormatter(formatter) logging.getLogge... | def setup_logging (in_downloader=False): if in_downloader: level = logging.INFO logging.basicConfig(level=level, format='%(levelname)-8s %(message)s') handler = logging.StreamHandler(sys.stdout) logging.getLogger('').addHandler(handler) logging.getLogger('').setLevel(level) else: level = logging.WARN if config.get(pref... |
self.enable_subtitle_track, 1) | self.handle_change_subtitle_timout) def handle_change_subtitle_timout(self): self._change_subtitle_timout = None self.setup_subtitle_info() self.enable_subtitle_track(1) | 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 ... |
self.output_path = self._build_output_path(self.input_path, target_folder, converter_info) self.key = "%s->%s" % (self.input_path, self.output_path) | self.final_output_path, self.temp_output_path = self._build_output_paths(self.input_path, target_folder, converter_info) self.key = "%s->%s" % (self.input_path, self.final_output_path) | def __init__(self, converter_info, item_info, target_folder): self.item_info = item_info self.converter_info = converter_info self.input_path = item_info.video_path self.output_path = self._build_output_path(self.input_path, target_folder, converter_info) self.key = "%s->%s" % (self.input_path, self.output_path) self.t... |
return self.output_path | return self.temp_output_path | def substitute(param): if param == "{input}": return self.input_path elif param == "{output}": return self.output_path elif param == "{ssize}": return self.converter_info.screen_size return param |
def _build_output_path(self, input_path, target_folder, converter_info): | def _build_output_paths(self, input_path, target_folder, converter_info): | def _build_output_path(self, input_path, target_folder, converter_info): basename = os.path.basename(input_path) basename, _ = os.path.splitext(basename) target_name = "%s.%s.%s" % (basename, self.converter_info.identifier, self.converter_info.extension) return os.path.join(target_folder, target_name) |
return os.path.join(target_folder, target_name) | temp_dir = tempfile.mkdtemp("miro-conversion") return os.path.join(target_folder, target_name), os.path.join(temp_dir, target_name) | def _build_output_path(self, input_path, target_folder, converter_info): basename = os.path.basename(input_path) basename, _ = os.path.splitext(basename) target_name = "%s.%s.%s" % (basename, self.converter_info.identifier, self.converter_info.extension) return os.path.join(target_folder, target_name) |
if os.path.exists(self.output_path): self._log_progress("Removing existing output file (%s)...\n" % self.output_path) os.remove(self.output_path) | if os.path.exists(self.final_output_path): self._log_progress("Removing existing output file (%s)...\n" % self.final_output_path) os.remove(self.final_output_path) | def _loop(self): executable = self.get_executable() args = self.get_parameters() self._start_logging(executable, args) if os.path.exists(self.output_path): self._log_progress("Removing existing output file (%s)...\n" % self.output_path) os.remove(self.output_path) |
if os.path.exists(self.output_path) and self.progress < 1.0: eventloop.add_timeout(0.5, os.remove, "removing output_path", (self.output_path,)) | if os.path.exists(self.temp_output_path) and self.progress < 1.0: eventloop.add_timeout(0.5, os.remove, "removing temp_output_path", (self.temp_output_path,)) | def interrupt(self): utils.kill_process(self.process_handle.pid) if os.path.exists(self.output_path) and self.progress < 1.0: eventloop.add_timeout(0.5, os.remove, "removing output_path", (self.output_path,)) |
self._ascending = False | if sort_key == "name": self._ascending = True else: self._ascending = False | def _on_button_clicked(self, button, sort_key): if self._current_sort_key == sort_key: self._ascending = not self._ascending else: self._ascending = False old_button = self._button_map[self._current_sort_key] old_button.set_sort_state(SortBarButton.SORT_NONE) self._current_sort_key = sort_key if self._ascending: button... |
a = self.width - self.progress_width | end_circle_start = self.width - radius a = self.progress_width - end_circle_start | def _draw_progress_right(self, context): if self.progress_width == self.width: return radius = self.half_height if self.progress_end == 'left': # need to figure out how tall to draw the border. # pythagoras to the rescue a = radius - self.progress_width upper_height = math.floor(math.sqrt(radius**2 - a**2)) elif self.p... |
else: | def _loop(self): executable = self.get_executable() args = self.get_parameters() self._start_logging(executable, args) if os.path.exists(self.final_output_path): self._log_progress("Removing existing output file (%s)...\n" % self.final_output_path) os.remove(self.final_output_path) | |
if len(line) > 0: self._log_progress(line) old_progress = self.progress self.progress = self.monitor_progress(line) if self.progress >= 1.0: self.progress = 1.0 keep_going = False if old_progress != self.progress: self._notify_progress() | while line: error = self.check_for_errors(line) if error: self.error = error break break old_progress = self.progress line = self.readline().strip() error = self.check_for_errors(line) if error: keep_going = False self.error = error break self._log_progress(line) self.progress = self.monitor_progress(line) if self.p... | def _loop(self): executable = self.get_executable() args = self.get_parameters() self._start_logging(executable, args) if os.path.exists(self.final_output_path): self._log_progress("Removing existing output file (%s)...\n" % self.final_output_path) os.remove(self.final_output_path) |
if line.startswith(("Unknown", "Error")): self.error = line | def monitor_progress(self, line): if self.duration is None: match = self.DURATION_RE.match(line) if match is not None: hours = match.group(1) minutes = match.group(2) seconds = match.group(3) frames = match.group(4) self.duration = ( (int(hours) * 60 * 60) + (int(minutes) * 60) + int(seconds)) else: match = self.PROGRE... | |
if self.player_ready(): | if self.player_playing(): | def notify_update(self): if self.player_ready(): elapsed = self.player.get_elapsed_playback_time() total = self.player.get_total_playback_time() self.emit('playback-did-progress', elapsed, total) |
if not self.player_ready() and resume_time == -1: | if not self.player_playing() and resume_time == -1: | def update_current_resume_time(self, resume_time=-1): if not self.player_ready() and resume_time == -1: # we want to see what the current time is, but the player hasn't # started playing yet. Just return return item_info = self.playlist[self.position] if app.config.get(prefs.RESUME_VIDEOS_MODE): if resume_time == -1: ... |
self.open_finished = False | self.open_successful = self.open_finished = False | 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 ... |
self.open_finished = True | self.open_successful = self.open_finished = True | def _on_ready_to_play(self, obj): self.open_finished = True if not self.playlist[self.position].item_viewed: 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() |
return len(item.children) > 0 | if item is nil: return len(self.model) > 0 else: return len(item.children) > 0 | def outlineView_isItemExpandable_(self, view, item): return len(item.children) > 0 |
if default_track is None: | if default_track in (None, -1): | def finish_select_file(self): Renderer.finish_select_file(self) if hasattr(self, "pick_subtitle_track") and self.supports_subtitles: 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 |
self.enable_subtitle_track(0) | index = tracks[0][0] self.enable_subtitle_track(index) | def finish_select_file(self): Renderer.finish_select_file(self) if hasattr(self, "pick_subtitle_track") and self.supports_subtitles: 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 |
text = '%s (%d%%)' % (_('Sending Crash Report'), progress * 100) | text = _('Sending Crash Report (%(progress)d%%)', {"progress": progress * 100}) | def _send_bug_report_progress(self): current_sent = 0 total_to_send = 0 for sender in self.bug_report_senders: sent, to_send = sender.progress() if to_send == 0: # this sender doesn't know it's total data, we can't calculate # things. current_sent = total_to_send = 0 break else: current_sent += sent total_to_send += to... |
logging.info("Support directory backed up to %s" % tempfilename) | logging.info("Support directory backed up to %s (%d bytes)", tempfilename, os.path.getsize(tempfilename)) | def _backup_support_dir(self): # backs up the support directories to a zip file # returns the name of the zip file logging.info("Attempting to back up support directory") app.db.close() |
try: parser.setFeature(xml.sax.handler.feature_external_ges, 0) except (SystemExit, KeyboardInterrupt): raise except: pass | parser.setFeature(xml.sax.handler.feature_external_ges, 0) | def _generateFeedCallback(self, info, removeOnError): """This is called by grabURL to generate a feed based on the type of data found at the given URL """ # FIXME: This probably should be split up a bit. The logic is # a bit daunting |
except (SystemExit, KeyboardInterrupt): raise except: | except KeyError: | 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 (SystemExit, KeyboardInterrupt): raise except: continue mimetype = filetypes.guess_mime_type(url) if mimetype is no... |
except (SystemExit, KeyboardInterrupt): raise except: | except AttributeError: | def update(self): """Updates a feed """ self.ufeed.confirm_db_thread() if not self.ufeed.id_exists(): return if self.updating: return else: self.updating = True self.ufeed.signal_change(needs_save=False) if hasattr(self, 'initialHTML') and self.initialHTML is not None: html = self.initialHTML self.initialHTML = None se... |
icopath = resources.share_path("icons/hicolor/24x24/apps/miro.png") if config.get(prefs.THEME_NAME) != prefs.THEME_NAME.default and config.get(options.WINDOWS_ICON): themeIcoPath = resources.theme_path(config.get(prefs.THEME_NAME), config.get(options.WINDOWS_ICON)) if os.path.exists(themeIcoPath): icopath = themeIcoPat... | ico_path = resources.share_path("icons/hicolor/24x24/apps/miro.png") if ((config.get(prefs.THEME_NAME) != prefs.THEME_NAME.default and config.get(options.WINDOWS_ICON))): theme_ico_path = resources.theme_path( config.get(prefs.THEME_NAME), config.get(options.WINDOWS_ICON)) if os.path.exists(theme_ico_path): ico_path = ... | def _set_default_icon(self): # set the icon so that it doesn't flash when the window is realized in # Application.build_window(). # if this isn't a themed Miro, then we use the default icon set icopath = resources.share_path("icons/hicolor/24x24/apps/miro.png") if config.get(prefs.THEME_NAME) != prefs.THEME_NAME.defaul... |
return icopath | return ico_path | def _set_default_icon(self): # set the icon so that it doesn't flash when the window is realized in # Application.build_window(). # if this isn't a themed Miro, then we use the default icon set icopath = resources.share_path("icons/hicolor/24x24/apps/miro.png") if config.get(prefs.THEME_NAME) != prefs.THEME_NAME.defaul... |
icopath = self._set_default_icon() | self._set_default_icon() | def build_window(self): icopath = self._set_default_icon() Application.build_window(self) self.window.connect('save-dimensions', self.set_main_window_dimensions) self.window.connect('save-maximized', self.set_main_window_maximized) |
logging.exception("Problems creating or populating autostart dir.") | logging.exception("Problems creating or populating " "autostart dir.") | def update_autostart(self, value): autostart_dir = resources.get_autostart_dir() destination = os.path.join(autostart_dir, "miro.desktop") |
mappings = [('title', 'minm'), ('id', 'miid'), ('id', 'mper')] | mappings = [('name', 'minm'), ('title', 'minm'), ('id', 'miid'), ('id', 'mper')] | def make_daap_playlists(self, items): mappings = [('title', 'minm'), ('id', 'miid'), ('id', 'mper')] for x in items: attributes = [] for p, q in mappings: if isinstance(getattr(x, p), unicode): attributes.append((q, getattr(x, p).encode('utf-8'))) else: attributes.append((q, getattr(x, p))) count = len(self.get_items(p... |
if isinstance(getattr(x, p), unicode): attributes.append((q, getattr(x, p).encode('utf-8'))) else: attributes.append((q, getattr(x, p))) | try: if isinstance(getattr(x, p), unicode): attributes.append((q, getattr(x, p).encode('utf-8'))) else: attributes.append((q, getattr(x, p))) except AttributeError: continue | def make_daap_playlists(self, items): mappings = [('title', 'minm'), ('id', 'miid'), ('id', 'mper')] for x in items: attributes = [] for p, q in mappings: if isinstance(getattr(x, p), unicode): attributes.append((q, getattr(x, p).encode('utf-8'))) else: attributes.append((q, getattr(x, p))) count = len(self.get_items(p... |
del self.daap_playlists[x.id] | del self.daap_playlists[x] | def handle_playlist_removed(self, obj, removed): for x in removed: del self.daap_playlists[x.id] |
self.wrapped_widget_connect('popdown', self.on_value_set) | def __init__(self): Widget.__init__(self) self.set_widget(gtk.VolumeButton()) self.wrapped_widget_connect('value-changed', self.on_value_changed) self.wrapped_widget_connect('popdown', self.on_value_set) self.create_signal('changed') self.create_signal('released') | |
def on_value_set(self, *args): | def on_value_changed(self, *args): value = self.get_value() self.emit('changed', value) | |
self.assertEqualWithType(u'http://www.example.com/fran%C3%83%C2%A7ois', unicode, util.quote_unicode_url(u'http://www.example.com/françois')) | self.assertEqualWithType(u'http://www.example.com/fran%C3%83%C2%A7ois', unicode, util.quote_unicode_url(u'http://www.example.com/fran\xc3\xa7ois')) | def test_quote_unicode_url(self): # Non-unicode self.assertRaises(util.MiroUnicodeError, util.quote_unicode_url, 'http://www.example.com') |
self.save_path = self.make_temp_path() | self.save_path = FilenameType(self.make_temp_path(extension=".db")) | def setUp(self): EventLoopTest.setUp(self) self.save_path = self.make_temp_path() self.remove_database() self.reload_test_database() |
try: | if os.path.exists(self.save_path): | def remove_database(self): try: os.unlink(self.save_path) except OSError: pass |
except OSError: pass | def remove_database(self): try: os.unlink(self.save_path) except OSError: pass | |
self.pending_tasks.remove(task) self._notify_task_canceled(task) | try: self.pending_tasks.remove(task) except ValueError: logging.warn("Task not in pending list: %s", msg['key']) else: self._notify_task_canceled(task) | def _process_message_queue(self): try: msg = self.message_queue.get_nowait() |
NetworkError.__init__(self, _('Unknow Host'), | NetworkError.__init__(self, _('Unknown Host'), | def __init__(self, host): NetworkError.__init__(self, _('Unknow Host'), _('The domainname "%(host)s" couldn\'t be found', {"host": host})) |
traceback.format_ext()) | traceback.format_exc()) | def open_url(self, url): # It looks like the maximum URL length is about 2k. I can't # seem to find the exact value if len(url) > 2047: url = url[:2047] try: webbrowser.get("windows-default").open_new(url) except: logging.warn("Error opening URL: %r\n%s", url, traceback.format_ext()) recommendURL = config.get(prefs.REC... |
title = utils.unicode_to_filename(item_info.name, temp_dir) if not title or not title.strip(): | title = utils.unicode_to_filename(item_info.name, temp_dir).strip() if not title: | def build_output_paths(item_info, target_folder, converter_info): """Returns final_output_path and temp_output_path. We base the temp path on temp filenames. We base the final path on the item title. """ input_path = item_info.video_path temp_dir = utils.FilenameType(tempfile.mkdtemp("miro-conversion")) basename = os.... |
if len(sys.argv) > 1: if sys.argv[1] == "download_daemon": launch_downloader_daemon() elif sys.argv[1] == "unittest": launch_unit_tests() | if "download_daemon" in sys.argv: launch_downloader_daemon() elif "unittest" in sys.argv: launch_unit_tests() | def endLoop(loop): del loop.pool |
self.sync_container.set_size_request(500, -1) | def __init__(self): self.device = None widgetset.VBox.__init__(self) | |
def _remove_file(path): if os.path.exists(path): os.remove(path) | def _remove_file(path, attempt=0): try: if os.path.exists(path): os.remove(path) except Exception, e: logging.debug("_remove_file: %s kicked up while removing %s", e, self.log_path) if attempt <= 3: eventloop.add_timeout(1.0, _remove_file, "removing file", args=(self.log_path, attempt + 1)) | def _remove_file(path): if os.path.exists(path): os.remove(path) |
eventloop.add_timeout(0.5, _remove_file, "removing file", | eventloop.add_timeout(1.0, _remove_file, "removing file", | def _stop_logging(self, keep_file=False): if not self.log_file.closed: self.log_file.flush() self.log_file.close() self.log_file = None if not keep_file: eventloop.add_timeout(0.5, _remove_file, "removing file", args=(self.log_path,)) self.log_path = None |
data_files.append(('', iglob(os.path.join(VCREDIST90_PATH, '*')))) | data_files.extend(find_data_files('Microsoft.VC90.CRT', os.path.join(VCREDIST90_PATH, 'Microsoft.VC90.CRT'))) | 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() |
first_label.set_size_request(100, -1) | first_label.set_text(text_up) width1, height1 = first_label.get_size_request() print 'width 1 is ', width1 first_label.set_text(text_down) width2, height2 = first_label.get_size_request() print 'width 2 is ', width2 first_label.set_size_request(max(width1, width2), -1) | def __init__(self): DisplayToolbar.__init__(self) |
second_label.set_size_request(100, -1) | second_label.set_size_request(max(width1, width2), -1) | def __init__(self): DisplayToolbar.__init__(self) |
if self._current_sort_column is None: new_sort_column.set_sort_indicator_visible(True) elif self._current_sort_column is not new_sort_column: | if not self._current_sort_column in (new_sort_column, None): | def change_sort_indicator(self, column_name, ascending): if not column_name in self._column_name_to_column: # column not visible column_name = 'name' # TODO: better handling of this case new_sort_column = self._column_name_to_column[column_name] if self._current_sort_column is None: new_sort_column.set_sort_indicator_v... |
if position != -1 and type == 'downloaded-item': | if position != -1 and typ == 'downloaded-item': | def validate_drop(self, table_view, model, typ, source_actions, parent, position): if position != -1 and type == 'downloaded-item': return widgetset.DRAG_ACTION_MOVE return widgetset.DRAG_ACTION_NONE |
return None | return _("Unknown Language") | def _get_subtitle_file_name(self, filename): """Returns the language for the file at the specified filename. """ basename, ext = os.path.splitext(filename) movie_file, code = os.path.splitext(basename) |
self.update_finished(mdi.item, -1, None, mediatype) | self.update_finished(mdi.item, -1, None, None) | def thread_loop(self): while not self.in_shutdown: self.emit('begin-loop') mdi = self.queue.get(block=True) if mdi is None or mdi.program_info is None: # shutdown() was called or there's no moviedata # implemented. self.emit('end-loop') break try: duration = -1 screenshot_worked = False screenshot = None command_line, ... |
import resource logging.info('Increasing file descriptor count limit in Downloader') resource.setrlimit(resource.RLIMIT_NOFILE, (10240, -1)) | try: import resource logging.info('Increasing file descriptor count limit in Downloader') resource.setrlimit(resource.RLIMIT_NOFILE, (10240, -1)) except ValueError: logging.warn('setrlimit failed.') | def launch_downloader_daemon(): # Increase the maximum file descriptor count (to the max) # NOTE: the info logging is REQUIRED for some unknown reason, if it is not # done here, no further logging can be done in the daemon and it gets stuck. import resource logging.info('Increasing file descriptor count limit in Downlo... |
if item is nil: | if item is not nil and hasattr(item, 'children'): return len(item.children) > 0 else: | def outlineView_isItemExpandable_(self, view, item): if item is nil: return len(self.model) > 0 else: return len(item.children) > 0 |
else: return len(item.children) > 0 | def outlineView_isItemExpandable_(self, view, item): if item is nil: return len(self.model) > 0 else: return len(item.children) > 0 | |
if item is nil: | if item is not nil and hasattr(item, 'children'): return len(item.children) else: | def outlineView_numberOfChildrenOfItem_(self, view, item): if item is nil: return len(self.model) else: return len(item.children) |
else: return len(item.children) | def outlineView_numberOfChildrenOfItem_(self, view, item): if item is nil: return len(self.model) else: return len(item.children) | |
self._make_fake_item("pcf.mpeg") | self._make_fake_item("pcf.avi") | def setUp(self): MiroTestCase.setUp(self) self.feed = Feed(u'dtv:manualFeed', initiallyAutoDownloadable=False) self.tempdir = FilenameType(tempfile.mkdtemp()) self._make_fake_item("pcf.mpeg") self._make_fake_item("dean.avi") self._make_fake_item("npr.txt") self.container_item = FileItem(self.tempdir, self.feed.id) |
callback(current_url) | if info.get("content-type"): callback(current_url, unicode(info["content-type"])) else: callback(current_url) | def _youtube_get_first_successful(info, current_url, urls, callback): status = info["status"] if status == 200: callback(current_url) return if len(urls) == 0: callback(None) return current_url, urls = urls[0], urls[1:] logging.debug("youtube download: trying %s", current_url) httpclient.grabHeaders(current_url, la... |
menubar.insert(5, windowMenu) | menubar.insert(6, windowMenu) | def populate_menu(): short_appname = config.get(prefs.SHORT_APP_NAME) menubar = menus.get_menu() # Application menu miroMenuItems = [ extract_menu_item(menubar, "About"), menus.Separator(), extract_menu_item(menubar, "Donate"), extract_menu_item(menubar, "CheckVersion"), menus.Separator(), extract_menu_item(menubar, ... |
os.environ['FFMPEG_DATADIR'] = os.path.join(bundle.resourcePath(), | os.environ['FFMPEG_DATADIR'] = os.path.join( bundle.resourcePath().encode('utf-8'), | def launch_application(): from miro.plat import migrateappname migrateappname.migrateSupport('Democracy', 'Miro') from miro.plat.utils import initialize_locale initialize_locale() from glob import glob theme = None bundle = Foundation.NSBundle.mainBundle() bundle_path = bundle.bundlePath() bundle_theme_dir_path = os.... |
return json.load(file(file_name)) | try: return json.load(file(file_name, 'rb')) except ValueError: logging.exception('error loading JSON db on %s' % mount) return {} | 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 {} return json.load(file(file_name)) |
elif self.data.pending_auto_dl: hotspot = self._make_button( layout, self.CANCEL_TEXT, 'cancel_auto_download') main_hbox.pack(cellpack.align_middle(cellpack.align_middle(hotspot))) | def pack_infobar(self, layout): if self.show_progress_bar: return cellpack.align_bottom(self.pack_download_status(layout)) | |
return self.process_handle is not None and self.process_handle.returncode != 0 | return (self.process_handle is not None and self.process_handle.returncode is not None and self.process_handle.returncode != 0) | def is_failed(self): return self.process_handle is not None and self.process_handle.returncode != 0 |
DURATION_RE = re.compile('Duration: (\d\d):(\d\d):(\d\d)\.(\d\d), start:.*, bitrate:.*') PROGRESS_RE = re.compile('frame=.* fps=.* q=.* L?size=.* time=(.*) bitrate=(.*)') | DURATION_RE = re.compile('Duration: (\d\d):(\d\d):(\d\d)\.(\d\d)(, start:.*)?(, bitrate:.*)?') PROGRESS_RE = re.compile('frame=.* fps=.* q=.* size=.* time=(.*) bitrate=(.*)') LAST_PROGRESS_RE = re.compile('frame=.* fps=.* q=.* Lsize=.* time=(.*) bitrate=(.*)') | def interrupt(self): utils.kill_process(self.process_handle.pid) if os.path.exists(self.temp_output_path) and self.progress < 1.0: eventloop.add_timeout(0.5, os.remove, "removing temp_output_path", (self.temp_output_path,)) |
file_size = os.stat(self.filename)[stat.ST_SIZE] if file_size > self.currentSize: logging.info("File larger than currentSize: truncating. " "url: %s, path: %s.", self.url, self.filename) f = open(self.filename, "ab") f.truncate(self.currentSize) f.close() elif file_size < self.currentSize: logging.warn("File doesn'... | resume = self._resume_sanity_check() | def startDownload(self, resume=True): if self.retryDC: self.retryDC.cancel() self.retryDC = None if resume: # sanity check that the file we're resuming from is the right # size. In particular, before the libcurl change, we would # preallocate the entire file, so we need to undo this. file_size = os.stat(self.filename)... |
return 2 | return (2, ) | 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: # the tuple here creates a subsort on expiration_date return (4, item.expiration_date) # expiring elif not item.item_viewed: return 0 # new el... |
return 3 | return (3, ) | 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: # the tuple here creates a subsort on expiration_date return (4, item.expiration_date) # expiring elif not item.item_viewed: return 0 # new el... |
return 0 else: return 1 | return (0, ) else: return (1, ) | 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: # the tuple here creates a subsort on expiration_date return (4, item.expiration_date) # expiring elif not item.item_viewed: return 0 # new el... |
def build_output_paths(input_path, target_folder, converter_info): basename = os.path.basename(input_path) basename, _ = os.path.splitext(basename) target_name = "%s.%s.%s" % (basename, converter_info.identifier, converter_info.extension) | def build_output_paths(item_info, target_folder, converter_info): """Returns final_output_path and temp_output_path. """ input_path = item_info.video_path | def build_output_paths(input_path, target_folder, converter_info): basename = os.path.basename(input_path) basename, _ = os.path.splitext(basename) target_name = "%s.%s.%s" % (basename, converter_info.identifier, converter_info.extension) temp_dir = tempfile.mkdtemp("miro-conversion") return os.path.join(target_folder,... |
return os.path.join(target_folder, target_name), os.path.join(temp_dir, target_name) | title = utils.unicode_to_filename(item_info.name, temp_dir) if not title or not title.strip(): title = os.path.basename(input_path) title, ext = os.path.splitext(title) target_name = "%s.%s.%s" % (title, converter_info.identifier, converter_info.extension) return (os.path.join(target_folder, target_name), os.path.join... | def build_output_paths(input_path, target_folder, converter_info): basename = os.path.basename(input_path) basename, _ = os.path.splitext(basename) target_name = "%s.%s.%s" % (basename, converter_info.identifier, converter_info.extension) temp_dir = tempfile.mkdtemp("miro-conversion") return os.path.join(target_folder,... |
self.final_output_path, self.temp_output_path = build_output_paths(self.input_path, target_folder, converter_info) | self.final_output_path, self.temp_output_path = build_output_paths( item_info, target_folder, converter_info) | def __init__(self, converter_info, item_info, target_folder): 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(self.input_path, target_folder, converter_info) self.key = "%s->%s" % (self.input_path, ... |
if data[0] != 'd': | if not data or data[0] != 'd': | def get_torrent_info_hash(path): if os.path.getsize(path) > MAX_TORRENT_SIZE: # file is too large, bailout. (see #12301) raise ValueError("%s is not a valid torrent" % path) import libtorrent as lt f = open(path, 'rb') try: data = f.read() if data[0] != 'd': # File doesn't start with 'd', bailout (see #12301) raise ... |
print "handling %r" % obj | def export_content(self, pathname, media_tabs, site_tabs): """Given a pathname (which is just written into the opml), a list of media_tabs, and a list of site_tabs, generates the OPML and returns it as a utf-8 encoded string. """ self.io = StringIO() self.current_folder = None | |
line = self.readline() self._log_progress(line.strip()) if line == "": | if self.process_handle.poll() is not None: | def _loop(self): executable = self.get_executable() args = self.get_parameters() self._start_logging(executable, args) if os.path.exists(self.output_path): self._log_progress("Removing existing output file (%s)...\n" % self.output_path) os.remove(self.output_path) args.insert(0, executable) self.process_handle = subp... |
old_progress = self.progress self.progress = self.monitor_progress(line.strip()) if self.progress >= 1.0: self.progress = 1.0 if old_progress != self.progress: self._notify_progress() | line = self.readline().strip() if len(line) > 0: self._log_progress(line) old_progress = self.progress self.progress = self.monitor_progress(line) if self.progress >= 1.0: self.progress = 1.0 keep_going = False if old_progress != self.progress: self._notify_progress() | def _loop(self): executable = self.get_executable() args = self.get_parameters() self._start_logging(executable, args) if os.path.exists(self.output_path): self._log_progress("Removing existing output file (%s)...\n" % self.output_path) os.remove(self.output_path) args.insert(0, executable) self.process_handle = subp... |
PROGRESS_RE = re.compile('\{"duration":(.*), "position":(.*), "audio_kbps":.*, "video_kbps":.*, "remaining":.*\}') RESULT_RE = re.compile('\{"result": "(.*)"\}') | PROGRESS_RE1 = re.compile('\{"duration":(.*), "position":(.*), "audio_kbps":.*, "video_kbps":.*, "remaining":.*\}') RESULT_RE1 = re.compile('\{"result": "(.*)"\}') DURATION_RE2 = re.compile('f2t ;duration: (.*);') PROGRESS_RE2 = re.compile('f2t ;position: (.*);') RESULT_RE2 = re.compile('f2t ;result: (.*);') | def monitor_progress(self, line): if self.duration is None: match = self.DURATION_RE.match(line) if match is not None: hours = match.group(1) minutes = match.group(2) seconds = match.group(3) frames = match.group(4) self.duration = int(hours) * 60 * 60 + int(minutes) * 60 + int(seconds) else: match = self.PROGRESS_RE.m... |
match = self.PROGRESS_RE.match(line) if match is not None: | if line.startswith('f2t'): | def monitor_progress(self, line): match = self.PROGRESS_RE.match(line) if match is not None: if self.duration is None: self.duration = float(match.group(1)) return float(match.group(2)) / self.duration return self.progress |
self.duration = float(match.group(1)) return float(match.group(2)) / self.duration | match = self.DURATION_RE2.match(line) if match is not None: self.duration = float(match.group(1)) match = self.PROGRESS_RE2.match(line) if match is not None: return float(match.group(1)) / self.duration match = self.RESULT_RE2.match(line) if match is not None: return 1.0 else: match = self.PROGRESS_RE1.match(line) if m... | def monitor_progress(self, line): match = self.PROGRESS_RE.match(line) if match is not None: if self.duration is None: self.duration = float(match.group(1)) return float(match.group(2)) / self.duration return self.progress |
if self.totalSize == -1: self.totalSize = self.currentSize | def on_download_finished(self, response): self.destroy_client() self.state = "finished" if self.totalSize == -1: self.totalSize = self.currentSize self.endTime = clock() try: self.move_to_movies_directory() except IOError, e: self.handle_write_error(e) self.update_client() | |
try: self.move_to_movies_directory() except IOError, e: self.handle_write_error(e) | if self.currentSize == 0: self.handle_network_error(httpclient.PossiblyTemporaryError(_("no content"))) else: if self.totalSize == -1: self.totalSize = self.currentSize try: self.move_to_movies_directory() except IOError, e: self.handle_write_error(e) | def on_download_finished(self, response): self.destroy_client() self.state = "finished" if self.totalSize == -1: self.totalSize = self.currentSize self.endTime = clock() try: self.move_to_movies_directory() except IOError, e: self.handle_write_error(e) self.update_client() |
downloader.init_controller() downloader.startup_downloader() | def setup_state(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(self.tempdir, 'miro-download-unit-tests') app.config.set(prefs.DOWNLOADER_LOG_PATHNAME, self.log_file) self.... | |
for id_ in new_ids.difference(self.current_ids): | old_ids = self.current_ids self.current_ids = new_ids for id_ in new_ids.difference(old_ids): | def check_all_objects(self): new_ids = set(app.db.query_ids(self.klass, self.where, self.values, joins=self.joins)) for id_ in new_ids.difference(self.current_ids): self.emit('added', app.db.get_obj_by_id(id_)) for id_ in self.current_ids.difference(new_ids): self.emit('removed', app.db.get_obj_by_id(id_)) for id_ in s... |
for id_ in self.current_ids.difference(new_ids): | for id_ in old_ids.difference(new_ids): | def check_all_objects(self): new_ids = set(app.db.query_ids(self.klass, self.where, self.values, joins=self.joins)) for id_ in new_ids.difference(self.current_ids): self.emit('added', app.db.get_obj_by_id(id_)) for id_ in self.current_ids.difference(new_ids): self.emit('removed', app.db.get_obj_by_id(id_)) for id_ in s... |
for id_ in self.current_ids.intersection(new_ids): | for id_ in old_ids.intersection(new_ids): | def check_all_objects(self): new_ids = set(app.db.query_ids(self.klass, self.where, self.values, joins=self.joins)) for id_ in new_ids.difference(self.current_ids): self.emit('added', app.db.get_obj_by_id(id_)) for id_ in self.current_ids.difference(new_ids): self.emit('removed', app.db.get_obj_by_id(id_)) for id_ in s... |
self.current_ids = new_ids | def check_all_objects(self): new_ids = set(app.db.query_ids(self.klass, self.where, self.values, joins=self.joins)) for id_ in new_ids.difference(self.current_ids): self.emit('added', app.db.get_obj_by_id(id_)) for id_ in self.current_ids.difference(new_ids): self.emit('removed', app.db.get_obj_by_id(id_)) for id_ in s... | |
print 'width 1 is ', width1 | def __init__(self): DisplayToolbar.__init__(self) | |
print 'width 2 is ', width2 | def __init__(self): DisplayToolbar.__init__(self) | |
sys.argv.remove('unittest') | sys.argv.remove('--unittest') | def launch_unit_tests(): sys.argv.remove('unittest') import logging logging.basicConfig(level=logging.CRITICAL) from miro.plat.utils import initialize_locale initialize_locale() from miro import bootstrap bootstrap.bootstrap() from miro import test print 'Running Miro unit tests:' test.run_tests() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.