예제 #1
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: %s" % str(e))
예제 #2
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 = core.db.action.create_action(param_changes)
            controller.change_selected_version(parent_version)
            controller.add_new_action(action)
            controller.perform_action(action)
        return action
예제 #3
0
파일: api.py 프로젝트: bluemoon/shovel
 def handleArguments(self, arguments):
     argumentDict = {}
     for a in self._arg_gen(arguments):
         debug(a, DEBUG)
         argumentDict.update(a)
             
     return argumentDict
예제 #4
0
 def fromXml(node):
     if node.tag != 'mashuptrail':
         debug.debug("node.tag != 'mashuptrail'")
         return None
     #read attributes
     data = node.get('id', None)
     id = Mashuptrail.convert_from_str(data, 'uuid')
     data = node.get('vtVersion', None)
     vtVersion = Mashuptrail.convert_from_str(data, 'long')
     data = node.get('version', None)
     version = Mashuptrail.convert_from_str(data, 'str')
     actions = []
     action_map = {}
     annotations = []
     for child in node.getchildren():
         if child.tag == 'action':
             action = Action.fromXml(child)
             actions.append(action)
             action_map[action.id] = action
         elif child.tag == 'actionAnnotation':
             annot = ActionAnnotation.fromXml(child)
             annotations.append(annot)
             
     mtrail = Mashuptrail(id,vtVersion)
     mtrail.version = version
     mtrail.actions = actions
     mtrail.actionMap = action_map
     mtrail.annotations = annotations
     mtrail.currentVersion = mtrail.getLatestVersion()
     mtrail.updateIdScope()
     return mtrail
예제 #5
0
	def _sendstr(self,sendstr,tolist):
		'''向某人发送消息,tolist为目标name对象,也可以为一个玩家的str'''
		if type(tolist)!=list:
			tolist = [tolist]
		for player in tolist:
			if self.PlayerID[player]!='':
				itchat.send_msg(sendstr,self.PlayerID[player])
				debug("向 %s 发送消息:%s" %(player,sendstr),'狼人杀')
예제 #6
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 i in range(num):
         try:
             del self.elements[elements[i].name]
             os.unlink(elements[i].abs_name)
         except os.error, e:
             debug.warning("Could not remove file %s:" (
                 elements[i].abs_name, str(e)))
