rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return item.name | return item.name.lower() | def sort_key(self, item): return item.name |
@threads.on_ui_thread | def __init__(self): self._info_for_volume = {} | |
FSEventStreamScheduleWithRunLoop(self.stream, CFRunLoopGetCurrent(), | FSEventStreamScheduleWithRunLoop(self.stream, CFRunLoopGetMain(), | def start_tracking(self): self.stream = FSEventStreamCreate(kCFAllocatorDefault, self.streamCallback, None, ['/Volumes/'], kFSEventStreamEventIdSinceNow, STREAM_INTERVAL, kFSEventStreamCreateFlagNoDefer | kFSEventStreamCreateFlagIgnoreSelf) FSEventStreamScheduleWithRunLoop(self.stream, CFRunLoopGetCurrent(), kCFRunLoop... |
assert FSEventStreamStart(self.stream) | FSEventStreamStart(self.stream) | def start_tracking(self): self.stream = FSEventStreamCreate(kCFAllocatorDefault, self.streamCallback, None, ['/Volumes/'], kFSEventStreamEventIdSinceNow, STREAM_INTERVAL, kFSEventStreamCreateFlagNoDefer | kFSEventStreamCreateFlagIgnoreSelf) FSEventStreamScheduleWithRunLoop(self.stream, CFRunLoopGetCurrent(), kCFRunLoop... |
self._disk_mounted('/Volumes/%s' % volume) | self._disk_mounted(volume) | def start_tracking(self): self.stream = FSEventStreamCreate(kCFAllocatorDefault, self.streamCallback, None, ['/Volumes/'], kFSEventStreamEventIdSinceNow, STREAM_INTERVAL, kFSEventStreamCreateFlagNoDefer | kFSEventStreamCreateFlagIgnoreSelf) FSEventStreamScheduleWithRunLoop(self.stream, CFRunLoopGetCurrent(), kCFRunLoop... |
else: logging.debug('unknown mask %i: %s' % (mask, path)) | def streamCallback(self, stream, clientInfo, numEvents, eventPaths, eventMasks, eventIDs): for path, mask in zip(eventPaths, eventMasks): if mask & kFSEventStreamEventFlagMount: self._disk_mounted(path) elif mask & kFSEventStreamEventFlagUnmount: self._disk_unmounted(path) else: logging.debug('unknown mask %i: %s' % (m... | |
logging.info("canceling download: %s", download.url) | def on_remove(self): for download in self.downloads: logging.info("canceling download: %s", download.url) download.cancel() self.downloads = set() | |
libvlc.libvlc_video_take_snapshot(media_player, ctypes.c_char_p(thumbnail_path), ctypes.c_int(0), ctypes.c_int(0), byref(exception)) check_exception() sleep(0.5) | if media_type == "video": libvlc.libvlc_video_take_snapshot(media_player, ctypes.c_char_p(thumbnail_path), ctypes.c_int(0), ctypes.c_int(0), byref(exception)) check_exception() sleep(0.5) if length <= 0: length = libvlc.libvlc_media_player_get_length(media_player, byref(exception)) check_exception() | 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... |
check_u(type) | check_u(typ) | def setup_new(self, typ): """Construct a TabOrder. typ should be either ``channel`` or ``playlist``. """ check_u(type) self.type = typ self.tab_ids = [] self._setup_views() to_sort = self.id_to_tab.values() to_sort.sort(key=lambda x: x.get_title().lower()) for tab in to_sort: self.tab_ids.append(tab.id) |
play_pause_menu_item = main_menu.itemAtIndex_(6).submenu().itemAtIndex_(0) | play_pause_menu_item = main_menu.itemAtIndex_(5).submenu().itemAtIndex_(0) | def on_menu_change(menu_manager): main_menu = NSApp().mainMenu() play_pause_menu_item = main_menu.itemAtIndex_(6).submenu().itemAtIndex_(0) play_pause = _menu_structure.get("PlayPauseItem").state_labels[app.menu_manager.play_pause_state] play_pause_menu_item.setTitleWithMnemonic_(play_pause.replace("_", "&")) |
subtitles_menu_root = main_menu.itemAtIndex_(6).submenu().itemAtIndex_(15) | subtitles_menu_root = main_menu.itemAtIndex_(5).submenu().itemAtIndex_(15) | def on_playback_change(playback_manager): main_menu = NSApp().mainMenu() subtitles_menu_root = main_menu.itemAtIndex_(6).submenu().itemAtIndex_(15) subtitles_menu = NSMenu.alloc().init() subtitles_menu.setAutoenablesItems_(NO) subtitles_tracks = None if app.playback_manager.is_playing and not app.playback_manager.is_pl... |
self.suspendAutoHiding() self.reveal(video_window) | if NSApplication.sharedApplication().isActive() and video_window.isVisible(): self.suspendAutoHiding() self.reveal(video_window) | def setup(self, item_info, renderer, video_window): from miro.frontends.widgets import widgetutil self.item_info = item_info self.renderer = renderer self.titleLabel.setStringValue_(item_info.name) try: self.feedLabel.setStringValue_(widgetutil.get_feed_info(item_info.feed_id).name) except: self.feedLabel.setStringValu... |
status_dict[key] = unicodeToFilename(value) | status_dict[key] = self._unicode_to_filename(value) | def _convert_status(self, repr_value): status_dict = self._convert_repr(repr_value) filename_fields = schema.SchemaStatusContainer.filename_fields for key in filename_fields: value = status_dict.get(key) if value is not None: status_dict[key] = unicodeToFilename(value) return status_dict |
self.state = "downloading" self.start_new_download() | self.start(resume=False) | def retry_download(self): self.retryDC = None self.state = "downloading" self.start_new_download() |
def start(self): | def start(self, resume=False): | def start(self): """Continues a paused or stopped download thread. """ if self.state in ('paused', 'stopped', 'offline'): self.state = "downloading" self.start_download() |
self.start_download() | self.start_download(resume=resume) | def start(self): """Continues a paused or stopped download thread. """ if self.state in ('paused', 'stopped', 'offline'): self.state = "downloading" self.start_download() |
def start(self): | def start(self, resume=False): | def start(self): if self.state not in ('paused', 'stopped', 'offline'): return |
@uses_httpclient | @uses_mock_httpclient | def test_404_error(self): self.expecting_errback = True url = self.httpserver.build_url('badfile.txt') self.grab_url(url) self.assert_(isinstance(self.grab_url_error, httpclient.UnexpectedStatusCode)) # FIXME: It'd be nice if we could check a HTTP code rather than a # static message. self.assertEquals(self.grab_url_err... |
self.grab_url('http://unknowndomainname/') | def mock_add_handle(handle): error = (handle, pycurl.E_COULDNT_RESOLVE_HOST, 'fake message') self.mocked_multi.info_read.return_value = ([], [], [error]) self.mocked_multi.add_handle.side_effect = mock_add_handle self.grab_url('http://pculture.org/') | def test_bad_domain_name(self): self.grab_url('http://unknowndomainname/') self.check_errback_called() self.assert_(isinstance(self.grab_url_error, httpclient.UnknownHostError)) |
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 != 0 | def is_failed(self): return self.process_handle is not None and self.process_handle.returncode > 0 |
eventloop.add_timeout(0.5, self._stage_file, "staging file") | 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) | |
def _stage_file(self): shutil.move(self.temp_output_path, self.final_output_path) shutil.rmtree(os.path.dirname(self.temp_output_path)) | 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) | |
uniqfn = "%012databasebackup.zip" % randrange(0, 999999999999) | uniqfn = "%012ddatabasebackup.zip" % randrange(0, 999999999999) | 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() |
self.check_auth_errback_called() | self.check_auth_canceled() | def test_auth_failed(self): self.expecting_errback = True self.setup_cancel() self.grab_url(self.httpserver.build_url('protected/index.txt')) self.check_auth_errback_called() |
self.check_auth_errback_called() | self.check_auth_canceled() | def test_digest_auth_failed(self): self.expecting_errback = True self.setup_cancel() self.grab_url(self.httpserver.build_url('digest-protected/index.txt')) self.check_auth_errback_called() |
feed_ = feed.Feed.get_by_id(video_id) | feed_ = feed.Feed.get_by_id(audio_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_) |
response = self._panel.runModalForDirectory_file_(self._directory, self._filename, self._types) | if self._filter_on_run: response = self._panel.runModalForDirectory_file_types_(self._directory, self._filename, self._types) else: response = self._panel.runModalForDirectory_file_(self._directory, self._filename) | def run(self): self._panel.setAllowedFileTypes_(self._types) if self.sheet_parent is None: response = self._panel.runModalForDirectory_file_(self._directory, self._filename, self._types) else: delegate = SheetDelegate.alloc().init() self._panel.beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_con... |
self._panel.beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo_( self._directory, self._filename, self.sheet_parent.nswindow, delegate, 'sheetDidEnd:returnCode:contextInfo:', 0) | if self._filter_on_run: self._panel.beginSheetForDirectory_file_types_modalForWindow_modalDelegate_didEndSelector_contextInfo_( self._directory, self._filename, self._types, self.sheet_parent.nswindow, delegate, 'sheetDidEnd:returnCode:contextInfo:', 0) else: self._panel.beginSheetForDirectory_file_modalForWindow_modal... | def run(self): self._panel.setAllowedFileTypes_(self._types) if self.sheet_parent is None: response = self._panel.runModalForDirectory_file_(self._directory, self._filename, self._types) else: delegate = SheetDelegate.alloc().init() self._panel.beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_con... |
left_side = rect.right - right_buttons.last_rect.right | left_side = rect.width - right_buttons.last_rect.right | def layout_main_bottom(self, layout, layout_manager, rect): """layout_main_bottom lay out the bottom part of the main section. |
self.program_info = (command_line, env) | self._program_info = (command_line, env) | def _calc_program_info(self): videopath = fileutil.expand_filename(self.video_path) thumbnailpath = fileutil.expand_filename(self.thumbnail_path) command_line, env = movie_data_program_info(videopath, thumbnailpath) self.program_info = (command_line, env) |
url, traceback.format_exc()) | url, "".join(traceback.format_stack())) | def find_subscribe_links(url): """Given a URL, test if it's trying to subscribe the user using a subscribe_host. Returns the list of parsed URLs. """ if not isinstance(url, basestring): logging.warn("find_subscribe_links: url wrong type %r\n%s", url, traceback.format_exc()) return [] dummy, host, path, dummy, query, ... |
if task is not None and task.get_executable() is not None: | if ((task is not None and task.get_executable() is not None and not self._has_running_task(task.key) and not self._has_finished_task(task.key))): | def start_conversion(self, converter_id, item_info, target_folder=None): converter_info = self.converters.lookup_converter(converter_id) task = self._make_conversion_task(converter_info, item_info, target_folder) if task is not None and task.get_executable() is not None: self._check_task_loop() self.pending_tasks.appen... |
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, path) if attempt <= 3: eventloop.add_timeout(1.0, _remove_file, "removing file", args=(path, attempt + 1)) def build_output_paths(item_info, target_fo... | def build_output_paths(item_info, temp_dir, target_folder, converter_info): | def _remove_file(path, attempt=0): try: if os.path.exists(path): os.remove(path) except Exception, e: # FIXME - need a way to catch Windows errors which only exist # on Windows logging.debug("_remove_file: %s kicked up while removing %s", e, path) if attempt <= 3: eventloop.add_timeout(1.0, _remove_file, "removing file... |
temp_dir = utils.FilenameType(tempfile.mkdtemp("miro-conversion")) | 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.... | |
item_info, target_folder, converter_info) logging.info("temp_output_path: %s", self.temp_output_path) logging.info("final_output_path: %s", self.final_output_path) | item_info, self.temp_dir, target_folder, converter_info) logging.debug("temp_output_path: %s final_output_path: %s", self.temp_output_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.final_output_path, self.temp_output_path = build_output_paths( item_info, target_folder, converter_info) |
keep_going = False | def _loop(self): executable = self.get_executable() args = self.get_parameters() self._start_logging(executable, args) | |
self.error = error | def _loop(self): executable = self.get_executable() args = self.get_parameters() self._start_logging(executable, args) | |
eventloop.add_timeout(1.0, _remove_file, "removing file", args=(self.log_path,)) | clean_up(self.log_path) | 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(1.0, _remove_file, "removing file", args=(self.log_path,)) self.log_path = None |
eventloop.add_timeout(0.5, os.remove, "removing temp_output_path", (self.temp_output_path,)) | clean_up(self.temp_output_path, file_and_directory=True) | 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,)) |
return if self.screenshot and not fileutil.exists(self.screenshot): self.screenshot = None self.signal_change() | def setup_links(self): self.split_item() if not self.id_exists(): # In split_item() we found out that all our children were # deleted, so we were removed as well. (#11979) return if (self.isContainerItem is not None and not fileutil.exists(self.get_filename()) and not hasattr(app, 'in_unit_tests')): self.expire() retu... | |
def on_db_insert(self): self.split_item() | def setup_common(self): self.selected = False self.active = False self.expiring = None self.showMoreInfo = False self.updating_movie_info = False | |
logging.info("WARNING: error in Feed.update for %s -- %s", self.ufeed, stringify(error)) | logging.warn("WARNING: error in Feed.update for %s -- %s", stringify(self.ufeed), 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, stringify(error)) self.scheduleUpdateEvents(-1) self.updating = False self.ufeed.signal_change(needs_save=False) |
self.ufeed, url, stringify(error)) | stringify(self.ufeed), stringify(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, stringify(error)) self.scheduleUpdateEvents(-1) self.updating -= 1 self.check_update_finished() self.ufeed.signal_change(needs_save=False) |
for mem in ["~/Videos/Miro", "~/Movies/Miro", "~/Movies/Democracy"]: | for mem in ["~/.miro/Movies", "~/Videos/Miro", "~/Movies/Miro", "~/Movies/Democracy" ]: | def _copy_gconf(src, dst): for entry in client.all_entries(src): entry_dst = dst + '/' + entry.key.split('/')[-1] client.set(entry_dst, entry.value) for subdir in client.all_dirs(src): subdir_dst = dst + '/' + subdir.split('/')[-1] _copy_gconf(subdir, subdir_dst) |
return self._createItemsForParsed(parsed) | self._createItemsForParsed(parsed) | def createItemsForParsed(self, parsed): """Update the feed using parsed XML passed in""" app.bulk_sql_manager.start() try: return self._createItemsForParsed(parsed) finally: app.bulk_sql_manager.finish() |
old_items = set() | 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... | |
old_items.add(item) | 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... | |
old_items.discard(item) | self.old_items.discard(item) | 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... |
return old_items def update_finished(self, old_items): | def update_finished(self): | 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... |
self.truncateOldItems(old_items) | self.truncateOldItems() del self.old_items | def update_finished(self, old_items): """ 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.isAutoD... |
def truncateOldItems(self, old_items): | def truncateOldItems(self): | def truncateOldItems(self, old_items): """Truncate items so that the number of items in this feed doesn't exceed self.get_max_old_items() |
old_items should be an iterable that contains items that aren't in the feed anymore. | def truncateOldItems(self, old_items): """Truncate items so that the number of items in this feed doesn't exceed self.get_max_old_items() | |
if truncate > len(old_items): | if truncate > len(self.old_items): | def truncateOldItems(self, old_items): """Truncate items so that the number of items in this feed doesn't exceed self.get_max_old_items() |
extra = len(old_items) - limit | extra = len(self.old_items) - limit | def truncateOldItems(self, old_items): """Truncate items so that the number of items in this feed doesn't exceed self.get_max_old_items() |
for item in old_items: | for item in self.old_items: | def truncateOldItems(self, old_items): """Truncate items so that the number of items in this feed doesn't exceed self.get_max_old_items() |
old_items = self.createItemsForParsed(parsed) | self.remember_old_items() self.createItemsForParsed(parsed) | def feedparser_callback(self, parsed): self.ufeed.confirm_db_thread() if not self.ufeed.id_exists(): return start = clock() parsed = self.parsed = unicodify(parsed) old_items = self.createItemsForParsed(parsed) |
self.update_finished(old_items) | self.update_finished() | def feedparser_callback(self, parsed): self.ufeed.confirm_db_thread() if not self.ufeed.id_exists(): return start = clock() parsed = self.parsed = unicodify(parsed) old_items = self.createItemsForParsed(parsed) |
self.oldItems = None | def setup_new(self, url, ufeed, title=None): RSSFeedImplBase.setup_new(self, url, ufeed, title) self.oldItems = None self.etag = {} self.modified = {} self.download_dc = {} self.updating = 0 self.query = None self.splitURLs() | |
self.update_finished(self.oldItems) self.oldItems = None | self.update_finished() | def checkUpdateFinished(self): if self.updating == 0: self.update_finished(self.oldItems) self.oldItems = None self.scheduleUpdateEvents(-1) |
if self.oldItems is None: return | def feedparser_callback(self, parsed, url): self.ufeed.confirm_db_thread() if not self.ufeed.id_exists() or url not in self.download_dc: return if self.oldItems is None: # if this is the case, then this feedparser_callback isn't # paired with an update. maybe we did two in a row? return start = clock() parsed = unicod... | |
old_items = self.createItemsForParsed(parsed) self.oldItems.update(old_items) | self.createItemsForParsed(parsed) | def feedparser_callback(self, parsed, url): self.ufeed.confirm_db_thread() if not self.ufeed.id_exists() or url not in self.download_dc: return if self.oldItems is None: # if this is the case, then this feedparser_callback isn't # paired with an update. maybe we did two in a row? return start = clock() parsed = unicod... |
self.oldItems = set() | self.remember_old_items() | def update(self): self.ufeed.confirm_db_thread() if not self.ufeed.id_exists(): return if self.updating: return self.oldItems = set() for url in self.urls: etag = self.etag.get(url) modified = self.modified.get(url) self.download_dc[url] = grabURL(url, lambda x, url=url: self._updateCallback(x, url), lambda x, url=url:... |
def update_finished(self, old_items): | def update_finished(self): | def update_finished(self, old_items): self.searching = False RSSMultiFeedImpl.update_finished(self, old_items) |
RSSMultiFeedImpl.update_finished(self, old_items) | RSSMultiFeedImpl.update_finished(self) | def update_finished(self, old_items): self.searching = False RSSMultiFeedImpl.update_finished(self, old_items) |
dialogs.MessageBoxDialog(title, text).run() | if not isinstance(error, httpclient.PossiblyTemporaryError): dialogs.MessageBoxDialog(title, text).run() else: def callback(dialog): if dialog.choice == dialogs.BUTTON_RETRY: httpclient.grab_headers(url, callback, errback) dialogs.ChoiceDialog(title, text, dialogs.BUTTON_RETRY, dialogs.BUTTON_CANCEL).run(callback) | def errback(error): title = _("Download Error") text = _( "%(appname)s is not able to download a file at this URL:\n" "\n" "URL: %(url)s\n" "\n" "Error: %(error)s (%(errordesc)s)", {"url": url, "appname": config.get(prefs.SHORT_APP_NAME), "error": error.getFriendlyDescription(), "errordesc": error.getLongDescription()}... |
self.iter_map[task.key] = self.model.append(task) self.table.model_changed() | if task.key not in self.iter_map: self.iter_map[task.key] = self.model.append(task) self.table.model_changed() | def handle_task_added(self, task): self.iter_map[task.key] = self.model.append(task) self.table.model_changed() self._update_buttons_state() |
for X in os.path.listdir(d): | for X in os.listdir(d): | def check_comp(self, wait=0.2): r""" Check on currently computing cells in the queue. INPUT: - ``wait`` - float (default: 0.2); how long to wait for output. EXAMPLES:: sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()) sage: nb.add_user('sage','sage','sage@sagemath.org',force=True) sage: W = nb.create_new_w... |
from sage.server.notebook.twist import SEP import sage.server.notebook.twist as notebook_twist | from sagenb.notebook.twist import SEP import sagenb.notebook.twist as notebook_twist | def late_import(): global SEP, notebook_twist, late_import_done if not late_import_done: from sage.server.notebook.twist import SEP import sage.server.notebook.twist as notebook_twist late_import_done = True |
return http.Response(stream = "\n".join([simple_jsonize(status), SEP, result])) | return http.Response(stream = str("\n".join([simple_jsonize(status), SEP, result]))) | def render_cell_result(self, looper): cell = looper.cell if cell.interrupted(): cell_status = 'interrupted' elif cell.computing(): cell_status = 'computing' else: cell_status = 'done' status = { 'cell_id': cell.id(), 'status': cell_status, 'files': cell.files() } result = cell.output_text(raw=True) return http.Response... |
input += 'print "CPU time: %.2f s, Wall time: %.2f s"%(cputime(__SAGE_t__), walltime(__SAGE_w__))\n' | input += '; print "CPU time: %.2f s, Wall time: %.2f s"%(cputime(__SAGE_t__), walltime(__SAGE_w__))\n' | def start_next_comp(self): if len(self.__queue) == 0: return |
<table border=0 bgcolor=' | <table border=0 bgcolor='white' width=100%% height=100%%> | def render_output(self): """ Render in text (HTML) form the output portion of the :func:`interact` canvas. |
try: import dsage.all import dsage.misc.constants print "Using dsage certificates." path = dsage.misc.constants.DSAGE_DIR dsage.all.dsage.setup() shutil.copyfile(path + '/cacert.pem', private_pem) shutil.copyfile(path + '/pubcert.pem', public_pem) except ImportError: pass | if not cmd_exists('certtool'): raise RuntimeError, "You must install certtool to use the secure notebook server." dn = raw_input("Domain name [localhost]: ").strip() if dn == '': print "Using default localhost" dn = 'localhost' import random template_dict = {'organization': 'SAGE (at %s)' % (dn), 'unit': '389', 'loca... | def notebook_setup(self=None): if not os.path.exists(conf_path): os.makedirs(conf_path) try: import dsage.all import dsage.misc.constants print "Using dsage certificates." path = dsage.misc.constants.DSAGE_DIR dsage.all.dsage.setup() shutil.copyfile(path + '/cacert.pem', private_pem) shutil.copyfile(path + '/pubcert.p... |
<RedirectResponse 301 Document moved to over there.> | <sagenb.notebook.twist.RedirectResponse code=303, streamlen=None> | def render(self, ctx): """ Rendering this resource (1) empties the trash, and (2) returns a message. |
``obj``, return a list of those names. If | ``obj``, return a sorted list of those names. If | def sage_getvariablename(obj, omit_underscore_names=True): """ Attempt to get the name of a Sage object. INPUT: - ``obj`` - an object - ``omit_underscore_names`` (optional, default True) If the user has assigned an object ``obj`` to a variable name, then return that variable name. If several variables point to ``ob... |
return result | return sorted(result) | def sage_getvariablename(obj, omit_underscore_names=True): """ Attempt to get the name of a Sage object. INPUT: - ``obj`` - an object - ``omit_underscore_names`` (optional, default True) If the user has assigned an object ``obj`` to a variable name, then return that variable name. If several variables point to ``ob... |
sage: C = sagenb.notebook.cell.Cell(0, '%hide\n%maxima\n2+3', '5', None) | sage: C = sagenb.notebook.cell.Cell(0, '%hide\n%maxima\n%pi+3', '5', None) | def parse_percent_directives(self): r""" Parses this compute cell's percent directives, determines its system (if any), and returns the "cleaned" input text. |
u'2+3' | u'%pi+3' | def parse_percent_directives(self): r""" Parses this compute cell's percent directives, determines its system (if any), and returns the "cleaned" input text. |
pass | directives.append(line[1:]) | def parse_percent_directives(self): r""" Parses this compute cell's percent directives, determines its system (if any), and returns the "cleaned" input text. |
directives.append(line[1:]) | directives.append(line[1:]) i += 1 break | def parse_percent_directives(self): r""" Parses this compute cell's percent directives, determines its system (if any), and returns the "cleaned" input text. |
33 | 34 | def sage_getsourcelines(obj, is_binary=False): r""" Return a pair ([source_lines], starting line number) of the source code associated to obj, or None. INPUT: - ``obj`` - function, etc. - ``is_binary`` - boolean, ignored OUTPUT: (source_lines, lineno) or None: ``source_lines`` is a list of strings, and ``lineno`` is... |
input += '_interact_.SAGE_CELL_ID=%r\n' % C.id() | input += '_interact_.SAGE_CELL_ID=%r\n__SAGE_TMP_DIR__=os.getcwd()\n' % C.id() | def start_next_comp(self): if len(self.__queue) == 0: return |
def _eval_cmd(self, system, cmd, dir): return u"print _support_.syseval(%s, %r, %r)"%(system, cmd, dir) | def _eval_cmd(self, system, cmd): return u"print _support_.syseval(%s, %r, __SAGE_TMP_DIR__)"%(system, cmd) | def _eval_cmd(self, system, cmd, dir): return u"print _support_.syseval(%s, %r, %r)"%(system, cmd, dir) |
(True, u"print _support_.syseval(gap, u'SymmetricGroup(5)', '...')") | (True, u"print _support_.syseval(gap, u'SymmetricGroup(5)', __SAGE_TMP_DIR__)") | def check_for_system_switching(self, input, cell): r""" Check for input cells that start with ``%foo``, where ``foo`` is an object with an eval method. |
cmd = self._eval_cmd(system, input, os.path.abspath(cell.directory())) | cmd = self._eval_cmd(system, input) | def check_for_system_switching(self, input, cell): r""" Check for input cells that start with ``%foo``, where ``foo`` is an object with an eval method. |
self.assert_(isinstance(v, tuple), "array value not returned as a list") | self.assert_(isinstance(v, list), "array value not returned as a list") | def testGetIntArray(self): self.assert_(self.policy.isInt("int")) v = self.policy.getArray("int") self.assert_(isinstance(v, tuple), "array value not returned as a list") truth = [-11, 0, 3, 42, -11, 0 , 3, 42, 0, 0] self.assertEquals(len(v), len(truth),"wrong number of values in array") for i in xrange(len(truth)): s... |
self.assert_(isinstance(v, tuple), "array value not returned as a list") | self.assert_(isinstance(v, list), "array value not returned as a list") | def testGetBoolArray(self): self.assert_(self.policy.isBool("true")) v = self.policy.getArray("true") self.assert_(isinstance(v, tuple), "array value not returned as a list") truth = [ True ] self.assertEquals(len(v), len(truth),"wrong number of values in array") for i in xrange(len(truth)): self.assertEquals(v[i], tr... |
self.assert_(isinstance(v, tuple), "array value not returned as a list") | self.assert_(isinstance(v, list), "array value not returned as a list") | def testGetDoublArray(self): self.assert_(self.policy.isDouble("dbl")) v = self.policy.getArray("dbl") self.assert_(isinstance(v, tuple), "array value not returned as a list") truth = [-1.0, -65.78, -14.0, -0.12, -0.12, 1.0, 65.78, 14.0, 0.12, 0.12, 1.0, 65.78, 14.0, 0.12, 0.12, -1.0e10, -65780000.0, -0.014, -0.12e14,... |
self.assert_(isinstance(v, tuple), "array value not returned as a list") | self.assert_(isinstance(v, list), "array value not returned as a list") | def testGetStringArray(self): self.assert_(self.policy.isString("str")) v = self.policy.getArray("str") self.assert_(isinstance(v, tuple), "array value not returned as a list") truth = ["word", "two words", "quoted ' words", 'quoted " words', "a very long, multi-line description", "happy", "birthday" ] self.assertEqua... |
if False: self.assert_(isinstance(v, list), "array value not returned as a list") | self.assert_(isinstance(v, list), "array value not returned as a list") | def testGetFileArray(self): self.assert_(self.policy.isFile("file")) v = self.policy.getArray("file") self.assert_(v is not None, "file array returned as None") if False: # this is be fixed in another ticket self.assert_(isinstance(v, list), "array value not returned as a list") truth = ["EventTransmitter_policy.paf",... |
truth = ["EventTransmitter_policy.paf", "CacheManager_dict.paf"] self.assertEquals(len(v), len(truth),"wrong number of values in array") self.assertEquals(v.size(), len(truth),"wrong number of values in array") for i in xrange(len(truth)): self.assertEquals(v[i].getPath, truth[i], "wrong array element at index %d: %s !... | truth = ["EventTransmitter_policy.paf", "CacheManager_dict.paf"] self.assertEquals(len(v), len(truth),"wrong number of values in array") for i in xrange(len(truth)): self.assertEquals(v[i].getPath(), truth[i], "wrong array element at index %d: %s != %s" % (i, v[i], truth[i])) | def testGetFileArray(self): self.assert_(self.policy.isFile("file")) v = self.policy.getArray("file") self.assert_(v is not None, "file array returned as None") if False: # this is be fixed in another ticket self.assert_(isinstance(v, list), "array value not returned as a list") truth = ["EventTransmitter_policy.paf",... |
if False: self.assert_(isinstance(v, list), "array value not returned as a list") | self.assert_(isinstance(v, list), "array value not returned as a list") | def testGetPolicyArray(self): self.assert_(self.policy.isPolicy("pol")) v = self.policy.getArray("pol") if False: # this is be fixed in another ticket self.assert_(isinstance(v, list), "array value not returned as a list") self.assertEquals(len(v), 2,"wrong number of values in array") self.assertEquals(v[0].get("int")... |
vs = Numeric.array(v, 'd').tostring() if len(vs)/len(v) == 8: | vs = Numeric.array(v, 'd') if vs.itemsize() == 8: | def writeVector(fp, objname, name, v, format): # Mon Jan 26 10:58:21 2009 mazer # spent some time profile and trying to speed this up... best was # to use tempfile and matlab-load() instead of matlab-eval(). This # fn is still the main cycle stealer for this module.. # # Thu Jan 29 13:51:03 2009 mazer # by writing... |
t.write(Numeric.array(v, 'd').tostring()) | t.write(vs.tostring()) | def writeVector(fp, objname, name, v, format): # Mon Jan 26 10:58:21 2009 mazer # spent some time profile and trying to speed this up... best was # to use tempfile and matlab-load() instead of matlab-eval(). This # fn is still the main cycle stealer for this module.. # # Thu Jan 29 13:51:03 2009 mazer # by writing... |
m = where(greater(m, thresh*255), 255, 1) | m = where(greater(m, thresh*255), 255, 1).astype(UnsignedInt8) | def noise(self, thresh=0.5, color=None): """Fill sprite with noise |
self.alpha[::] = 255 | def noise(self, thresh=0.5, color=None): """Fill sprite with noise | |
m = Menu(self._canvas, tearoff=0) | m = Menu(p, tearoff=0) | def __init__(self, master, cwidth=1024, cheight=768, pix_per_dva=1.0, app=None, callback=None): """UserDisplay Class. |
m.add_cascade(label='Fixspot', menu=m) | p.add_cascade(label='Fixspot', menu=m) | def __init__(self, master, cwidth=1024, cheight=768, pix_per_dva=1.0, app=None, callback=None): """UserDisplay Class. |
self.spike_times = self.spike_times[1:] | self.spike_times = self.spike_times[1::] | def compute(self, velocity=None, gaps=None, raw=None, nooffset=None): """ Note: All eye info is maintained here in PIXELS. Use pix2deg() and deg2pix() below to convert. """ if not self.computed: # this is new 13-apr-2001: try: lag = float(self.params['eyelag']) except NameError: lag = 0 # all pype files (may be [] if n... |
self.photo_times = self.photo_times[1:] | self.photo_times = self.photo_times[1::] | def compute(self, velocity=None, gaps=None, raw=None, nooffset=None): """ Note: All eye info is maintained here in PIXELS. Use pix2deg() and deg2pix() below to convert. """ if not self.computed: # this is new 13-apr-2001: try: lag = float(self.params['eyelag']) except NameError: lag = 0 # all pype files (may be [] if n... |
dx = x[1:] - x[0:-1] dy = y[1:] - y[0:-1] dt = t[1:] - t[0:-1] | dx = x[1::] - x[0:-1:] dy = y[1::] - y[0:-1:] dt = t[1::] - t[0:-1:] | def find_saccades(d, thresh=2, mindur=25, maxthresh=None): """Find all saccades in a trial Thu Apr 5 13:33:12 2001 mazer This function is carefully hand tuned. The steps are as follows: - decimates eye signal back down to 120hz (iscan speed) - compute the velocity signal - smooth velocity with a running average (5... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.