rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
d = {'__getattr__': get_module(package)} return type(package.name, (object,), d)()
d = {'__getattr__': get_module(package),} pkg = type(package.name, (object,), d)() modules = {} for (m,ns) in package.descriptors: module_desc = package.descriptors[(m,ns)] modules = create_dict(modules, ns.split('|'), m, module_desc) modules = create_namespace_path(None, modules) for (k,v) in modules.iteritems(): setattr(pkg, k, v) return pkg
def getter(self, attr_name): desc_tuple = (attr_name, '') if desc_tuple in package.descriptors: module_desc = package.descriptors[desc_tuple] d = {'_module_desc': module_desc, '_package': self,} return type('module', (vistrails_module,), d) else: raise AttributeError("type object '%s' has no attribute " "'%s'" % (self.__class__.__name__, attr_name))
(new_version, pipeline) = \ self.handle_invalid_pipeline(e, new_version, self.vistrail, report_all_errors)
try: (new_version, pipeline) = \ self.handle_invalid_pipeline(e, new_version, self.vistrail, report_all_errors) except InvalidPipeline, e: pipeline = e._pipeline
def switch_version(version, allow_fail=False): if self.current_version != -1 and not self.current_pipeline: debug.warning("current_version is not -1 and " "current_pipeline is None") if version != self.current_pipeline: # clear delayed actions # FIXME: invert the delayed actions and integrate them into # the general_action_chain? if len(self._delayed_actions) > 0: self._delayed_actions = [] self.current_pipeline = Pipeline() self.current_version = 0 if version == -1: return None
abs_vistrail, False)
abs_vistrail, False, True)
def initialize(*args, **kwargs): import core.packagemanager manager = core.packagemanager.get_package_manager() reg = core.modules.module_registry.get_module_registry()
debug.log("PORT SIG:", port.signature)
debug.log("PORT SIG:" + port.signature)
def getPortPosition(self, port, port_dict, optional_ports, next_pos, next_op, default_sig): """ getPortPosition(port: Port, port_dict: {PortSpec: QGraphicsPortItem}, optional_ports: [PortSpec], next_pos: [float, float], next_op: operator (operator.add, operator.sub), default_sig: str ) -> QPointF Return the scene position of a port matched 'port' in port_dict """ registry = get_module_registry()
obj_id=old_db_vt_id, user=db_write_user, passwd=db_write_pass)
obj_id=int(old_db_vt_id), user=db_write_user, passwd=db_write_pass)
def merge_vt(self, host, port, db_name, user, new_vt_filepath, old_db_vt_id, is_local=True): """ Merge new_vt (new_vt_filepath) with current vt (old_db_vt_id)
except Exception, e: self.server_logger.error(str(e)) return (str(e), 0) def run_from_db(self, host, port, db_name, vt_id, path_to_figures, version=None, pdf=False, vt_tag='',parameters='', is_local=True): self.server_logger.info("Request: run_vistrail_from_db(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)" % \ (host, port, db_name, vt_id, path_to_figures, version, pdf, vt_tag, parameters, is_local)) self.server_logger.info("path_exists_and_not_empty? %s" % self.path_exists_and_not_empty(path_to_figures)) self.server_logger.info(str(self.proxies_queue)) if not is_local: dest_version = "%s_%s_%d_%d_%d" % (host, db_name, int(port), int(vt_id), int(version)) dest_version = hashlib.sha1(dest_version).hexdigest() path_to_figures = os.path.join(media_dir, "wf_execution", dest_version) if (not self.path_exists_and_not_empty(path_to_figures) and self.proxies_queue is not None): self.server_logger.info("will forward request") proxy = self.proxies_queue.get() try: self.server_logger.info("Sending request to %s" % proxy) result = proxy.run_from_db(host, port, db_name, vt_id, path_to_figures, version, pdf, vt_tag, parameters, is_local) self.proxies_queue.put(proxy) self.server_logger.info("returning %s" % result) return result
except xmlrpclib.ProtocolError, err: err_msg = ("A protocol error occurred\n" "URL: %s\n" "HTTP/HTTPS headers: %s\n" "Error code: %d\n" "Error message: %s\n") % (err.url, err.headers, err.errcode, err.errmsg) self.server_logger.error(err_msg) return (str(err), 0) except Exception, e: self.server_logger.error(str(e)) return (str(e), 0) def run_from_db(self, host, port, db_name, vt_id, path_to_figures, version=None, pdf=False, vt_tag='',parameters='', is_local=True): self.server_logger.info("Request: run_vistrail_from_db(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)" % \ (host, port, db_name, vt_id, path_to_figures, version, pdf, vt_tag, parameters, is_local)) self.server_logger.info("path_exists_and_not_empty? %s" % self.path_exists_and_not_empty(path_to_figures)) self.server_logger.info(str(self.proxies_queue)) if not is_local: dest_version = "%s_%s_%d_%d_%d" % (host, db_name, int(port), int(vt_id), int(version)) dest_version = hashlib.sha1(dest_version).hexdigest() path_to_figures = os.path.join(media_dir, "wf_execution", dest_version) if (not self.path_exists_and_not_empty(path_to_figures) and self.proxies_queue is not None): self.server_logger.info("will forward request") proxy = self.proxies_queue.get() try: self.server_logger.info("Sending request to %s" % proxy) result = proxy.run_from_db(host, port, db_name, vt_id, path_to_figures, version, pdf, vt_tag, parameters, is_local) self.proxies_queue.put(proxy) self.server_logger.info("returning %s" % result) return result except xmlrpclib.ProtocolError, err: err_msg = ("A protocol error occurred\n" "URL: %s\n" "HTTP/HTTPS headers: %s\n" "Error code: %d\n" "Error message: %s\n") % (err.url, err.headers, err.errcode, err.errmsg) self.server_logger.error(err_msg) return (str(err), 0)
def executeMedley(self, xml_medley, extra_info=None): self.server_logger.info("executeMedley request received") try: self.server_logger.info(xml_medley) xml_string = xml_medley.replace('\\"','"') root = ElementTree.fromstring(xml_string) try: medley = MedleySimpleGUI.from_xml(root) except: #even if this error occurred there's still a chance of # recovering from it... (the server can find cached images) self.server_logger.error("couldn't instantiate medley")
obj_id=vt_id,
obj_id=int(vt_id),
def get_wf_graph_pdf(self, host, port, db_name, vt_id, version, is_local=True): """get_wf_graph_pdf(host:str, port:int, db_name:str, vt_id:int, version:int) -> str Returns the relative url to the generated PDF """ self.server_logger.info("get_wf_graph_pdf(%s,%s,%s,%s,%s) request received" % \ (host, port, db_name, vt_id, version)) try: vt_id = long(vt_id) version = long(version) subdir = 'workflows' filepath = os.path.join(media_dir, 'graphs', subdir) base_fname = "graph_%s_%s.pdf" % (vt_id, version) filename = os.path.join(filepath,base_fname) if ((not os.path.exists(filepath) or os.path.exists(filepath) and not os.path.exists(filename)) and self.proxies_queue is not None): #this server can send requests to other instances proxy = self.proxies_queue.get() try: result = proxy.get_wf_graph_pdf(host,port,db_name, vt_id, version, is_local) self.proxies_queue.put(proxy) self.server_logger.info("get_wf_graph_pdf returning %s"% result) return result except Exception, e: self.server_logger.error(str(e)) return (str(e), 0)
obj_id=vt_id,
obj_id=int(vt_id),
def get_wf_graph_png(self, host, port, db_name, vt_id, version, is_local=True): """get_wf_graph_png(host:str, port:int, db_name:str, vt_id:int, version:int) -> str Returns the relative url to the generated image """ self.server_logger.info("get_wf_graph_png(%s,%s,%s,%s,%s) request received" % \ (host, port, db_name, vt_id, version)) try: vt_id = long(vt_id) version = long(version) subdir = 'workflows' filepath = os.path.join(media_dir, 'graphs', subdir) base_fname = "graph_%s_%s.png" % (vt_id, version) filename = os.path.join(filepath,base_fname) if ((not os.path.exists(filepath) or os.path.exists(filepath) and not os.path.exists(filename)) and self.proxies_queue is not None): #this server can send requests to other instances proxy = self.proxies_queue.get() try: self.server_logger.info("Sending request to %s" % proxy) result = proxy.get_wf_graph_png(host, port, db_name, vt_id, version, is_local) self.proxies_queue.put(proxy) self.server_logger.info("returning %s" % result) return result except Exception, e: self.server_logger.error(str(e)) return (str(e), 0) #if it gets here, this means that we will execute on this instance if not os.path.exists(filepath): os.mkdir(filepath)
obj_id=vt_id,
obj_id=int(vt_id),
def get_vt_graph_png(self, host, port, db_name, vt_id, is_local=True): """get_vt_graph_png(host:str, port: str, db_name: str, vt_id:str) -> str Returns the relative url of the generated image """
obj_id=vt_id,
obj_id=int(vt_id),
def get_vt_graph_pdf(self, host, port, db_name, vt_id, is_local=True): """get_vt_graph_pdf(host:str, port: str, db_name: str, vt_id:str) -> str Returns the relative url of the generated image """
self.setResult("d", d)
self.setResult("value", d)
def dict_compute(self): d = {} if self.hasInputFromPort('value'): Constant.compute(self) d.update(self.outputPorts['value']) if self.hasInputFromPort('addPair'): pairs_list = self.getInputListFromPort('addPair') d.update(pairs_list) if self.hasInputFromPort('addPairs'): d.update(self.getInputFromPort('addPairs')) self.setResult("d", d)
visibleOptionalPorts = []
visibleOptionalInputPorts = []
def setupModule(self, module): """ setupModule(module: Module) -> None Set up the item to reflect the info in 'module' """ # Update module info and visual self.id = module.id self.setZValue(float(self.id)) self.module = module self.center = copy.copy(module.center) if '__desc__' in module.db_annotations_key_index: self.label = module.get_annotation_by_key('__desc__').value.strip() self.description = module.label else: self.label = module.label self.description = '' self.setToolTip(self.description) self.computeBoundingRect() self.resetMatrix() self.translate(module.center.x, -module.center.y)
visibleOptionalPorts = []
visibleOptionalOutputPorts = []
def setupModule(self, module): """ setupModule(module: Module) -> None Set up the item to reflect the info in 'module' """ # Update module info and visual self.id = module.id self.setZValue(float(self.id)) self.module = module self.center = copy.copy(module.center) if '__desc__' in module.db_annotations_key_index: self.label = module.get_annotation_by_key('__desc__').value.strip() self.description = module.label else: self.label = module.label self.description = '' self.setToolTip(self.description) self.computeBoundingRect() self.resetMatrix() self.translate(module.center.x, -module.center.y)
visibleOptionalPorts.append(p)
visibleOptionalInputPorts.append(p)
def setupModule(self, module): """ setupModule(module: Module) -> None Set up the item to reflect the info in 'module' """ # Update module info and visual self.id = module.id self.setZValue(float(self.id)) self.module = module self.center = copy.copy(module.center) if '__desc__' in module.db_annotations_key_index: self.label = module.get_annotation_by_key('__desc__').value.strip() self.description = module.label else: self.label = module.label self.description = '' self.setToolTip(self.description) self.computeBoundingRect() self.resetMatrix() self.translate(module.center.x, -module.center.y)
inputPorts += visibleOptionalPorts
inputPorts += visibleOptionalInputPorts
def setupModule(self, module): """ setupModule(module: Module) -> None Set up the item to reflect the info in 'module' """ # Update module info and visual self.id = module.id self.setZValue(float(self.id)) self.module = module self.center = copy.copy(module.center) if '__desc__' in module.db_annotations_key_index: self.label = module.get_annotation_by_key('__desc__').value.strip() self.description = module.label else: self.label = module.label self.description = '' self.setToolTip(self.description) self.computeBoundingRect() self.resetMatrix() self.translate(module.center.x, -module.center.y)
visibleOptionalPorts.append(p)
visibleOptionalOutputPorts.append(p)
def setupModule(self, module): """ setupModule(module: Module) -> None Set up the item to reflect the info in 'module' """ # Update module info and visual self.id = module.id self.setZValue(float(self.id)) self.module = module self.center = copy.copy(module.center) if '__desc__' in module.db_annotations_key_index: self.label = module.get_annotation_by_key('__desc__').value.strip() self.description = module.label else: self.label = module.label self.description = '' self.setToolTip(self.description) self.computeBoundingRect() self.resetMatrix() self.translate(module.center.x, -module.center.y)
outputPorts += visibleOptionalPorts
outputPorts += visibleOptionalOutputPorts
def setupModule(self, module): """ setupModule(module: Module) -> None Set up the item to reflect the info in 'module' """ # Update module info and visual self.id = module.id self.setZValue(float(self.id)) self.module = module self.center = copy.copy(module.center) if '__desc__' in module.db_annotations_key_index: self.label = module.get_annotation_by_key('__desc__').value.strip() self.description = module.label else: self.label = module.label self.description = '' self.setToolTip(self.description) self.computeBoundingRect() self.resetMatrix() self.translate(module.center.x, -module.center.y)
if self.modules[m_id].isSelected:
if self.modules[m_id].isSelected():
def setupScene(self, pipeline): """ setupScene(pipeline: Pipeline) -> None Construct the scene to view a pipeline """ old_pipeline = self.pipeline self.pipeline = pipeline
if tm_item.isSelected:
if tm_item.isSelected():
def setupScene(self, pipeline): """ setupScene(pipeline: Pipeline) -> None Construct the scene to view a pipeline """ old_pipeline = self.pipeline self.pipeline = pipeline
tar_bin = configuration.git_bin
tar_bin = configuration.tar_bin
def initialize(): global global_db, local_db, search_dbs, compress_by_default, db_access, \ git_bin, tar_bin, debug if configuration.check('git_bin'): git_bin = configuration.git_bin if git_bin.startswith("@executable_path/"): non_expand_path = git_bin git_bin = get_executable_path(git_bin[len("@executable_path/"):]) if git_bin is not None: configuration.git_bin = non_expand_path if git_bin is None: git_bin = 'git' configuration.git_bin = git_bin if configuration.check('tar_bin'): tar_bin = configuration.git_bin if tar_bin.startswith("@executable_path/"): non_expand_path = tar_bin tar_bin = get_executable_path(tar_bin[len("@executable_path/"):]) if tar_bin is not None: configuration.tar_bin = non_expand_path if tar_bin is None: tar_bin = 'tar' configuration.tar_bin = tar_bin if configuration.check('compress_by_default'): compress_by_default = configuration.compress_by_default if configuration.check('debug'): debug = configuration.debug if configuration.check('global_db'): global_db = configuration.global_db if configuration.check('local_db'): local_db = configuration.local_db if not os.path.exists(local_db): raise Exception('local_db "%s" does not exist' % local_db) else: local_db = os.path.join(default_dot_vistrails(), 'persistent_files') if not os.path.exists(local_db): try: os.mkdir(local_db) except: raise Exception('local_db "%s" does not exist' % local_db) git_init(local_db) debug_print('creating DatabaseAccess') db_path = os.path.join(local_db, '.files.db') db_access = DatabaseAccessSingleton(db_path) debug_print('done', db_access) search_dbs = [local_db,] if configuration.check('search_dbs'): try: check_paths = eval(configuration.search_dbs) except: print "*** persistence error: cannot parse search_dbs ***" for path in check_paths: if os.path.exists(path): search_dbs.append(path) else: print '*** persistence warning: cannot find path "%s"' % path
qual_name += m if qual_name not in self._existing_paths and not qual_name.endswith('_rc'): self._imported_paths.add(qual_name) qual_name += '.'
qual_name += m if qual_name not in self._existing_paths and \ not qual_name.endswith('_rc'): self._imported_paths.add(qual_name) qual_name += '.' if fromlist is not None: for from_module in fromlist: qual_name = res_name + '.' + from_module if qual_name not in self._existing_paths and \ not qual_name.endswith('_rc'): self._imported_paths.add(qual_name)
def _import(self, name, globals=None, locals=None, fromlist=None, level=-1): # if name != 'core.modules.module_registry': # print 'running import', name, fromlist res = apply(self._real_import, (name, globals, locals, fromlist, level)) if len(name) > len(res.__name__): res_name = name else: res_name = res.__name__ qual_name = '' for m in res_name.split('.'): qual_name += m if qual_name not in self._existing_paths and not qual_name.endswith('_rc'): # print ' adding', name, qual_name self._imported_paths.add(qual_name) # else: # if name != 'core.modules.module_registry': # print ' already exists', name, res.__name__
self._branch_button.hide()
def check_dependencies(self, index): """ determines if current VisTrail will be supported by the repository's VisTrail server """
self.unsupported_packages = filter(lambda p: p not in \ server_packages, local_packages)
def check_dependencies(self, index): """ determines if current VisTrail will be supported by the repository's VisTrail server """
print "save login state: ", self.saveLogin.checkState()
def clicked_on_login(self): """ Attempts to log into web repository stores auth cookie for session """ from gui.application import VistrailsApplication
print "save repo login checked"
def clicked_on_login(self): """ Attempts to log into web repository stores auth cookie for session """ from gui.application import VistrailsApplication
print "setting repo login" print self.dialog.loginUser.text()
def clicked_on_login(self): """ Attempts to log into web repository stores auth cookie for session """ from gui.application import VistrailsApplication
print "save repo login unchecked"
def clicked_on_login(self): """ Attempts to log into web repository stores auth cookie for session """ from gui.application import VistrailsApplication
print "removing repo login"
def clicked_on_login(self): """ Attempts to log into web repository stores auth cookie for session """ from gui.application import VistrailsApplication
for (m, n) in neighbors]
for (m, n) in neighbors if (Module.vtType, m.id) in id_remap]
def create_ungroup(self, full_pipeline, module_id):
cmdline = ['unzip', '-q','-o','-d', vt_save_dir, filename]
cmdline = ['unzip', '-q','-o','-d', vt_save_dir, shell_quote(filename)]
def open_vistrail_bundle_from_zip_xml(filename): """open_vistrail_bundle_from_zip_xml(filename) -> SaveBundle Open a vistrail from a zip compressed format. It expects that the vistrail file inside archive has name 'vistrail', the log inside archive has name 'log', abstractions inside archive have prefix 'abstraction_', and thumbnails inside archive are '.png' files in 'thumbs' dir """ core.requirements.require_executable('unzip') vt_save_dir = tempfile.mkdtemp(prefix='vt_save') output = [] cmdline = ['unzip', '-q','-o','-d', vt_save_dir, filename] result = execute_cmdline(cmdline, output) if result != 0 and len(output) != 0: raise VistrailsDBException("Unzip of '%s' failed" % filename) vistrail = None log = None log_fname = None abstraction_files = [] unknown_files = [] thumbnail_files = [] try: for root, dirs, files in os.walk(vt_save_dir): for fname in files: if fname == 'vistrail' and root == vt_save_dir: vistrail = open_vistrail_from_xml(os.path.join(root, fname)) elif fname == 'log' and root == vt_save_dir: # FIXME read log to get execution info # right now, just ignore the file log = None log_fname = os.path.join(root, fname) # log = open_log_from_xml(os.path.join(root, fname)) # objs.append(DBLog.vtType, log) elif fname.startswith('abstraction_'): abstraction_file = os.path.join(root, fname) abstraction_files.append(abstraction_file) elif (fname.endswith('.png') and root == os.path.join(vt_save_dir,'thumbs')): thumbnail_file = os.path.join(root, fname) thumbnail_files.append(thumbnail_file) else: unknown_files.append(os.path.join(root, fname)) except OSError, e: raise VistrailsDBException("Error when reading vt file") if len(unknown_files) > 0: raise VistrailsDBException("Unknown files in vt file: %s" % \ unknown_files) if vistrail is None: raise VistrailsDBException("vt file does not contain vistrail") vistrail.db_log_filename = log_fname save_bundle = SaveBundle(DBVistrail.vtType, vistrail, log, abstractions=abstraction_files, thumbnails=thumbnail_files) return (save_bundle, vt_save_dir)
self.DEBUG_FILTER_BACKGROUND_COLOR = QtGui.QColor(" class MacTheme(DefaultTheme): def __init__(self):
def __init__(self): """ DefaultTheme() -> DefaultTheme This is for initializing all Qt objects """ ###################### #### MEASUREMENTS ####
self.DEBUG_FILTER_BACKGROUND_COLOR = QTransparentColor("transparent")
def name(self): return 'transparent'
cmd_list = [self.git_command() + \
if systemType == "Windows": cmd_list = [self.git_command() + \ ["archive", str(version + ':' + name)], ["%s:" % out_dirname[0], "&&", "cd", "%s"%out_dirname, "&&", 'tar', '-xf-']] else: cmd_list = [self.git_command() + \
def git_get_dir(self, name, version="HEAD", out_dirname=None): global temp_persist_files if out_dirname is None: # create a temporary directory out_dirname = tempfile.mkdtemp(prefix='vt_persist') temp_persist_files.append(out_dirname) cmd_list = [self.git_command() + \ ["archive", str(version + ':' + name)], ['tar', '-C', out_dirname, '-xf-']] debug_print('executing commands', cmd_list) result, output, errs = execute_piped_cmdlines(cmd_list) debug_print('stdout:', type(output), output) debug_print('stderr:', type(errs), errs) if result != 0: # check output for error messages raise ModuleError(self, "Error retrieving file '%s'\n" % name + errs) return out_dirname
if operation.data.vtType == Abstraction.vtType:
if operation.data is not None and operation.data.vtType == Abstraction.vtType:
def find_abstractions(self, vistrail, recurse=False): abstractions = [] for action in vistrail.actions: for operation in action.operations: if operation.vtType == 'add' or \ operation.vtType == 'change': if operation.data.vtType == Abstraction.vtType: abstraction = operation.data if abstraction.package == abstraction_pkg: abstractions.append(abstraction) if recurse: for abstraction in abstractions: try: vistrail = abstraction.vistrail except MissingPackageVersion, e: reg = core.modules.module_registry.get_module_registry() abstraction._module_descriptor = \ reg.get_similar_descriptor(*abstraction.descriptor_info) vistrail = abstraction.vistrail abstractions.extend(self.find_abstractions(vistrail, recurse)) return abstractions
new_id = self.perform_action(action)
def add_parameter_changes_from_execution(self, pipeline, version, parameter_changes): """add_parameter_changes_from_execution(pipeline, version, parameter_changes) -> int.
return new_id
return action.id
def add_parameter_changes_from_execution(self, pipeline, version, parameter_changes): """add_parameter_changes_from_execution(pipeline, version, parameter_changes) -> int.
self.setupDefaultFolders()
def init(self): """ init() -> None Initialize VisTrails with optionsDict. optionsDict can be another VisTrails Configuration object, e.g. ConfigurationObject """ if self._do_load_packages: self.load_packages() self.setupDefaultFolders() if self._do_load_packages: # don't call this anymore since we do an add_package for it now # self.setupBaseModules() self.installPackages() self.runStartupHooks()
def mouseReleaseEvent(self, e): """mousePressEvent(e) -> None Keep the cursor after the last prompt. """ if e.button() == QtCore.Qt.LeftButton: self.copy() cursor = self.textCursor() cursor.movePosition(QtGui.QTextCursor.End) self.setTextCursor(cursor) return
def focusNextPrevChild(self, next): """focusNextPrevChild(next) -> None Suppress tabbing to the next window in multi-line commands. """ if next and self.more: return 0 return QtGui.QTextEdit.focusNextPrevChild(self, next)
user = ""
data = node.get('user') user = convert_from_str(data, 'str')
def bool_conv(x): s = str(x).upper() if s == 'TRUE': return True if s == 'FALSE': return False
data = convert_data(op.db_data)
data = convert_data(op.db_data, op.db_parentObjType, op.db_parentObjId)
def translateVistrail(_vistrail): vistrail = DBVistrail() for _action in _vistrail.db_actions.itervalues(): ops = [] for op in _action.db_operations: if op.vtType == 'add': data = convert_data(op.db_data) ops.append(DBAdd(id=op.db_id, what=op.db_what, objectId=op.db_objectId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType, data=data)) elif op.vtType == 'change': data = convert_data(op.db_data) ops.append(DBChange(id=op.db_id, what=op.db_what, oldObjId=op.db_oldObjId, newObjId=op.db_newObjId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType, data=data)) elif op.vtType == 'delete': ops.append(DBDelete(id=op.db_id, what=op.db_what, objectId=op.db_objectId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType)) action = DBAction(id=_action.db_id, prevId=_action.db_prevId, date=_action.db_date, user=_action.db_user, operations=ops, annotations=_action.db_annotations.values()) vistrail.db_add_action(action) for _tag in _vistrail.db_tags.itervalues(): tag = DBTag(id=_tag.db_id, name=_tag.db_name) vistrail.db_add_tag(tag) vistrail.db_version = '0.7.0' return vistrail
if tuple(vtk.vtkVersion().GetVTKVersion().split('.')) < ('5', '7', '0'): def get_method_signature(method): """ get_method_signature(method: vtkmethod) -> [ret, arg] Re-wrap Prabu's method to increase performance """ doc = method.__doc__ tmp = doc.split('\n') sig = [] pat = re.compile(r'\b') offset = 2+len(method.__name__) for i in xrange(len(tmp)): s = tmp[i] if s=='': break if i%2==0: x = s.split('->') arg = x[0].strip()[offset:] if len(x) == 1: ret = None
def get_method_signature(method): """ get_method_signature(method: vtkmethod) -> [ret, arg] Re-wrap Prabu's method to increase performance """ doc = method.__doc__ tmp = doc.split('\n') sig = [] pat = re.compile(r'\b') offset = 2+len(method.__name__) for i in xrange(len(tmp)): s = tmp[i] if s=='': break if i%2==0: x = s.split('->') arg = x[0].strip()[offset:] if len(x) == 1: ret = None else: ret = x[1].strip() arg = arg[1:-1] if not arg: arg = None if arg and arg[-1] == ')': arg = arg + ',' if ret and ret[:3]!='vtk': ret = eval(pat.sub('\"', ret)) if arg: if arg.find('(')!=-1: arg = eval(pat.sub('\"', arg))
def typeMap(name, package=None): """ typeMap(name: str) -> Module Convert from C/C++ types into VisTrails Module type """ if package is None: package = identifier if type(name) == tuple: return [typeMap(x, package) for x in name] if name in typeMapDict: return typeMapDict[name] else: registry = get_module_registry() if not registry.has_descriptor_with_name(package, name): return None else: return registry.get_descriptor_by_name(package, name).module
ret = x[1].strip() arg = arg[1:-1] if not arg: arg = None if arg and arg[-1] == ')': arg = arg + ',' if ret and ret[:3]!='vtk': ret = eval(pat.sub('\"', ret)) if arg: if arg.find('(')!=-1: arg = eval(pat.sub('\"', arg))
arg = arg.split(', ') if len(arg)>1: arg = tuple(arg)
def get_method_signature(method): """ get_method_signature(method: vtkmethod) -> [ret, arg] Re-wrap Prabu's method to increase performance
arg = arg.split(', ') if len(arg)>1: arg = tuple(arg) else: arg = arg[0] if type(arg) == str: arg = [arg] sig.append(([ret], arg)) return sig else: funcRE = re.compile(r'^(virtual|static)*([\w\d\s*&]+[\s*&])([\w\d]+)\(([\w\d\s,=-\[\]*&]*)\)', re.MULTILINE) paramRE = re.compile(r'(const\s+)*(([\w\d]+\s?)+?([*&\s]?|\b))[^=\[*]*(\[\d*\])*(\=.*)*') C2PMap = { 'unsigned': 'int', 'int': 'int', 'float': 'float', 'char': 'char', 'short': 'int', 'id': 'int', 'signed': 'int', 'double': 'float', 'long': 'int', 'bool': 'bool', 'int': 'int', 'void': 'None', 'void *': 'string', 'char *': 'string', } def convertToPythonType(pType): pType = pType.strip() m = paramRE.match(pType) if m==None: return None pType = m.group(2) if pType[:3]!='vtk': pType = pType.strip() if pType in C2PMap: pType = C2PMap[pType] else: return None else: pType = pType.replace('*', '') pType = pType.replace('&', '') pType = pType.strip() arrayStr = m.group(5) if arrayStr!=None: count = int(arrayStr[1:-1]) pType = tuple([pType]*count) return pType def get_method_signature(method): """ get_method_signature(method: vtkmethod) -> [ret, arg] Re-wrap Prabu's method to increase performance """ doc = method.__doc__ sig = [] for m in funcRE.finditer(doc): fName = m.group(3) retType = convertToPythonType(m.group(2)) argType = tuple([convertToPythonType(a) for a in m.group(4).split(',')]) if None not in argType: sig.append(([retType], argType)) return sig
arg = arg[0] if type(arg) == str: arg = [arg] sig.append(([ret], arg)) return sig
def get_method_signature(method): """ get_method_signature(method: vtkmethod) -> [ret, arg] Re-wrap Prabu's method to increase performance
self.mRenWin.Render()
if self.mRenWin.GetInteractor(): self.mRenWin.GetInteractor().Render() else: self.mRenWin.Render()
def resizeEvent(self, e): """ resizeEvent(e: QEvent) -> None Re-adjust the vtkRenderWindow size then QVTKWidget resized """ qt_super(QVTKWidget, self).resizeEvent(e) if not self.mRenWin: return
self.mRenWin.Render()
if self.mRenWin.GetInteractor(): self.mRenWin.GetInteractor().Render() else: self.mRenWin.Render()
def paintEvent(self, e): """ paintEvent(e: QPaintEvent) -> None Paint the QVTKWidget with vtkRenderWindow """ iren = None if self.mRenWin: iren = self.mRenWin.GetInteractor()
self.mRenWin.Render() self.mRenWin.Render()
if self.mRenWin.GetInteractor(): self.mRenWin.GetInteractor().Render() self.mRenWin.GetInteractor().Render() else: self.mRenWin.Render() self.mRenWin.Render()
def saveToPNG(self, filename): """ saveToPNG(filename: str) -> filename or vtkUnsignedCharArray Save the current widget contents to an image file. If str==None, then it returns the vtkUnsignedCharArray containing the PNG image. Otherwise, the filename is returned. """ w2i = vtk.vtkWindowToImageFilter() w2i.ReadFrontBufferOff() w2i.SetInput(self.mRenWin) # Render twice to get a clean image on the back buffer self.mRenWin.Render() self.mRenWin.Render() w2i.Update() writer = vtk.vtkPNGWriter() writer.SetInputConnection(w2i.GetOutputPort()) if filename!=None: writer.SetFileName(filename) else: writer.WriteToMemoryOn() writer.Write() if filename: return filename else: return writer.GetResult()
return self.perform_action(action)
res = self.perform_action(action) self.current_pipeline.ensure_modules_are_on_registry( [m.id for m in modules]) self.current_pipeline.ensure_connection_specs( [c.id for c in connections]) return res
def create_ungroup(self, module_id): (modules, connections) = \ BaseController.create_ungroup(self, self.current_pipeline, module_id) pipeline = self.current_pipeline old_conn_ids = self.get_module_connection_ids([module_id], pipeline.graph) op_list = [] op_list.extend(('delete', pipeline.connections[c_id]) for c_id in old_conn_ids) op_list.append(('delete', pipeline.modules[module_id])) op_list.extend(('add', m) for m in modules) op_list.extend(('add', c) for c in connections) action = core.db.action.create_action(op_list) self.add_new_action(action) return self.perform_action(action)
cmd_list = [["echo", str(version + ':' + name)], self.git_command() + ["cat-file", "--batch-check"]]
cmd_list = [self.git_command() + ["cat-file", "-t", str(version + ':' + name)]]
def git_get_type(self, name, version="HEAD"): cmd_list = [["echo", str(version + ':' + name)], self.git_command() + ["cat-file", "--batch-check"]] debug_print('executing commands', cmd_list) result, output, errs = execute_piped_cmdlines(cmd_list) debug_print('stdout:', type(output), output) debug_print('stderr:', type(errs), errs) if result != 0: # check output for error messages raise ModuleError(self, "Error retrieving file '%s'" % name + errs) return output.split(None, 2)[1]
return output.split(None, 2)[1]
return output.split(None,1)[0]
def git_get_type(self, name, version="HEAD"): cmd_list = [["echo", str(version + ':' + name)], self.git_command() + ["cat-file", "--batch-check"]] debug_print('executing commands', cmd_list) result, output, errs = execute_piped_cmdlines(cmd_list) debug_print('stdout:', type(output), output) debug_print('stderr:', type(errs), errs) if result != 0: # check output for error messages raise ModuleError(self, "Error retrieving file '%s'" % name + errs) return output.split(None, 2)[1]
if invalid_module.internal_version != invalid_module.module_descriptor.version:
desc = None try:
def attempt_automatic_upgrade(controller, pipeline, module_id, function_remap={}, src_port_remap={}, dst_port_remap={}, annotation_remap={}): """attempt_automatic_upgrade(module_id, pipeline): [Action]
else: abs_fname = invalid_module.module_descriptor.module.vt_fname abs_name = controller.parse_abstraction_name(abs_fname) lookup = {abs_name: abs_fname} descriptor_info = invalid_module.descriptor_info newest_version = str(invalid_module.vistrail.get_latest_version()) desc = controller.check_abstraction((descriptor_info[0], descriptor_info[1], descriptor_info[2], descriptor_info[3], newest_version), lookup) desired_version = desc.version
except: pass if desc is not None: if invalid_module.internal_version != desc.version: pass else: abs_fname = invalid_module.module_descriptor.module.vt_fname abs_name = controller.parse_abstraction_name(abs_fname) lookup = {abs_name: abs_fname} descriptor_info = invalid_module.descriptor_info newest_version = str(invalid_module.vistrail.get_latest_version()) desc = controller.check_abstraction((descriptor_info[0], descriptor_info[1], descriptor_info[2], descriptor_info[3], newest_version), lookup) desired_version = desc.version
def attempt_automatic_upgrade(controller, pipeline, module_id, function_remap={}, src_port_remap={}, dst_port_remap={}, annotation_remap={}): """attempt_automatic_upgrade(module_id, pipeline): [Action]
""" paintEvent(e: QPaintEvent) -> QPaintEngine
""" paintEngine() -> QPaintEngine
def paintEngine(self): """ paintEvent(e: QPaintEvent) -> QPaintEngine On Windows, this has to return None to fully disable double-buffer (we let vtkRenderWindow handle this instead). """ if system.systemType=='Win32': return None else: return QCellWidget.paintEngine(self)
if system.systemType=='Win32':
if system.systemType in ['Windows', 'Microsoft']:
def paintEngine(self): """ paintEvent(e: QPaintEvent) -> QPaintEngine On Windows, this has to return None to fully disable double-buffer (we let vtkRenderWindow handle this instead). """ if system.systemType=='Win32': return None else: return QCellWidget.paintEngine(self)
if exPipe:
if exPipe is not None:
def compute(self): exPipe = self.forceGetInputFromPort('ExternalPipe') if exPipe: self.setResult('InternalPipe', exPipe) else: self.setResult('InternalPipe', InvalidOutput)
if type(sig_item) == __builtin__.type: return (sig_item, '<no description>') elif type(sig_item) == __builtin__.tuple:
if type(sig_item) == __builtin__.tuple:
def canonicalize(sig_item): if type(sig_item) == __builtin__.type: return (sig_item, '<no description>') elif type(sig_item) == __builtin__.tuple: # assert len(sig_item) == 2 # assert type(sig_item[0]) == __builtin__.type # assert type(sig_item[1]) == __builtin__.str return sig_item elif type(sig_item) == __builtin__.list: return (registry.get_descriptor_by_name('edu.utah.sci.vistrails.basic', 'List').module, '<no description>')
handler = logging.handlers.RotatingFileHandler(f, maxBytes=1024*1024, backupCount=5)
import core.system if core.system.systemType in ["Windows", "Microsoft"]: rotate_file_if_necessary(f) handler = logging.FileHandler(f) else: handler = logging.handlers.RotatingFileHandler(f, maxBytes=1024*1024, backupCount=5)
def set_logfile(self, f): """set_logfile(file) -> None. Redirects debugging output to file.""" try: handler = logging.handlers.RotatingFileHandler(f, maxBytes=1024*1024, backupCount=5) handler.setFormatter(self.format) handler.setLevel(logging.DEBUG) if self.fhandler: self.logger.removeHandler(self.fhandler) self.fhandler = handler self.logger.addHandler(handler)
def git_get_hash(self, name, version="HEAD"): cmd_list = [["echo", str(version + ':' + name)], self.git_command() + ["cat-file", "--batch-check"]]
def git_get_hash(self, name): cmd_list = [self.git_command() + ["ls-files", "--stage", str(name)]]
def git_get_hash(self, name, version="HEAD"): cmd_list = [["echo", str(version + ':' + name)], self.git_command() + ["cat-file", "--batch-check"]] debug_print('executing commands', cmd_list) result, output, errs = execute_piped_cmdlines(cmd_list) debug_print('stdout:', type(output), output) debug_print('stderr:', type(errs), errs) if result != 0: # check output for error messages raise ModuleError(self, "Error retrieving file '%s'\n" % name + errs) return output.split(None, 1)[0]
return output.split(None, 1)[0]
return output.split(None, 2)[1]
def git_get_hash(self, name, version="HEAD"): cmd_list = [["echo", str(version + ':' + name)], self.git_command() + ["cat-file", "--batch-check"]] debug_print('executing commands', cmd_list) result, output, errs = execute_piped_cmdlines(cmd_list) debug_print('stdout:', type(output), output) debug_print('stderr:', type(errs), errs) if result != 0: # check output for error messages raise ModuleError(self, "Error retrieving file '%s'\n" % name + errs) return output.split(None, 1)[0]
context['commands'] = [] context['contains'] = [] import pmxbot.pmxbot as p p.run(configInput = context['config'], start=False) for typ, name, f, doc, channels, exclude, rate in sorted(p._handler_registry, key=lambda x: x[1]): if typ == 'command': aliases = sorted([x[1] for x in p._handler_registry if x[0] == 'alias' and x[2] == f]) context['commands'].append((name, doc, aliases)) elif typ == 'contains': context['contains'].append((name, doc))
if not self.run: self.commands = [] self.contains = [] import pmxbot.pmxbot as p p.run(configInput = context['config'], start=False) for typ, name, f, doc, channels, exclude, rate in sorted(p._handler_registry, key=lambda x: x[1]): if typ == 'command': aliases = sorted([x[1] for x in p._handler_registry if x[0] == 'alias' and x[2] == f]) self.commands.append((name, doc, aliases)) elif typ == 'contains': self.contains.append((name, doc)) self.run = True context['commands'] = self.commands context['contains'] = self.contains
def default(self): page = jenv.get_template('help.html') context = get_context() context['commands'] = [] context['contains'] = [] import pmxbot.pmxbot as p p.run(configInput = context['config'], start=False) for typ, name, f, doc, channels, exclude, rate in sorted(p._handler_registry, key=lambda x: x[1]): if typ == 'command': aliases = sorted([x[1] for x in p._handler_registry if x[0] == 'alias' and x[2] == f]) context['commands'].append((name, doc, aliases)) elif typ == 'contains': context['contains'].append((name, doc)) return page.render(**context)
self.assertRaises(Exception, test_view('ldap_connection'))
test_view('ldap_connection')
def test0005views(self): ''' Test views. ''' self.assertRaises(Exception, test_view('ldap_connection'))
scale = diff_time
scale = diff_time / (self.scale_x)
def onTimer(self, timer): new_time = time() diff_time = new_time - self.cur_time self.cur_time = new_time
queue1.put(('startobsblock',) + tuple(args))
queue1.put(args)
def startobsblock(self, args): _logger.info('Received start observing block command') queue1.put(('startobsblock',) + tuple(args))
hdulist.writeto('data/' + filename, clobber=True)
hdulist.writeto(os.path.join(datadir, filename), clobber=True)
def store_image(bindata, index): # Convert binary data back to HDUList handle = StringIO.StringIO(bindata) hdulist = pyfits.open(handle) # Write to disk filename = FORMAT % index hdulist.writeto('data/' + filename, clobber=True) # Update database img = Images(filename) img.exposure = hdulist[0].header['EXPOSED'] img.imgtype = hdulist[0].header['IMGTYP'] img.stamp = datetime.datetime.utcnow() ob.images.append(img) session.commit()
activity_toolbar = toolbox.get_activity_toolbar()
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
goicon_bw = gtk.Image() goicon_bw.set_from_file("%s/icons/run_bw.svg" % os.getcwd()) goicon_color = gtk.Image() goicon_color.set_from_file("%s/icons/run_color.svg" % os.getcwd()) gobutton = ToolButton(label=_("_Run!")) gobutton.props.accelerator = _('<alt>r') gobutton.set_icon_widget(goicon_bw) gobutton.set_tooltip("Run") gobutton.connect('clicked', self.flash_cb, dict({'bw':goicon_bw, 'color':goicon_color})) gobutton.connect('clicked', self.gobutton_cb) activity_toolbar.insert(gobutton, 2) stopicon_bw = gtk.Image() stopicon_bw.set_from_file("%s/icons/stopit_bw.svg" % os.getcwd()) stopicon_color = gtk.Image() stopicon_color.set_from_file("%s/icons/stopit_color.svg" % os.getcwd()) stopbutton = ToolButton(label=_("_Stop")) stopbutton.props.accelerator = _('<alt>s') stopbutton.set_icon_widget(stopicon_bw) stopbutton.connect('clicked', self.flash_cb, dict({'bw':stopicon_bw, 'color':stopicon_color})) stopbutton.connect('clicked', self.stopbutton_cb) stopbutton.set_tooltip("Stop Running") activity_toolbar.insert(stopbutton, 3) clearicon_bw = gtk.Image() clearicon_bw.set_from_file("%s/icons/eraser_bw.svg" % os.getcwd()) clearicon_color = gtk.Image() clearicon_color.set_from_file("%s/icons/eraser_color.svg" % os.getcwd()) clearbutton = ToolButton(label=_("_Clear")) clearbutton.props.accelerator = _('<alt>c') clearbutton.set_icon_widget(clearicon_bw) clearbutton.connect('clicked', self.clearbutton_cb) clearbutton.connect('clicked', self.flash_cb, dict({'bw':clearicon_bw, 'color':clearicon_color})) clearbutton.set_tooltip("Clear") activity_toolbar.insert(clearbutton, 4) separator = gtk.SeparatorToolItem() separator.set_draw(True) activity_toolbar.insert(separator, 5)
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
hpane = gtk.HPaned() vpane = gtk.VPaned()
hbox = gtk.HBox() vbox = gtk.VBox()
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
treeview.set_size_request(int(SIZE_X * 0.3), SIZE_Y)
treeview.set_size_request(220, 900)
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
hpane.add1(sidebar)
hbox.pack_start(sidebar)
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
self.text_view.set_size_request(0, int(SIZE_Y * 0.5))
self.text_view.set_size_request(900, 350)
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
vpane.add1(codesw)
vbox.pack_start(codesw) buttonhbox = gtk.HBox() goicon = gtk.Image() goicon.set_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_BUTTON) gobutton = gtk.Button(label=_("_Run!")) gobutton.set_image(goicon) gobutton.connect('clicked', self.gobutton_cb) gobutton.set_size_request(650, 2) buttonhbox.pack_start(gobutton) stopbutton = gtk.Button(stock=gtk.STOCK_STOP) stopbutton.connect('clicked', self.stopbutton_cb) stopbutton.set_size_request(200, 2) buttonhbox.pack_start(stopbutton) clearbutton = gtk.Button(stock=gtk.STOCK_CLEAR) clearbutton.connect('clicked', self.clearbutton_cb) clearbutton.set_size_request(150, 2) buttonhbox.pack_end(clearbutton) vbox.pack_start(buttonhbox)
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
vpane.add2(outbox) hpane.add2(vpane) self.set_canvas(hpane)
vbox.pack_end(outbox) hbox.pack_end(vbox) self.set_canvas(hbox)
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
def timer_cb(self, button, icons): button.set_icon_widget(icons['bw']) button.show_all() return False def flash_cb(self, button, icons): button.set_icon_widget(icons['color']) button.show_all() gobject.timeout_add(400, self.timer_cb, button, icons)
def selection_cb(self, column): self.save() model, _iter = column.get_selected() value = model.get_value(_iter,0) self._logger.debug("clicked! %s" % value['path']) _file = open(value['path'], 'r') lines = _file.readlines() global text_buffer text_buffer.set_text("".join(lines)) self.metadata['title'] = value['name'] self.stopbutton_cb(None) self._reset_vte() self.text_view.grab_focus()
self.hbox = gtk.HBox() vbox = gtk.VBox()
self.hpane = gtk.HPaned() self.vpane = gtk.VPaned()
def initialize_display(self): self._logger = logging.getLogger('pippy-activity')
treeview.set_size_request(220, 900)
treeview.set_size_request(int(SIZE_X * 0.3), SIZE_Y)
def initialize_display(self): self._logger = logging.getLogger('pippy-activity')
self.hbox.pack_start(self.sidebar)
self.hpane.add1(self.sidebar)
def initialize_display(self): self._logger = logging.getLogger('pippy-activity')
self.text_view.set_size_request(900, 350)
self.text_view.set_size_request(0, int(SIZE_Y * 0.5))
def initialize_display(self): self._logger = logging.getLogger('pippy-activity')
vbox.pack_start(codesw) buttonhbox = gtk.HBox() goicon = gtk.Image() goicon.set_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_BUTTON) gobutton = gtk.Button(label=_("_Run!")) gobutton.set_image(goicon) gobutton.connect('clicked', self.gobutton_cb) gobutton.set_size_request(650, 2) buttonhbox.pack_start(gobutton) stopbutton = gtk.Button(stock=gtk.STOCK_STOP) stopbutton.connect('clicked', self.stopbutton_cb) stopbutton.set_size_request(200, 2) buttonhbox.pack_start(stopbutton) clearbutton = gtk.Button(stock=gtk.STOCK_CLEAR) clearbutton.connect('clicked', self.clearbutton_cb) clearbutton.set_size_request(150, 2) buttonhbox.pack_end(clearbutton) vbox.pack_start(buttonhbox)
self.vpane.add1(codesw)
def initialize_display(self): self._logger = logging.getLogger('pippy-activity')
self._vte.set_size_request(200, 300)
def initialize_display(self): self._logger = logging.getLogger('pippy-activity')
vbox.pack_end(outbox) self.hbox.pack_end(vbox) return self.hbox
self.vpane.add2(outbox) self.hpane.add2(self.vpane) return self.hpane
def initialize_display(self): self._logger = logging.getLogger('pippy-activity')
self.hbox.remove(self.sidebar)
self.hpane.remove(self.hpane.get_child1())
def when_shared(self): self.hbox.remove(self.sidebar) global text_buffer self.cloud.sharefield = groupthink.gtk_tools.TextBufferSharePoint(text_buffer)
def timer_cb(self, button, icons): button.set_icon_widget(icons['bw']) button.show_all() return False def flash_cb(self, button, icons): button.set_icon_widget(icons['color']) button.show_all() gobject.timeout_add(400, self.timer_cb, button, icons)
def selection_cb(self, column): self.save() model, _iter = column.get_selected() value = model.get_value(_iter,0) self._logger.debug("clicked! %s" % value['path']) _file = open(value['path'], 'r') lines = _file.readlines() global text_buffer text_buffer.set_text("".join(lines)) self.metadata['title'] = value['name'] self.stopbutton_cb(None) self._reset_vte() self.text_view.grab_focus()
hbox = gtk.HBox() vbox = gtk.VBox()
hpane = gtk.HPaned() vpane = gtk.VPaned()
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
treeview.set_size_request(220, 900)
treeview.set_size_request(int(SIZE_X * 0.3), SIZE_Y)
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
hbox.pack_start(sidebar)
hpane.add1(sidebar)
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
self.text_view.set_size_request(900, 350)
self.text_view.set_size_request(0, int(SIZE_Y * 0.5))
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
vbox.pack_start(codesw) buttonhbox = gtk.HBox() goicon = gtk.Image() goicon.set_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_BUTTON) gobutton = gtk.Button(label=_("_Run!")) gobutton.set_image(goicon) gobutton.connect('clicked', self.gobutton_cb) gobutton.set_size_request(650, 2) buttonhbox.pack_start(gobutton) stopbutton = gtk.Button(stock=gtk.STOCK_STOP) stopbutton.connect('clicked', self.stopbutton_cb) stopbutton.set_size_request(200, 2) buttonhbox.pack_start(stopbutton) clearbutton = gtk.Button(stock=gtk.STOCK_CLEAR) clearbutton.connect('clicked', self.clearbutton_cb) clearbutton.set_size_request(150, 2) buttonhbox.pack_end(clearbutton) vbox.pack_start(buttonhbox)
vpane.add1(codesw)
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
self._vte.set_size_request(200, 300)
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
vbox.pack_end(outbox) hbox.pack_end(vbox) self.set_canvas(hbox)
vpane.add2(outbox) hpane.add2(vpane) self.set_canvas(hpane)
def __init__(self, handle): """Set up the Pippy activity.""" super(PippyActivity, self).__init__(handle) self._logger = logging.getLogger('pippy-activity')
raise Error("stock link to non-directory `%s'" % stock.link)
raise Error("stock link to non-directory `%s'" % self.link)
def __init__(self, path): self.paths = self.Paths(path) self.name = basename(path) self.link = os.readlink(self.paths.link) if not isdir(self.link): raise Error("stock link to non-directory `%s'" % stock.link)
def _read_versions(self):
def _init_read_versions(self):
def _read_versions(self): source_versions = {} for dpath, dnames, fnames in os.walk(self.paths.source_versions): relative_path = make_relative(self.paths.source_versions, dpath) for fname in fnames: fpath = join(dpath, fname) versions = [ line.strip() for line in file(fpath).readlines() if line.strip() ] source_versions[join(relative_path, fname)] = versions
def _get_workdir(self):
def _init_get_workdir(self):
def _get_workdir(self): """Return an initialized workdir path.
self.source_versions = self._read_versions() self.workdir = self._get_workdir()
self.source_versions = self._init_read_versions() self.workdir = self._init_get_workdir()
def __init__(self, path, pkgcache): self.paths = StockPaths(path) self.name = basename(path) self.branch = None if "#" in self.name: self.branch = self.name.split("#")[1]
for binary in self.stocks.get_binaries(): if self.pkgcache.exists(basename(binary)): continue self.pkgcache.add(binary) def _get_source_path(self, package): name, version = parse_package_id(package) for source_path, source_version in self.stocks.get_sources(): if basename(source_path) == name: source_path = dirname(source_path) if version is None: return source_path if source_version == version: return source_path return None
self.stocks.sync()
def _sync(self): """synchronise pool with registered stocks""" for binary in self.stocks.get_binaries(): if self.pkgcache.exists(basename(binary)): continue
if self._get_source_path(package):
if self.stocks.exists_source_version(*parse_package_id(package)):
def exists(self, package): """Check if package exists in pool -> Returns bool""" if self.pkgcache.exists(package): return True
self.packagelist.add(name)
if name in self.namerefs: self.namerefs[name] += 1 else: self.namerefs[name] = 1
def _register(self, filename): name, version = self._parse_filename(filename) self.filenames[(name, version)] = filename self.packagelist.add(name)
self.packagelist.remove(name)
self.namerefs[name] -= 1 if not self.namerefs[name]: del self.namerefs[name]
def _unregister(self, name, version): del self.filenames[(name, version)] self.packagelist.remove(name)
self.packagelist = set()
self.namerefs = {}
def __init__(self, path): self.path = path
if name in self.packagelist:
if name in self.namerefs:
def exists(self, name, version=None): """Returns True if package exists in cache.
packages |= set([ (basename(path), version) for path, version in self.stocks.get_sources() ])
for stock, path, versions in self.stocks.get_source_versions(): package = basename(path) packages |= set([ (package, version) for version in versions ])
def list(self, all_versions=False): """List packages in pool -> list of (name, version) tuples.
if not islink(fname) and isfile(fname) and fname.endswith(".deb"): binaries.append(join(dirpath, fname))
fpath = join(dirpath, fname) if not islink(fpath) and isfile(fpath) and fname.endswith(".deb"): binaries.append(fpath)
def get_binaries(self): """Recursively scan stocks for binaries -> list of filename"""