예제 #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 i in range(num):
         try:
             del self.elements[elements[i].name]    
             os.unlink(elements[i].abs_name)
         except os.error, e:
             debug.warning("Could not remove file %s:"(elements[i].abs_name,
                                                       str(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)
예제 #9
0
파일: base.py 프로젝트: painter1/vistrails
 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: %s"%str(e))
예제 #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)
예제 #11
0
 def fromXml(node):
     if node.tag != 'action':
         debug.debug("node.tag != 'action'")
         return None
     #read attributes
     data = node.get('id', None)
     id = Action.convert_from_str(data, 'long')
     data = node.get('parent_id', None)
     parent_id = Action.convert_from_str(data, 'long')
     data = node.get('user', None)
     user = Action.convert_from_str(data, 'str')
     data = node.get('date', None)
     date = Action.convert_from_str(data, 'datetime')
     child = node.getchildren()[0]
     if child.tag == 'mashup':
         mashup = Mashup.fromXml(child)
     return Action(id=id, parent_id=parent_id, mashup=mashup, user=user,
                   date=date)
예제 #12
0
 def fromXml(node):
     if node.tag != 'actionAnnotation':
         debug.debug("node.tag != 'actionAnnotation'")
         return None
     #read attributes
     data = node.get('id', None)
     id = Action.convert_from_str(data, 'long')
     data = node.get('action_id', None)
     action_id = Action.convert_from_str(data, 'long')
     data = node.get('key', None)
     key = Action.convert_from_str(data, 'str')
     data = node.get('value', None)
     value = Action.convert_from_str(data, 'str')
     data = node.get('user', None)
     user = Action.convert_from_str(data, 'str')
     data = node.get('date', None)
     date = Action.convert_from_str(data, 'datetime')
     return ActionAnnotation(id=id, action_id=action_id, key=key, value=value,
                   user=user, date=date)
 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: %s"%str(e))
예제 #14
0
 def GetSkill(self, skillname):
     try:
         returnlist = []
         r = requests.get(self.url % skillname)
         p = re.compile('<img class="wx-share" src="(.*?)" alt')  #icon
         p2 = re.compile('<span class="font-106">(.*?)</span>')  #距离等
         p3 = re.compile('<span class="font-100">(.*?)</span>')  #具体描述
         p4 = re.compile('<span class="font-31">(.*?)</span>')  #技能名称
         icon = p.findall(r.text)
         iconimg = BytesIO(requests.get(icon[0]).content)
         iconobj = Image.open(iconimg)
         describe_1 = p2.findall(r.text)
         describe_2 = p3.findall(r.text)
         skillnames = p4.findall(r.text)
         for index, name in enumerate(skillnames):
             if name == skillname:
                 returnlist.append((describe_1[index], describe_2[index]))
             else:
                 print(name, skillname)
         return iconobj, returnlist
     except Exception as err:
         debug("获取技能信息错误!信息:" + str(err), '错误')
         return None, None
예제 #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")
    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")
예제 #17
0
파일: api.py 프로젝트: bluemoon/shovel
 def debug(self, string, level=NONE):
     ''' this prints debugging code in a fashionable way. '''
     assert string, "there is no debug string"
     debug(string, level)
예제 #18
0
    def build_plot_pipeline_action(controller, version, var_modules, plot_objs,
                                   row, col):
        """build_plot_pipeline_action(controller: VistrailController,
                                      version: long,
                                      var_modules: [list of modules],
                                      plot_objs: [list of Plot objects],
                                      row: int,
                                      col: int) -> Action 
        
        This function will build the complete workflow and add it to the
        provenance. You should make sure to update the state of the controller
        so its current_version is version before adding the VisTrails action to 
        the provenance.
        row and col contain the position of the cell in the spreadsheet the 
        workflow should be displayed. 
        """
        plot_obj = plot_objs[0]
        plot_obj.current_parent_version = version
        plot_obj.current_controller = controller
        controller.change_selected_version(version)

        if len(var_modules) == plot_obj.varnum:
            ops = []
            pip_str = core.db.io.serialize(plot_obj.workflow)
            controller.paste_modules_and_connections(pip_str, (0.0, 0.0))
            version = controller.current_version
            pipeline = controller.vistrail.getPipeline(version)
            plot_module = MatplotlibPipelineHelper.find_module_by_name(
                pipeline, 'CDMSData')
            aliases = {}
            for j in range(plot_obj.cellnum):
                if plot_obj.cells[j].row_name and plot_obj.cells[j].col_name:
                    aliases[plot_obj.cells[j].row_name] = str(row + 1)
                    aliases[plot_obj.cells[j].col_name] = str(col + 1 + j)
                elif plot_obj.cells[j].address_name:
                    aliases[plot_obj.cells[j].address_name] = "%s%s" % (
                        chr(ord('A') + col + j), row + 1)
            for a, w in plot_obj.alias_widgets.iteritems():
                try:
                    aliases[a] = w.contents()
                except Exception, err:
                    debug.debug("Error updating alias %s:" % str(a), str(err))

            action = MatplotlibPipelineHelper.addParameterChangesFromAliasesAction(
                controller.current_pipeline, controller, controller.vistrail,
                controller.current_version, aliases)
            version = action.id
            added_vars = []
            for i in range(len(var_modules)):
                if issubclass(var_modules[i].module_descriptor.module,
                              CDMSVariable):
                    conn = controller.create_connection(
                        var_modules[i], 'self', plot_module, 'variable')
                else:
                    conn = controller.create_connection(
                        var_modules[i], 'output_var', plot_module, 'variable')
                ops.append(('add', conn))
                if plot_obj.varnum > 1:
                    if i + 1 < len(var_modules):
                        idx = i + 1
                    else:
                        idx = i
                    if issubclass(var_modules[idx].module_descriptor.module,
                                  CDMSVariable):
                        conn2 = controller.create_connection(
                            var_modules[idx], 'self', plot_module, 'variable2')
                        if var_modules[idx] not in added_vars:
                            ops.append(('add', var_modules[idx]))
                            added_vars.append(var_modules[idx])
                    else:
                        conn2 = controller.create_connection(
                            var_modules[idx], 'output_var', plot_module,
                            'variable')
                    ops.append(('add', conn2))
            action2 = core.db.action.create_action(ops)
            controller.change_selected_version(version)
            controller.add_new_action(action2)
            controller.perform_action(action2)
            return action2
예제 #19
0
def addSetGetPorts(module, get_set_dict, delayed):
    """ addSetGetPorts(module: Module, get_set_dict: dict) -> None
    Convert all Setxxx methods of module into input ports and all Getxxx
    methods of module into output ports

    Keyword arguments:
    module       --- Module
    get_set_dict --- the Set/Get method signatures returned by vtk_parser

    """

    klass = get_description_class(module.vtkClass)
    registry = get_module_registry()
    for name in get_set_dict.iterkeys():
        if name in disallowed_set_get_ports: continue
        getterMethod = getattr(klass, 'Get%s'%name)
        setterMethod = getattr(klass, 'Set%s'%name)
        getterSig = get_method_signature(getterMethod)
        setterSig = get_method_signature(setterMethod)
        if len(getterSig) > 1:
            prune_signatures(module, 'Get%s'%name, getterSig, output=True)
        for order, getter in enumerate(getterSig):
            if getter[1]:
                debug("Can't handle getter %s (%s) of class %s: Needs input to "
                    "get output" % (order+1, name, klass))
                continue
            if len(getter[0]) != 1:
                debug("Can't handle getter %s (%s) of class %s: More than a "
                    "single output" % (order+1, name, str(klass)))
                continue
            class_ = typeMap(getter[0][0])
            if is_class_allowed(class_):
                registry.add_output_port(module, 'Get'+name, class_, True)
        if len(setterSig) > 1:
            prune_signatures(module, 'Set%s'%name, setterSig)
        for ix, setter in enumerate(setterSig):
            if setter[1]==None: continue
            n = resolve_overloaded_name('Set' + name, ix, setterSig)
            if len(setter[1]) == 1 and is_class_allowed(typeMap(setter[1][0])):
                registry.add_input_port(module, n,
                                        typeMap(setter[1][0]),
                                        setter[1][0] in typeMapDict)
            else:
                classes = [typeMap(i) for i in setter[1]]
                if all(is_class_allowed(x) for x in classes):
                    registry.add_input_port(module, n, classes, True)
            # Wrap SetFileNames for VisTrails file access
            if file_name_pattern.match(name):
                registry.add_input_port(module, 'Set' + name[:-4], 
                                        (File, 'input file'), False)
            # Wrap SetRenderWindow for exporters
            elif name == 'RenderWindow':
                # cscheid 2008-07-11 This is messy: VTKCell isn't
                # registered yet, so we can't use it as a port
                # However, we can't register VTKCell before these either,
                # because VTKCell requires vtkRenderer. The "right" way would
                # be to add all modules first, then all ports. However, that would
                # be too slow.
                # Workaround: delay the addition of the port by storing
                # the information in a list
                if registry.has_module('edu.utah.sci.vistrails.spreadsheet',
                                       'SpreadsheetCell'):
                    delayed.add_input_port.append((module, 'SetVTKCell', VTKCell, False))
            # Wrap color methods for VisTrails GUI facilities
            elif name == 'DiffuseColor':
                registry.add_input_port(module, 'SetDiffuseColorWidget',
                                        (Color, 'color'), True)
            elif name == 'Color':
                registry.add_input_port(module, 'SetColorWidget', 
                                        (Color, 'color'), True)
            elif name == 'AmbientColor':
                registry.add_input_port(module, 'SetAmbientColorWidget',
                                        (Color, 'color'), True)
            elif name == 'SpecularColor':
                registry.add_input_port(module, 'SetSpecularColorWidget',
                                        (Color, 'color'), True)
            elif name == 'EdgeColor':
                registry.add_input_port(module, 'SetEdgeColorWidget',
                                        (Color, 'color'), True)
            elif name == 'Background' :
                registry.add_input_port(module, 'SetBackgroundWidget', 
                                        (Color, 'color'), True)
            elif name == 'Background2' :
                registry.add_input_port(module, 'SetBackground2Widget', 
                                        (Color, 'color'), True)
예제 #20
0
    def initFenrirConfig(self, environment = environment.environment, settingsRoot = '/etc/fenrir/', settingsFile='settings.conf', soundRoot = '/usr/share/sounds/fenrir/'):
        environment['runtime']['debug'] = debug.debug()
        environment['runtime']['debug'].initialize(environment)
        if not os.path.exists(settingsRoot):
            if os.path.exists(os.path.dirname(os.path.realpath(__main__.__file__)) +'/../../config/'):
                settingsRoot = os.path.dirname(os.path.realpath(__main__.__file__)) +'/../../config/'
            else:
                return None
        if not os.path.exists(soundRoot):
            if os.path.exists(os.path.dirname(os.path.realpath(__main__.__file__)) +'/../../config/sound/'):
                soundRoot = os.path.dirname(os.path.realpath(__main__.__file__)) +'/../../config/sound/'

        environment['runtime']['settingsManager'] = self 
        environment['runtime']['settingsManager'].initialize(environment)

        validConfig = environment['runtime']['settingsManager'].loadSettings(settingsRoot + '/settings/' + settingsFile)
        if not validConfig:
            return None

        self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
        self.setScriptKeys(self.getSetting('general','scriptKeys'))      

        if not os.path.exists(self.getSetting('keyboard','keyboardLayout')):
            if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')):  
                self.setSetting('keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout'))
                environment['runtime']['settingsManager'].loadShortcuts(self.getSetting('keyboard','keyboardLayout'))
            if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout') + '.conf'):  
                self.setSetting('keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout') + '.conf')
                environment['runtime']['settingsManager'].loadShortcuts(self.getSetting('keyboard','keyboardLayout'))
        else:
            environment['runtime']['settingsManager'].loadShortcuts(self.getSetting('keyboard','keyboardLayout'))
        
        if not os.path.exists(self.getSetting('sound','theme') + '/soundicons.conf'):
            if os.path.exists(soundRoot + self.getSetting('sound','theme')):  
                self.setSetting('sound', 'theme', soundRoot + self.getSetting('sound','theme'))
                if os.path.exists(self.getSetting('sound','theme') + '/soundicons.conf'):  
                    environment['runtime']['settingsManager'].loadSoundIcons(self.getSetting('sound','theme'))
        else:
            environment['runtime']['settingsManager'].loadSoundIcons(self.getSetting('sound','theme'))

        if not os.path.exists(self.getSetting('general','punctuationProfile')):
            if os.path.exists(settingsRoot + 'punctuation/' + self.getSetting('general','punctuationProfile')):  
                self.setSetting('general', 'punctuationProfile', settingsRoot + 'punctuation/' + self.getSetting('general','punctuationProfile'))
                environment['runtime']['settingsManager'].loadDicts(self.getSetting('general','punctuationProfile'))
            if os.path.exists(settingsRoot + 'punctuation/' + self.getSetting('general','punctuationProfile') + '.conf'):  
                self.setSetting('general', 'punctuationProfile', settingsRoot + 'punctuation/' + self.getSetting('general','punctuationProfile') + '.conf')
                environment['runtime']['settingsManager'].loadDicts(self.getSetting('general','punctuationProfile'))
        else:
            environment['runtime']['settingsManager'].loadDicts(self.getSetting('general','punctuationProfile'))

        environment['runtime']['inputManager'] = inputManager.inputManager()
        environment['runtime']['inputManager'].initialize(environment)             
        environment['runtime']['outputManager'] = outputManager.outputManager()
        environment['runtime']['outputManager'].initialize(environment)             
        environment['runtime']['commandManager'] = commandManager.commandManager()
        environment['runtime']['commandManager'].initialize(environment)  
        environment['runtime']['punctuationManager'] = punctuationManager.punctuationManager()
        environment['runtime']['punctuationManager'].initialize(environment)  
        environment['runtime']['cursorManager'] = cursorManager.cursorManager()
        environment['runtime']['cursorManager'].initialize(environment)  
        environment['runtime']['applicationManager'] = applicationManager.applicationManager()
        environment['runtime']['applicationManager'].initialize(environment)  
        
        if environment['runtime']['screenManager'] == None:
            environment['runtime']['screenManager'] = screenManager.screenManager()
            environment['runtime']['screenManager'].initialize(environment) 
            
        environment['runtime']['debug'].writeDebugOut('\/-------environment-------\/',debug.debugLevel.INFO, onAnyLevel=True)        
        environment['runtime']['debug'].writeDebugOut(str(environment),debug.debugLevel.INFO, onAnyLevel=True)
        environment['runtime']['debug'].writeDebugOut('\/-------settings.conf-------\/',debug.debugLevel.INFO, onAnyLevel=True)        
        environment['runtime']['debug'].writeDebugOut(str(environment['settings']._sections
),debug.debugLevel.INFO, onAnyLevel=True)        
        return environment
