Exemple #1
0
    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
Exemple #2
0
 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)
Exemple #3
0
 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)
Exemple #4
0
 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)
Exemple #5
0
 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
Exemple #6
0
 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
Exemple #7
0
 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)
Exemple #8
0
 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)
Exemple #9
0
 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)
Exemple #10
0
 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)
Exemple #11
0
 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)
Exemple #12
0
 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)
Exemple #13
0
 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)
Exemple #14
0
    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")
Exemple #15
0
    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")
Exemple #16
0
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)
Exemple #17
0
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)
Exemple #18
0
 def message(self, data):
     if self.hidden:
         debug.debug("tej server: %s" % data)
     else:
         debug.warning("tej server: %s" % data)
Exemple #19
0
 def message(self, data):
     if self.hidden:
         debug.debug("tej server: %s" % data)
     else:
         debug.warning("tej server: %s" % data)