def addParameterChangesFromAliasesAction(self, pipeline, controller, vistrail, parent_version, aliases): param_changes = [] newid = parent_version print "addParameterChangesFromAliasesAction()" print "Aliases: %s " % str( aliases ) print "Pipeline Aliases: %s " % str( pipeline.aliases ) aliasList = aliases.iteritems() for k,value in aliasList: alias = pipeline.aliases.get(k,None) # alias = (type, oId, parentType, parentId, mId) if alias: module = pipeline.modules[alias[4]] function = module.function_idx[alias[3]] old_param = function.parameter_idx[alias[1]] #print alias, module, function, old_param if old_param.strValue != value: new_param = controller.create_updated_parameter(old_param, value) if new_param is not None: op = ('change', old_param, new_param, function.vtType, function.real_id) param_changes.append(op) # print "Added parameter change for alias=%s, value=%s" % ( k, value ) else: debug.debug("CDAT Package: Change parameter %s in widget %s was not generated"%(k, self.name)) else: debug.debug( "CDAT Package: Alias %s does not exist in pipeline" % (k) ) action = None if len(param_changes) > 0: action = vistrails.core.db.action.create_action(param_changes) controller.change_selected_version(parent_version) controller.add_new_action(action) controller.perform_action(action) return action
def saveToPNG(self, filename, width=None): try: self.updateSceneBoundingRect(False) b_rect = QtCore.QRectF(self.sceneBoundingRect) b_rect.setWidth(math.floor(b_rect.width())) b_rect.setHeight(math.floor(b_rect.height())) debug.debug("PNG bounding box %sx%s" % (b_rect.width(), b_rect.height())) pixmap = QtGui.QPixmap( QtCore.QSize(int(math.floor(b_rect.width())), int(math.floor(b_rect.height())))) debug.debug("PNG pixmap size: %s" % str(pixmap.size())) painter = QtGui.QPainter(pixmap) painter.setRenderHint(QtGui.QPainter.Antialiasing) brush = self.backgroundBrush() self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(255, 255, 255))) self.render(painter, QtCore.QRectF(), b_rect) painter.end() if width is not None: pixmap = pixmap.scaledToWidth(width, QtCore.Qt.SmoothTransformation) pixmap.save(filename) self.setBackgroundBrush(brush) except Exception, e: debug.critical("Exception saving to PNG", e)
def emit(self, record): msg = "tej: %s" % self.format(record) if record.levelno >= logging.CRITICAL: debug.critical(msg) elif record.levelno >= logging.WARNING: debug.warning(msg) elif record.levelno >= logging.INFO: debug.log(msg) else: debug.debug(msg)
def unload(self): for path in self.py_dependencies: if path not in sys.modules: pass elif not getattr(get_vistrails_configuration(), 'dontUnloadModules', False): debug.debug("deleting from sys.modules: %s" % path) del sys.modules[path] self.py_dependencies.clear() self._loaded = False
def remove_lru(self,n=1): elements = self.elements.values() elements.sort(key=lambda obj: obj.time) num = min(n,len(elements)) debug.debug("Will remove %s elements from cache..."%num) debug.debug("Cache has %s elements and %s bytes"%(len(elements), self.size())) for elem in itertools.islice(elements, num): try: del self.elements[elem.name] os.unlink(elem.abs_name) except os.error, e: debug.warning("Could not remove file %s" % elem.abs_name, e)
def remove_lru(self, n=1): elements = self.elements.values() elements.sort(key=lambda obj: obj.time) num = min(n, len(elements)) debug.debug("Will remove %s elements from cache..." % num) debug.debug("Cache has %s elements and %s bytes" % (len(elements), self.size())) for elem in itertools.islice(elements, num): try: del self.elements[elem.name] os.unlink(elem.abs_name) except os.error, e: debug.warning("Could not remove file %s" % elem.abs_name, e)
def update_params(self, pipeline, customParams=None): """update_params(pipeline: Pipeline, customParams=[(vttype, oId, strval)] -> None This will set the new parameter values in the pipeline before execution """ if customParams: for (vttype, oId, strval) in customParams: try: param = pipeline.db_get_object(vttype, oId) param.strValue = str(strval) except Exception, e: debug.debug("Problem when updating params", e)
def saveToPDF(self, filename): self.updateSceneBoundingRect(False) printer = QtGui.QPrinter() printer.setOutputFormat(QtGui.QPrinter.PdfFormat) printer.setOutputFileName(filename) b_rect = self.sceneBoundingRect debug.debug("%sx%s" % (b_rect.width(), b_rect.height())) printer.setPaperSize(QtCore.QSizeF(b_rect.width(), b_rect.height()), QtGui.QPrinter.Point) painter = QtGui.QPainter(printer) brush = self.backgroundBrush() self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(255,255,255))) self.render(painter, QtCore.QRectF(), b_rect) painter.end() self.setBackgroundBrush(brush)
def update_params(self, pipeline, customParams=None): """update_params(pipeline: Pipeline, customParams=[(vttype, oId, strval)] -> None This will set the new parameter values in the pipeline before execution """ if customParams: for (vttype, oId, strval) in customParams: try: param = pipeline.db_get_object(vttype,oId) param.strValue = str(strval) except Exception, e: debug.debug("Problem when updating params", e)
def saveToPDF(self, filename): self.updateSceneBoundingRect(False) printer = QtGui.QPrinter() printer.setOutputFormat(QtGui.QPrinter.PdfFormat) printer.setOutputFileName(filename) b_rect = self.sceneBoundingRect debug.debug("%sx%s" % (b_rect.width(), b_rect.height())) printer.setPaperSize(QtCore.QSizeF(b_rect.width(), b_rect.height()), QtGui.QPrinter.Point) painter = QtGui.QPainter(printer) brush = self.backgroundBrush() self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(255, 255, 255))) self.render(painter, QtCore.QRectF(), b_rect) painter.end() self.setBackgroundBrush(brush)
def saveToPNG(self, filename, width=None): try: self.updateSceneBoundingRect(False) b_rect = QtCore.QRectF(self.sceneBoundingRect) b_rect.setWidth(math.floor(b_rect.width())) b_rect.setHeight(math.floor(b_rect.height())) debug.debug("PNG bounding box %sx%s" % (b_rect.width(), b_rect.height())) pixmap = QtGui.QPixmap(QtCore.QSize(int(math.floor(b_rect.width())), int(math.floor(b_rect.height())))) debug.debug("PNG pixmap size: %s"%str(pixmap.size())) painter = QtGui.QPainter(pixmap) painter.setRenderHint(QtGui.QPainter.Antialiasing) brush = self.backgroundBrush() self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(255,255,255))) self.render(painter, QtCore.QRectF(), b_rect) painter.end() if width is not None: pixmap = pixmap.scaledToWidth(width, QtCore.Qt.SmoothTransformation) pixmap.save(filename) self.setBackgroundBrush(brush) except Exception, e: debug.critical("Exception saving to PNG", e)
def get_key(self, key): """ get_key(key:str) -> str Returns the value for the key. Only the object that set the key is able to retrieve its value """ result = "" #get the arguments of the frame that called us args = inspect.getargvalues(inspect.currentframe().f_back)[3] try: #this will return the instance of the object that called us caller = id(args['self']) newkey = str(caller)+str(key) hashkey = md5_hash(newkey).hexdigest()[:16] if self.__keys.has_key(hashkey): return crypt(hashkey,self.__keys[hashkey]) else: debug.debug("KeyChain: the key is not present or only the" " object that set the key can get it") return "" except KeyError: debug.critical("KeyChain: You need to call this method inside " "another object's method")
def get_key(self, key): """ get_key(key:str) -> str Returns the value for the key. Only the object that set the key is able to retrieve its value """ result = "" #get the arguments of the frame that called us args = inspect.getargvalues(inspect.currentframe().f_back)[3] try: #this will return the instance of the object that called us caller = id(args['self']) newkey = str(caller) + str(key) hashkey = md5_hash(newkey).hexdigest()[:16] if self.__keys.has_key(hashkey): return crypt(hashkey, self.__keys[hashkey]) else: debug.debug("KeyChain: the key is not present or only the" " object that set the key can get it") return "" except KeyError: debug.critical("KeyChain: You need to call this method inside " "another object's method")
def submit_usage_report(**kwargs): """Submits the current usage report to the usagestats server. """ debug.debug("submit_usage_report %r" % (kwargs,)) for pkg in ('numpy', 'scipy', 'matplotlib'): try: pkg_o = __import__(pkg, globals(), locals()) usage_report.note({pkg: getattr(pkg_o, '__version__', '')}) except ImportError: pass try: import vtk usage_report.note({'vtk': vtk.vtkVersion().GetVTKVersion()}) except ImportError: pass features.update(*features_for_vistrails.values()) for feature in features: usage_report.note({'feature': feature}) usage_report.submit(kwargs, usagestats.OPERATING_SYSTEM, usagestats.SESSION_TIME, usagestats.PYTHON_VERSION)
def record_usage(**kwargs): """Records some info in the current usage report. """ if usage_report is not None: debug.debug("record_usage %r" % (kwargs,)) usage_report.note(kwargs)
def message(self, data): if self.hidden: debug.debug("tej server: %s" % data) else: debug.warning("tej server: %s" % data)