예제 #21
0
 def build_plot_pipeline_action(controller, version, var_modules, plot_objs, 
                                row, col):
     """build_plot_pipeline_action(controller: VistrailController,
                                   version: long,
                                   var_modules: [list of modules],
                                   plot_objs: [list of Plot objects],
                                   row: int,
                                   col: int) -> Action 
     
     This function will build the complete workflow and add it to the
     provenance. You should make sure to update the state of the controller
     so its current_version is version before adding the VisTrails action to 
     the provenance.
     row and col contain the position of the cell in the spreadsheet the 
     workflow should be displayed. 
     """
     plot_obj = plot_objs[0] 
     plot_obj.current_parent_version = version
     plot_obj.current_controller = controller
     controller.change_selected_version(version)
     
     if len(var_modules) == plot_obj.varnum:
         ops = []
         pip_str = core.db.io.serialize(plot_obj.workflow)
         controller.paste_modules_and_connections(pip_str, (0.0,0.0))
         version = controller.current_version
         pipeline = controller.vistrail.getPipeline(version)
         plot_module = MatplotlibPipelineHelper.find_module_by_name(pipeline, 'CDMSData')
         aliases = {}
         for j in range(plot_obj.cellnum):
             if plot_obj.cells[j].row_name and plot_obj.cells[j].col_name:
                 aliases[plot_obj.cells[j].row_name] = str(row+1)
                 aliases[plot_obj.cells[j].col_name] = str(col+1+j)
             elif plot_obj.cells[j].address_name:
                 aliases[plot_obj.cells[j].address_name] = "%s%s" % ( chr(ord('A') + col+j ), row+1)
         for a,w in plot_obj.alias_widgets.iteritems():
             try:    aliases[a] = w.contents()
             except Exception, err: debug.debug("Error updating alias %s:" % str( a ), str(err))
         
         action = MatplotlibPipelineHelper.addParameterChangesFromAliasesAction(controller.current_pipeline,  
                                                                       controller,  
                                                                       controller.vistrail, 
                                                                       controller.current_version, 
                                                                       aliases)
         version = action.id
         added_vars = []
         for i in range(len(var_modules)):
             if issubclass(var_modules[i].module_descriptor.module, CDMSVariable):
                 conn = controller.create_connection(var_modules[i], 'self',
                                             plot_module, 'variable')
             else:
                 conn = controller.create_connection(var_modules[i], 'output_var',
                                             plot_module, 'variable')
             ops.append(('add', conn))
             if plot_obj.varnum > 1:
                 if i + 1 < len(var_modules):
                     idx = i+1
                 else:
                     idx = i
                 if issubclass(var_modules[idx].module_descriptor.module, CDMSVariable):
                     conn2 = controller.create_connection(var_modules[idx], 'self',
                                                  plot_module, 'variable2')
                     if var_modules[idx] not in added_vars:
                         ops.append(('add', var_modules[idx]))
                         added_vars.append(var_modules[idx])
                 else:
                     conn2 = controller.create_connection(var_modules[idx], 'output_var',
                                                  plot_module, 'variable')
                 ops.append(('add', conn2))
         action2 = core.db.action.create_action(ops)
         controller.change_selected_version(version)
         controller.add_new_action(action2)
         controller.perform_action(action2)
         return action2