def open_workflow(self, locator, version=None):
        self.close_first_vistrail_if_necessary()
        if self.single_document_mode and self.currentView():
            self.closeVistrail()

        vistrail = Vistrail()
        try:
            if locator is not None:
                workflow = locator.load(Pipeline)
                action_list = []
                for module in workflow.module_list:
                    action_list.append(('add', module))
                for connection in workflow.connection_list:
                    action_list.append(('add', connection))
                action = core.db.action.create_action(action_list)
                vistrail.add_action(action, 0L)
                vistrail.update_id_scope()
                vistrail.addTag("Imported workflow", action.id)
                # FIXME might need different locator?
        except ModuleRegistryException, e:
            msg = ('Cannot find module "%s" in package "%s". '
                    'Make sure package is ' 
                   'enabled in the Preferences dialog.' % \
                       (e._name, e._identifier))
            debug.critical(msg)
    def reload(self, vistrail):
        if vistrail is not None:
            self.set_vistrail(vistrail)

            for version_id in self.vistrail.get_tagMap():
                self.add_workflow_entity(version_id)
            
            #mashups
            if hasattr(self.vistrail, 'mashups'):
                self._mshp_tag_map = {}
                for mashuptrail in self.vistrail.mashups:
                    self._mshp_tag_map[mashuptrail.id] = \
                         self.add_mashup_entities_from_mashuptrail(mashuptrail)
                
            # read persisted log entries
            try:
                log = vistrail.get_persisted_log()
            except:
                import traceback
                debug.critical("Failed to read log", traceback.format_exc())
                
            if log is not None:
                for wf_exec in log.workflow_execs:
                    self.add_wf_exec_entity(wf_exec, False)

            # read unpersisted log entries
            if vistrail.log is not None:
                for wf_exec in self.vistrail.log.workflow_execs:
                    self.add_wf_exec_entity(wf_exec, True)

            self._vt_tag_map = copy.copy(self.vistrail.get_tagMap())
    def __init__(self, address):
        """ Process WSDL and add all Types and Methods
        """
        self.address = address
        self.signature = toSignature(self.address)
        self.wsdlHash = '-1'
        self.modules = []
        self.package = None
        debug.log("Installing Web Service from WSDL: %s"% address)

        options = dict(cachingpolicy=1, cache=package_cache)
        
        proxy_types = ['http']
        for t in proxy_types:
            key = 'proxy_%s'%t
            if configuration.check(key):
                proxy = getattr(configuration, key)
                debug.log("Using proxy: %s" % proxy)
                if len(proxy):
                    options['proxy'] = {t:proxy}
        try:
            self.service = suds.client.Client(address, **options)
            self.backUpCache()
        except Exception, e:
            self.service = None
            # We may be offline and the cache may have expired,
            # try to use backup
            if self.restoreFromBackup():
                try:
                    self.service = suds.client.Client(address, **options)
                except Exception, e:
                    self.service = None
                    debug.critical("Could not load WSDL: %s" % address,
                           str(e) + '\n' + str(traceback.format_exc()))
    def add_workflow_entity(self, version_id):
        if version_id not in self.vistrail.actionMap:
            return
        action = self.vistrail.actionMap[version_id]
        tag = None
        if self.vistrail.has_tag(version_id):
            tag = self.vistrail.get_tag(version_id)
        try:
            workflow = self.vistrail.getPipeline(version_id)
        except:
            import traceback
            debug.critical("Failed to construct pipeline '%s'" % 
                               (tag if tag else version_id),
                           traceback.format_exc())
            workflow = self.vistrail.getPipeline(0)
        if tag:
            workflow.name = tag
        # if workflow already exists, we want to update it...
        # spin through self.children and look for matching
        # workflow entity?
        # self.children.append(WorkflowEntity(workflow))
        self.wf_entity_map[version_id] = \
            self.create_workflow_entity(workflow, action)

        # get thumbnail
        thumbnail = self.vistrail.get_thumbnail(version_id)
        if thumbnail is not None:
            cache = ThumbnailCache.getInstance()
            path = cache.get_abs_name_entry(thumbnail)
            if path:
                entity = ThumbnailEntity(path)
                self.wf_entity_map[action.id].children.append(entity)
                entity.parent = self.wf_entity_map[action.id]
        return self.wf_entity_map[version_id]
    def layout_from(self, vistrail, graph):
        """ layout_from(vistrail: VisTrail, graph: Graph) -> None
        Take a graph from VisTrail version and use Dotty to lay it out
        
        """
        # Create VisTrail graph input
        tmp_graph_file = file(core.system.temporary_directory() +
                            'dot_tmp_vistrails.txt', 'w')
        tmp_graph_file.write('digraph G {\n')
        tmp_graph_file.write('  ordering=out;\n')
        self.output_vistrail_graph(tmp_graph_file, vistrail, graph)
        tmp_graph_file.write('}\n')
        tmp_graph_file.close()

        # Run Dotty
        temp_dir = core.system.temporary_directory()
        cmdline = (core.system.graph_viz_dot_command_line() +
                   temp_dir + 'dot_output_vistrails.txt ' +
                   temp_dir + 'dot_tmp_vistrails.txt')
        os.system(cmdline)

        dtty_file = temp_dir + 'dot_output_vistrails.txt'

        if not os.path.exists(dtty_file) :
            debug.critical("Could not find %s" % dtty_file)
            debug.critical("Is GraphViz installed and is dotty in your PATH?")
            
        file_in = open(dtty_file)

        # Parse Dotty's output
        self.parse_dotty_output(file_in)
        core.system.remove_graph_viz_temporaries()
    def addFunction(self, module, fId, function):
        """ addFunction(module: Module, fId: int,
                        function: ModuleFunction) -> None
        Add an input form for the function
        
        """
        if not function.is_valid:
            debug.critical("FUNCTION NOT VALID!")
            return
        inputForm = QMethodInputWidget(self.formType, self)
        inputForm.moduleId = module.id
        inputForm.fId = fId

        port_spec = None
        if module.is_valid:
            # call module.get_port_spec(function.name) to get labels
            port_spec = module.get_port_spec(function.name, 'input')
        inputForm.updateFunction(function, port_spec)
        self.connect(inputForm, QtCore.SIGNAL('deleted(QWidget*)'), 
                     self.delete_form)
        self.layout().addWidget(inputForm)
        inputForm.show()
        self.setMinimumHeight(self.layout().minimumSize().height())
        self.showPrompt(False)
        self._functions.append(inputForm)
Exemple #7
0
    def run_flow(self, workflow, version, aliases=None, path=None,
            update=False):
        """Run a workflow version located at a specified path.

        Args:
            workflow: string
            version: string
            aliases: dictionary
                name:value pairs for workflow aliases
            path: string
                if not supplied, use current directory
            update: boolean
                True if you want the log of this execution to be stored
                in the vistrail file
        """
        # api must be imported after vistrails initialization
        import api
        location = path or os.getcwd()
        flow = os.path.join(location, workflow)
        #print "102 Running %s" % (flow)
        locator = FileLocator(os.path.abspath(flow))
        work_list = [(locator, version)]
        parameters = ''
        for key, item in enumerate(aliases.items()):
            parameters = parameters + '%s=%s' % (item[0], item[1])
            if key + 1 < len(aliases):
                parameters = parameters + '$&$'
        errs = run(work_list, parameters=parameters, update_vistrail=update)
        if len(errs) > 0:
            for err in errs:
                debug.critical("Error in %s:%s:%s -- %s" % err)
Exemple #8
0
 def install_default_startupxml_if_needed():
     fname = os.path.join(self.temp_configuration.dotVistrails,
                          'startup.xml')
     root_dir = core.system.vistrails_root_directory() 
     origin = os.path.join(root_dir, 'core','resources',
                           'default_vistrails_startup_xml')
     def skip():
         if os.path.isfile(fname):
             try:
                 d = self.startup_dom()
                 v = str(d.getElementsByTagName('startup')[0].attributes['version'].value)
                 r = core.utils.version_string_to_list(v)
                 return r >= [0, 1]
             except:
                 return False
         else:
             return False
     if skip():
         return
     try:
         shutil.copyfile(origin, fname)
         debug.log('Succeeded!')
     except:
         debug.critical("""Failed to copy default configuration
         file to %s. This could be an indication of a
         permissions problem. Please make sure '%s' is writable."""
                        % (fname,
                           self.temp_configuration.dotVistrails))
    def updateVistrail(self):
        """updateVistrail() -> None
        Update vistrail to contain changes to the python source

        """
        deleted_ports = []
        added_ports = []
        if self.has_inputs:
            (input_deleted_ports, input_added_ports) = \
                self.getPortDiff('input', self.inputPortTable)
            deleted_ports.extend(input_deleted_ports)
            added_ports.extend(input_added_ports)
        if self.has_outputs:
            (output_deleted_ports, output_added_ports) = \
                self.getPortDiff('output', self.outputPortTable)
            deleted_ports.extend(output_deleted_ports)
            added_ports.extend(output_added_ports)

        functions = []
        modified = False
        if self.codeEditor.__class__.__name__ != '_PythonEditor':
            modified = self.codeEditor.document().isModified()
        else:
            modified = self.codeEditor.isModified()
        
        if (self.codeEditor is not None and modified):
            try:
                code = str(self.codeEditor.toPlainText())
            except UnicodeEncodeError, e:
                debug.critical('Source Code Editor does not support non-ascii characters', str(e)) 
                return False
            if self.sourceEncode:
                code = urllib.quote(code)
            functions.append((self.sourcePortName, [code]))
 def load_entity(self, *args):
     if args[1] in Collection.entity_types:
         entity = Collection.entity_types[args[1]].load(*args)
         return entity
     else:
         debug.critical("Cannot find entity type '%s'" % args[1])
     return None
    def createPackage(self):
        pm = get_package_manager()
        if pm.has_package(self.signature):
            package = pm.get_package_by_identifier()
            pm.remove_package(package.codepath)

        reg = core.modules.module_registry.get_module_registry()

        # create a document hash integer from the cached sax tree
        # "name" is what suds use as the cache key
        name = '%s-%s' % (abs(hash(self.address)), "wsdl")
        wsdl = package_cache.get(name)
        if not wsdl:
            debug.critical("File not found in SUDS cache: '%s'" % name)
            self.wsdlHash = '0'
            return
        self.wsdlHash = str(int(hashlib.md5(str(wsdl.root)).hexdigest(), 16))

        package_id = reg.idScope.getNewId(Package.vtType)
        package = Package(id=package_id,
                          codepath=__file__,
                          load_configuration=False,
                          name="SUDS#" + self.address,
                          identifier=self.signature,
                          version=self.wsdlHash,
                          )
        self.package = package
        reg.add_package(package)
        self.module = new_module(Module, str(self.signature))
        reg.add_module(self.module, **{'package':self.signature,
                                       'package_version':self.wsdlHash,
                                       'abstract':True})
 def saveToPNG(self, filename):
     """ saveToPNG(filename: str) -> None        
     Abtract function for saving the current widget contents to an
     image file
     
     """
     debug.critical('saveToPNG() is unimplemented by the inherited cell')
    def add_wf_exec_entity(self, wf_exec, add_to_map=False):
        version_id = wf_exec.parent_version
        is_new = False
        if version_id not in self.wf_entity_map:
            is_new = True
            # FIXME add new workflow entity for this version
            if version_id not in self.vistrail.actionMap:
                raise Exception("Version %d does not occur in vistrail." % \
                                    version_id)
            action = self.vistrail.actionMap[version_id]
            try:
                workflow = self.vistrail.getPipeline(version_id)
            except:
                import traceback
                if self.vistrail.has_tag(version_id):
                    tag_str = self.vistrail.get_tag(version_id)
                else:
                    tag_str = str(version_id)
                debug.critical("Failed to construct pipeline '%s'" % tag_str,
                               traceback.format_exc())
                workflow = self.vistrail.getPipeline(0)
            wf_entity = self.create_workflow_entity(workflow, action)
            self.wf_entity_map[version_id] = wf_entity
        else:
            wf_entity = self.wf_entity_map[version_id]

        entity = self.create_wf_exec_entity(wf_exec, wf_entity)
        if add_to_map:
            self.wf_exec_entity_map[wf_exec.id] = entity
        if is_new:
            return (entity, wf_entity)
        return (entity, None)
def initialize(*args, **keywords):
    if "CLTools" == name:
        # this is the original package
        location = os.path.join(core.system.default_dot_vistrails(), "CLTools")
        # make sure dir exist
        if not os.path.isdir(location):
            try:
                debug.log("Creating CLTools directory...")
                os.mkdir(location)
            except:
                debug.critical(
                    """Could not create CLTools directory. Make
 sure '%s' does not exist and parent directory is writable"""
                    % location
                )
                sys.exit(1)
    else:
        # this is a standalone package so modules are placed in this directory
        location = os.path.dirname(__file__)

    reg = core.modules.module_registry.get_module_registry()
    reg.add_module(CLTools, hide_descriptor=True)
    for path in os.listdir(location):
        if path.endswith(SUFFIX):
            try:
                add_tool(os.path.join(location, path))
            except Exception as exc:
                import traceback

                debug.critical(
                    "Package CLTools failed to create module "
                    "from '%s': %s" % (os.path.join(location, path), str(exc)),
                    traceback.format_exc(),
                )
 def interpolate(self, ranges, stepCount):
     """ interpolate(ranges: tuple, stepCount: int) -> list
     
     This function takes a number of (min,max) or (s1,...sn) to
     interpolate exact stepCount number of step. The output will be
     a list of stepCount elements where each of them is (a1,...,an).
     a{i} is either int or string and n is the number of arguments.
     
     """
     params = []
     for r in ranges:
         interpolatedValues = []
         argumentType = type(r[0])
         if argumentType in [int, float]:
             for i in xrange(stepCount):
                 if stepCount>1: t = i/float(stepCount-1)
                 else: t = 0
                 interpolatedValues.append(argumentType(r[0]+t*(r[1]-r[0])))
         elif argumentType==str:
             interpolatedValues = list(r)
         else:
             debug.critical('Cannot interpolate non-cardinal types')
             assert False
         params.append(interpolatedValues)
     return zip(*params)
def initialize(*args, **keywords):
    reg = core.modules.module_registry.get_module_registry()
    basic = core.modules.basic_modules

    reg.add_module(HTTP, abstract=True)
    reg.add_module(HTTPFile)
    reg.add_input_port(HTTPFile, "url", (basic.String, "URL"))
    reg.add_output_port(HTTPFile, "file", (basic.File, "local File object"))
    reg.add_output_port(HTTPFile, "local_filename", (basic.String, "local filename"), optional=True)

    reg.add_module(RepoSync)
    reg.add_input_port(RepoSync, "file", (basic.File, "File"))
    reg.add_input_port(RepoSync, "checksum", (basic.String, "Checksum"), optional=True)
    reg.add_output_port(RepoSync, "file", (basic.File, "Repository Synced File object"))
    reg.add_output_port(RepoSync, "checksum", (basic.String, "Checksum"), optional=True)

    global package_directory
    package_directory = core.system.default_dot_vistrails() + "/HTTP"

    if not os.path.isdir(package_directory):
        try:
            debug.log("Creating HTTP package directory: %s" % package_directory)
            os.mkdir(package_directory)
        except:
            debug.critical(
                ("Create directory failed. Make sure '%s' does not" " exist and parent directory is writable")
                % package_directory
            )
            sys.exit(1)
    def save_vistrail(self, locator_class,
                      vistrailView=None,
                      force_choose_locator=False):
        """

        force_choose_locator=True triggers 'save as' behavior
        """
        global bobo

        if not vistrailView:
            vistrailView = self.currentWidget()
        vistrailView.flush_changes()
        if vistrailView:
            gui_get = locator_class.save_from_gui
            # get a locator to write to
            if force_choose_locator:
                locator = gui_get(self, Vistrail.vtType,
                                  vistrailView.controller.locator)
            else:
                locator = (vistrailView.controller.locator or
                           gui_get(self, Vistrail.vtType,
                                   vistrailView.controller.locator))
            if locator == untitled_locator():
                locator = gui_get(self, Vistrail.vtType,
                                  vistrailView.controller.locator)
            # if couldn't get one, ignore the request
            if not locator:
                return False
            # update collection
            try:
                vistrailView.controller.write_vistrail(locator)
            except Exception, e:
                debug.critical('An error has occurred', str(e))
                raise
                return False
            try:
                thumb_cache = ThumbnailCache.getInstance()
                vistrailView.controller.vistrail.thumbnails = \
                    vistrailView.controller.find_thumbnails(
                        tags_only=thumb_cache.conf.tagsOnly)
                vistrailView.controller.vistrail.abstractions = \
                    vistrailView.controller.find_abstractions(
                        vistrailView.controller.vistrail, True)

                collection = Collection.getInstance()
                url = locator.to_url()
                # create index if not exist
                entity = collection.fromUrl(url)
                if entity:
                    # find parent vistrail
                    while entity.parent:
                        entity = entity.parent 
                else:
                    entity = collection.updateVistrail(url, vistrailView.controller.vistrail)
                # add to relevant workspace categories
                collection.add_to_workspace(entity)
                collection.commit()
            except Exception, e:
                debug.critical('Failed to index vistrail', str(e))
Exemple #18
0
 def reload_current_package_finisher(self, codepath, reverse_deps, prefix_dictionary):
     # REENABLES the current package and all reverse dependencies
     pm = get_package_manager()
     try:
         pm.reload_package_enable(reverse_deps, prefix_dictionary)
     except self._current_package.InitializationFailed, e:
         debug.critical("Re-initialization of package '%s' failed" % 
                         codepath, str(e))
         raise
Exemple #19
0
 def runStartupHooks(self):
     """ runStartupHooks() -> None
     After initialization, need to run all start up hooks registered
     
     """
     for hook in self.startupHooks:
         try:
             hook()
         except Exception, e:
             debug.critical("Exception raised during hook: %s - %s" %
                          (e.__class__, e))
 def getChildTypes(type):
     schema = self.service.wsdl.schema
     if type in schema.elements:
         if schema.elements[type].type is not None:
             return [(schema.elements[type].name, schema.elements[type].type)]
         else:
             return [(c[0].name, c[0].type) for c in schema.elements[type].children()]
     elif type in schema.types:
         return [(c[0].name, c[0].type) for c in schema.types[type].children()]
     debug.critical("Could not resolve type in WSDL:" + str(type))
     return []
    def show_error_message(self, pkg, msg):
        """show_error_message(pkg: Package, msg: str) -> None
        Print a message to standard error output and emit a signal to the
        builder so if it is possible, a message box is also shown """

        debug.critical("Package %s (%s) says: %s"%(pkg.name,
                                                   pkg.identifier,
                                                   msg))
        app = get_vistrails_application()
        app.send_notification("pm_package_error_message", pkg.identifier,
                              pkg.name, msg)
Exemple #22
0
 def create_user_packages_init(userpackagesname):
     try:
         name = os.path.join(userpackagesname, '__init__.py')
         f = file(name, 'w')
         f.write('pass\n')
         f.close()
     except:
         msg = ("""Failed to create file '%s'. This could indicate a
         rare combination of a race condition and a permissions problem.
         Please make sure it is writable.""" % name)
         debug.critical(msg)
         sys.exit(1)
 def redo(self):
     """Performs one redo step if possible, moving down the version tree."""
     action_map = self.controller.vistrail.actionMap
     old_action = action_map.get(self.controller.current_version, None)
     if not self.can_redo():
         critical("Redo on an empty redo stack. Ignoring.")
         return
     next_version = self.redo_stack[-1]
     self.redo_stack = self.redo_stack[:-1]
     self.controller.show_child_version(next_version)
     new_action = action_map[self.controller.current_version]
     self.set_pipeline_selection(old_action, new_action, 'redo')
     return next_version
 def testConnection(self):
     """testConnection() -> None """
     config = {'host': str(self.hostEdt.text()),
               'port': int(self.portEdt.value()),
               'user': str(self.userEdt.text()),
               'passwd': str(self.passwdEdt.text()),
               'db': str(self.databaseEdt.text())}
     try:
         db.services.io.test_db_connection(config)
         show_info('Vistrails',"Connection succeeded!")
         
     except Exception, e:
         debug.critical('An error has occurred', str(e))
Exemple #25
0
    def create_default_directory(self):
        if os.path.lexists(self.temp_configuration.dotVistrails):
            return

        debug.log('Will try to create default directory')
        try:
            os.mkdir(self.temp_configuration.dotVistrails)
            debug.log('Succeeded!')
        except:
            debug.critical("""Failed to create initialization directory.
                    This could be an indication of a permissions problem.
                    Make sure parent directory of '%s' is writable."""
                    % self.temp_configuration.dotVistrails)
            sys.exit(1)
Exemple #26
0
 def process_interactive_input(self):
     usedb = False
     if self.temp_db_options.host:
         usedb = True
     if self.input:
         locator = None
         #check if versions are embedded in the filename
         for filename in self.input:
             f_name, version = self._parse_vtinfo(filename, not usedb)
             if f_name is None:
                 msg = "Could not find file %s" % filename
                 debug.critical(msg)
             elif not usedb:
                 locator = FileLocator(os.path.abspath(f_name))
                 #_vnode and _vtag will be set when a .vtl file is open and
                 # it can be either a FileLocator or a DBLocator
                 
             elif usedb:
                 locator = DBLocator(host=self.temp_db_options.host,
                                     port=self.temp_db_options.port,
                                     database=self.temp_db_options.db,
                                     user='',
                                     passwd='',
                                     obj_id=f_name,
                                     obj_type=None,
                                     connection_id=None)
             if locator:
                 if hasattr(locator, '_vnode') and \
                         locator._vnode is not None:
                     version = locator._vnode
                 if hasattr(locator,'_vtag'):
                     # if a tag is set, it should be used instead of the
                     # version number
                     if locator._vtag != '':
                         version = locator._vtag
                 execute = self.temp_configuration.executeWorkflows
                 mashuptrail = None
                 mashupversion = None
                 if hasattr(locator, '_mshptrail'):
                     mashuptrail = locator._mshptrail
                 if hasattr(locator, '_mshpversion'):
                     mashupversion = locator._mshpversion
                 if not self.temp_configuration.showSpreadsheetOnly:
                     self.showBuilderWindow()
                 self.builderWindow.open_vistrail_without_prompt(locator,
                                                                 version, execute,
                                                                 mashuptrail=mashuptrail, 
                                                                 mashupVersion=mashupversion)
             if self.temp_configuration.reviewMode:
                 self.builderWindow.interactiveExportCurrentPipeline()
 def set_properties(self):
     # Set properties
     try:
         self.name = self._module.name
         self.identifier = self._module.identifier
         self.version = self._module.version
         self.package_dir = os.path.dirname(self._module.__file__)
     except AttributeError, e:
         try:
             v = self._module.__file__
         except AttributeError:
             v = self._module
         debug.critical("Package %s is missing necessary attribute" % v)
         raise e
    def open_vistrail(self, locator, version=None, is_abstraction=False):
        """open_vistrail(locator: Locator, version = None: int or str,
                         is_abstraction: bool)

        opens a new vistrail from the given locator, selecting the
        given version.

        """
        self.close_first_vistrail_if_necessary()
        if self.single_document_mode and self.currentView():
            self.closeVistrail()
        view = self.ensureVistrail(locator)
        if view:
            if version is not None:
                if type(version) == type(""):
                    try:
                        version = view.vistrail.get_version_number(version)
                    except:
                        version = None
                if version is not None:
                    view.setup_view(version)
            return view
        try:
            (vistrail, abstraction_files, thumbnail_files, _) = \
                                        load_vistrail(locator, is_abstraction)
            result = self.set_vistrail_view(vistrail, locator, 
                                            abstraction_files, thumbnail_files,
                                            version)
            # update collection
            try:
                vistrail.thumbnails = thumbnail_files
                vistrail.abstractions = abstraction_files
                collection = Collection.getInstance()
                url = locator.to_url()
                # create index if not exist
                entity = collection.fromUrl(url)
                if entity:
                    # find parent vistrail
                    while entity.parent:
                        entity = entity.parent 
                else:
                    entity = collection.updateVistrail(url, vistrail)
                # add to relevant workspace categories
                collection.add_to_workspace(entity)
                collection.commit()
            except Exception, e:
                import traceback
                debug.critical('Failed to index vistrail', str(e) + traceback.format_exc())
            return result
Exemple #29
0
 def install_default_startup():
     debug.log('Will try to create default startup script')
     try:
         root_dir = core.system.vistrails_root_directory()
         default_file = os.path.join(root_dir,'core','resources',
                                     'default_vistrails_startup')
         user_file = os.path.join(self.temp_configuration.dotVistrails,
                                  'startup.py')
         shutil.copyfile(default_file,user_file)
         debug.log('Succeeded!')
     except:
         debug.critical("""Failed to copy default file %s.
         This could be an indication of a permissions problem.
         Make sure directory '%s' is writable"""
         % (user_file,self.temp_configuration.dotVistrails))
         sys.exit(1)
    def updateFunction(self, function, port_spec):
        """ updateFunction(function: ModuleFunction,
                           port_spec: PortSpec) -> None
        Auto create widgets to describes the function 'function'
        
        """
        reg = module_registry.get_module_registry()
        self.function = function
        self.widgets = []
        self.labels = []

        ps_labels = None
        if port_spec is not None:
            ps_labels = port_spec.labels
        for pIndex in xrange(len(function.params)):
            p = function.params[pIndex]
            # FIXME: Find the source of this problem instead
            # of working around it here.
            if p.identifier == '':
                idn = 'edu.utah.sci.vistrails.basic'
            else:
                idn = p.identifier

            p_module = None
            try:
                p_module = reg.get_module_by_name(idn,
                                                  p.type,
                                                  p.namespace)
            except module_registry.ModuleRegistryException:
                debug.critical("HIT ModuleRegistryException in DROPBOX")
                pass
            widget_type = get_widget_class(p_module)
            ps_label = ''
            if ps_labels is not None and len(ps_labels) > pIndex:
                ps_label = str(ps_labels[pIndex])
            label = QHoverAliasLabel(p.alias, p.type, ps_label)

            constant_widget = widget_type(p, self)
            self.widgets.append(constant_widget)
            self.labels.append(label)
            self.layout().addWidget(label, pIndex, 0)
            self.layout().addWidget(constant_widget, pIndex, 1)
            # Ugly hack to add browse button to methods that look like
            # they have to do with files
            if('file' in function.name.lower() and p.type == 'String'):
                browseButton = FileChooserToolButton(self, constant_widget)
                self.layout().addWidget(browseButton, pIndex, 2)
Exemple #31
0
 def setParameterExploration(self, xmlString):
     """ setParameterExploration(xmlString: string) -> None
     Sets the current parameter exploration to the one
     defined by 'xmlString'.
     
     """
     if not xmlString:
         return
     # Parse/validate the xml
     try:
         xmlDoc = parseString(xmlString).documentElement
     except:
         debug.critical("Parameter Exploration load failed because of "
                        "invalid XML:\n\n%s" % xmlString)
         return
     # Set the exploration dimensions
     dims = eval(str(xmlDoc.attributes['dims'].value))
     self.peWidget.table.label.setCounts(dims)
     # Set the virtual cell layout
     layout = eval(str(xmlDoc.attributes['layout'].value))
     self.virtualCell.setConfiguration(layout)
     # Populate parameter exploration window with stored functions and aliases
     for f in xmlDoc.getElementsByTagName('function'):
         # Retrieve function attributes
         f_id = long(f.attributes['id'].value)
         f_name = str(f.attributes['name'].value)
         f_is_alias = (str(f.attributes['alias'].value) == 'True')
         # Search the parameter treeWidget for this function and add it directly
         newEditor = None
         for tidx in xrange(self.paramView.treeWidget.topLevelItemCount()):
             moduleItem = self.paramView.treeWidget.topLevelItem(tidx)
             for cidx in xrange(moduleItem.childCount()):
                 paramInfo = moduleItem.child(cidx).parameter
                 name, params = paramInfo
                 if params[0].parent_id == f_id and params[
                         0].is_alias == f_is_alias:
                     newEditor = self.peWidget.table.addParameter(paramInfo)
         # Retrieve params for this function and set their values in the UI
         if newEditor:
             for p in f.getElementsByTagName('param'):
                 # Locate the param in the newly added param editor and set values
                 p_id = long(p.attributes['id'].value)
                 for paramWidget in newEditor.paramWidgets:
                     if paramWidget.param.id == p_id:
                         # Set Parameter Dimension (radio button)
                         p_dim = int(p.attributes['dim'].value)
                         paramWidget.setDimension(p_dim)
                         # Set Interpolator Type (dropdown list)
                         p_intType = str(p.attributes['interp'].value)
                         paramWidget.editor.selectInterpolator(p_intType)
                         # Set Interpolator Value(s)
                         interpolator = paramWidget.editor.stackedEditors.currentWidget(
                         )
                         if p_intType == 'Linear Interpolation':
                             # Set min/max
                             p_min = str(p.attributes['min'].value)
                             p_max = str(p.attributes['max'].value)
                             interpolator.fromEdit.setText(p_min)
                             interpolator.toEdit.setText(p_max)
                         elif p_intType == 'List':
                             p_values = str(p.attributes['values'].value)
                             # Set internal list structure
                             interpolator._str_values = eval(p_values)
                             # Update UI list
                             if interpolator.type == 'String':
                                 interpolator.listValues.setText(p_values)
                             else:
                                 interpolator.listValues.setText(
                                     p_values.replace("'",
                                                      "").replace('"', ''))
                         elif p_intType == 'User-defined Function':
                             # Set function code
                             p_code = str(p.attributes['code'].value)
                             interpolator.function = p_code
Exemple #32
0
from plot import MplPlot, MplPlotConfigurationWidget
from cdms_data import CDMSData
import time
import urllib

from core.bundles import py_import
try:
    mpl_dict = {
        'linux-ubuntu': 'python-matplotlib',
        'linux-fedora': 'python-matplotlib'
    }
    matplotlib = py_import('matplotlib', mpl_dict)
    matplotlib.use('Qt4Agg', warn=False)
    pylab = py_import('pylab', mpl_dict)
except Exception, e:
    debug.critical("Exception: %s" % e)

################################################################################


class MplFigureManager(Module):
    """
    MplFigureManager is the figure viewer available from
    Matplotlib. It supports pan/zoom, save and other plot
    interactions. It can be embedded in different backend. We are
    using Qt4Agg backend in this package.
    
    """
    def __init__(self):
        """ MplFigureManager() -> MplFigureManager
        Init the class as a storage structure
class SourceConfigurationWidget(SourceWidget):
    def __init__(self,
                 module,
                 controller,
                 editor_class=None,
                 has_inputs=True,
                 has_outputs=True,
                 parent=None,
                 encode=True,
                 portName='source'):
        SourceWidget.__init__(self, module, controller, editor_class,
                              has_inputs, has_outputs, parent, encode,
                              portName)
        self.detached_windows = []
        self.createButtons()
        #connect signals
        if has_inputs:
            self.connect(self.inputPortTable, QtCore.SIGNAL("contentsChanged"),
                         self.updateState)
        if has_outputs:
            self.connect(self.outputPortTable,
                         QtCore.SIGNAL("contentsChanged"), self.updateState)
        self.connect(self.codeEditor, QtCore.SIGNAL("textChanged()"),
                     self.updateState)
        self.adjustSize()
        self.setMouseTracking(True)
        self.mouseOver = False

    def enterEvent(self, event):
        self.mouseOver = True

    def leaveEvent(self, event):
        self.mouseOver = False

    def createButtons(self):
        """ createButtons() -> None
        Create and connect signals to Save & Reset button
        
        """
        self.buttonLayout = QtGui.QHBoxLayout()
        self.buttonLayout.setMargin(5)
        self.detachButton = QtGui.QPushButton("Show read-only window")
        self.buttonLayout.addWidget(self.detachButton)
        self.buttonLayout.addStretch()
        self.saveButton = QtGui.QPushButton('&Save', self)
        self.saveButton.setFixedWidth(100)
        self.saveButton.setEnabled(False)
        self.buttonLayout.addWidget(self.saveButton)
        self.resetButton = QtGui.QPushButton('&Reset', self)
        self.resetButton.setFixedWidth(100)
        self.resetButton.setEnabled(False)
        self.buttonLayout.addSpacing(10)
        self.buttonLayout.addWidget(self.resetButton)
        self.layout().addLayout(self.buttonLayout)
        self.connect(self.detachButton, QtCore.SIGNAL("clicked()"),
                     self.detachReadOnlyWindow)
        self.connect(self.saveButton, QtCore.SIGNAL('clicked(bool)'),
                     self.saveTriggered)
        self.connect(self.resetButton, QtCore.SIGNAL('clicked(bool)'),
                     self.resetTriggered)

    def detachReadOnlyWindow(self):
        from gui.vistrails_window import _app
        widget = SourceViewerWidget(self.module, self.controller,
                                    type(self.codeEditor), self.has_inputs,
                                    self.has_outputs, None, self.sourceEncode,
                                    self.sourcePortName)
        window = QtGui.QMainWindow()
        window.setCentralWidget(widget)
        window.setWindowTitle(widget.windowTitle())
        self.connect(widget, QtCore.SIGNAL("widgetClosed"), window.close)
        widget.setVisible(True)
        _app.palette_window.windows.append(window)
        window.show()

    def updateVistrail(self):
        """updateVistrail() -> None
        Update vistrail to contain changes to the python source

        """
        deleted_ports = []
        added_ports = []
        if self.has_inputs:
            (input_deleted_ports, input_added_ports) = \
                self.getPortDiff('input', self.inputPortTable)
            deleted_ports.extend(input_deleted_ports)
            added_ports.extend(input_added_ports)
        if self.has_outputs:
            (output_deleted_ports, output_added_ports) = \
                self.getPortDiff('output', self.outputPortTable)
            deleted_ports.extend(output_deleted_ports)
            added_ports.extend(output_added_ports)

        functions = []
        modified = False
        if self.codeEditor.__class__.__name__ != '_PythonEditor':
            modified = self.codeEditor.document().isModified()
        else:
            modified = self.codeEditor.isModified()

        if (self.codeEditor is not None and modified):
            try:
                code = str(self.codeEditor.toPlainText())
            except UnicodeEncodeError, e:
                debug.critical(
                    'Source Code Editor does not support non-ascii characters',
                    str(e))
                return False
            if self.sourceEncode:
                code = urllib.quote(code)
            functions.append((self.sourcePortName, [code]))
        if len(deleted_ports) + len(added_ports) + len(functions) == 0:
            # nothing changed
            return True
        try:
            self.controller.update_ports_and_functions(self.module.id,
                                                       deleted_ports,
                                                       added_ports, functions)
        except PortAlreadyExists, e:
            debug.critical('Port Already Exists %s' % str(e))
            return False
Exemple #34
0
        from core.modules.basic_modules import identifier as basic_modules_identifier
        if self._current_package.identifier != basic_modules_identifier:
            new_deps.append(basic_modules_identifier)

        try:
            pm.check_dependencies(self._current_package, new_deps)
        except self._current_package.MissingDependency, e:
            debug.critical("Missing dependencies", str(e))
        else:
            palette = QModulePalette.instance()
            palette.setUpdatesEnabled(False)
            try:
                pm.late_enable_package(codepath)
            except self._current_package.InitializationFailed, e:
                debug.critical(
                    "Initialization of package '%s' failed" % codepath, str(e))
                raise
            finally:
                palette.setUpdatesEnabled(True)
                palette.treeWidget.expandAll()
            # the old code that used to be here to update the lists
            # has been moved to package_added
            self.invalidate_current_pipeline()

    def disable_current_package(self):
        av = self._available_packages_list
        inst = self._enabled_packages_list
        item = inst.currentItem()
        pos = inst.indexFromItem(item).row()
        codepath = str(item.text())
        pm = get_package_manager()
Exemple #35
0
                if abstraction is not None:
                    options = {
                        'namespace': abstraction.uuid,
                        'hide_namespace': True,
                        'version': str(abstraction.internal_version)
                    }
                    reg.auto_add_module((abstraction, options))
                    reg.auto_add_ports(abstraction)
                    # print "Added subworkflow", abs_name, abstraction.uuid
                elif abs_name not in cannot_load:
                    cannot_load[abs_name] = (abs_vistrail, '')
        last_count = len(abs_vistrails)
        abs_vistrails = new_vistrails

    for abs_name, (_, e) in cannot_load.iteritems():
        debug.critical("Cannot load subworkflow '%s'" % abs_name)
        if e:
            debug.critical("- %s" % e)
    for abs_name in abs_vistrails:
        debug.critical("Cannot load subworkflow '%s'" % abs_name)


def package_dependencies():
    import core.packagemanager
    manager = core.packagemanager.get_package_manager()

    reg = core.modules.module_registry.get_module_registry()
    conf = get_vistrails_configuration()
    if conf.check("abstractionsDirectory"):
        abstraction_dir = conf.abstractionsDirectory
    p = re.compile(r".*\.xml")
Exemple #36
0
                else:
                    debug.warning('Duplicate package identifier: %s' % \
                                      package.identifier)
                self._package_versions[package.identifier][package.version] = \
                    package

        for pkg in failed:
            del self._package_list[pkg.codepath]
        failed = []

        # determine dependencies
        for package in self._package_list.itervalues():
            try:
                self.add_dependencies(package)
            except Package.MissingDependency, e:
                debug.critical("Dependencies of package %s are missing "
                               "so it will be disabled" % package.name, str(e))
                package.remove_own_dom_element()
                self._dependency_graph.delete_vertex(package.identifier)
                del self._package_versions[package.identifier][package.version]
                if len(self._package_versions[package.identifier]) == 0:
                    del self._package_versions[package.identifier]
                failed.append(package)

        for pkg in failed:
            del self._package_list[pkg.codepath]

        # perform actual initialization
        try:
            g = self._dependency_graph.inverse_immutable()
            sorted_packages = g.vertices_topological_sort()
        except core.data_structures.graph.Graph.GraphContainsCycles, e:
Exemple #37
0
def add_tool(path):
    global cl_tools
    # first create classes
    tool_name = os.path.basename(path)
    if not tool_name.endswith(SUFFIX):
        return
    (tool_name, _) = os.path.splitext(tool_name)

    if tool_name in cl_tools:
        debug.critical("Package CLTools already added: '%s'" % tool_name)
    try:
        conf = json.load(open(path))
    except ValueError as exc:
        debug.critical("Package CLTools could not parse '%s'" % path, str(exc))
        return

    def compute(self):
        """ 1. read inputs
            2. call with inputs
            3. set outputs
        """
        # add all arguments as an unordered list
        args = [self.conf['command']]
        file_std = 'options' in self.conf and 'std_using_files' in self.conf[
            'options']
        setOutput = []  # (name, File) - set File contents as output for name
        open_files = []
        stdin = None
        kwargs = {}
        for type, name, klass, options in self.conf['args']:
            type = type.lower()
            klass = klass.lower()
            if "constant" == type:
                flag = 'flag' in options and options['flag']
                if flag:
                    args.append(flag)
                if name:
                    # if flag==name we assume user tried to name a constant
                    if not name == flag:
                        if 'prefix' in options:
                            name = options['prefix'] + str(name)
                        args.append(name)
            elif "input" == type:
                # handle multiple inputs
                values = self.forceGetInputListFromPort(name)
                if values and 'list' == klass:
                    values = values[0]
                    klass = options['type'].lower() \
                      if 'type' in options else 'string'
                for value in values:
                    if 'flag' == klass:
                        if value and 'flag' in options and options['flag']:
                            value = options['flag']
                        else:
                            # use name as flag
                            value = name
                    elif 'file' == klass:
                        value = str(value.name)
                    # check for flag and append file name
                    if not 'flag' == klass and 'flag' in options:
                        args.append(options['flag'])
                    if 'prefix' in options:
                        value = options['prefix'] + str(value)
                    args.append(str(value))
            elif "output" == type:
                # output must be a filename but we may convert the result to a string
                # create new file
                file = self.interpreter.filePool.create_file(
                    suffix=options.get('suffix', DEFAULTFILESUFFIX))
                fname = file.name
                if 'prefix' in options:
                    fname = options['prefix'] + fname
                if 'flag' in options:
                    args.append(options['flag'])
                args.append(fname)
                if "file" == klass:
                    self.setResult(name, file)
                else:  # assume String - set to string value after execution
                    setOutput.append((name, file))
            elif "inputoutput" == type:
                # handle single file that is both input and output
                values = self.forceGetInputListFromPort(name)
                for value in values:
                    # create copy of infile to operate on
                    outfile = self.interpreter.filePool.create_file(
                        suffix=options.get('suffix', DEFAULTFILESUFFIX))
                    try:
                        shutil.copyfile(value.name, outfile.name)
                    except IOError, e:
                        raise ModuleError("Error copying file '%s': %s" %
                                          (value.name, str(e)))
                    value = str(outfile.name)
                    # check for flag and append file name
                    if 'flag' in options:
                        args.append(options['flag'])
                    if 'prefix' in options:
                        value = options['prefix'] + str(value)
                    args.append(str(value))
                    self.setResult(name, outfile)
                    # only process one input
                    break
        if "stdin" in self.conf:
            name, type, options = self.conf["stdin"]
            type = type.lower()
            if self.hasInputFromPort(name):
                value = self.getInputFromPort(name)
                if "file" == type:
                    if file_std:
                        f = open(value.name, 'rb')
                        data = f.read()
                        stdin = ''
                        while data:
                            stdin += data
                            data = f.read()
                        f.close()
                    else:
                        f = open(value.name, 'rb')
                else:  # assume String
                    if file_std:
                        file = self.interpreter.filePool.create_file()
                        f = open(file.name, 'w')
                        f.write(str(value))
                        f.close()
                        f = open(file.name)
                    else:
                        stdin = value
                if file_std:
                    open_files.append(f)
                    kwargs['stdin'] = f.fileno()
                else:
                    kwargs['stdin'] = subprocess.PIPE
        if "stdout" in self.conf:
            if file_std:
                name, type, options = self.conf["stdout"]
                type = type.lower()
                file = self.interpreter.filePool.create_file(
                    suffix=DEFAULTFILESUFFIX)
                if "file" == type:
                    self.setResult(name, file)
                else:  # assume String - set to string value after execution
                    setOutput.append((name, file))
                f = open(file.name, 'wb')
                open_files.append(f)
                kwargs['stdout'] = f.fileno()
            else:
                kwargs['stdout'] = subprocess.PIPE
        if "stderr" in self.conf:
            if file_std:
                name, type, options = self.conf["stderr"]
                type = type.lower()
                file = self.interpreter.filePool.create_file(
                    suffix=DEFAULTFILESUFFIX)
                if "file" == type:
                    self.setResult(name, file)
                else:  # assume String - set to string value after execution
                    setOutput.append((name, file))
                f = open(file.name, 'wb')
                open_files.append(f)
                kwargs['stderr'] = f.fileno()
            else:
                kwargs['stderr'] = subprocess.PIPE
        # On windows, builtin commands like cd/dir must use shell=True
        if core.system.systemType in ['Windows', 'Microsoft'] and \
                          args[0] in ['dir', 'cd']:
            kwargs['shell'] = True

        if configuration.check('env'):
            env = os.environ
            for var in configuration.env.split(";"):
                key, value = var.split('=')
                key = key.strip()
                value = value.strip()
                if key:
                    env[key] = value
            kwargs['env'] = env
        #print "calling", args, kwargs

        if 'dir' in self.conf:
            kwargs['cwd'] = self.conf['dir']

        process = subprocess.Popen(args, **kwargs)
        if file_std:
            process.wait()
        else:
            #if stdin:
            #    print "stdin:", len(stdin), stdin[:30]
            stdout, stderr = _eintr_retry_call(process.communicate, stdin)
            #stdout, stderr = process.communicate(stdin)
            #if stdout:
            #    print "stdout:", len(stdout), stdout[:30]
            #if stderr:
            #    print "stderr:", len(stderr), stderr[:30]

        for f in open_files:
            f.close()

        for name, file in setOutput:
            f = open(file.name)
            self.setResult(name, f.read())
            f.close()

        if not file_std:
            if stdout and "stdout" in self.conf:
                name, type, options = self.conf["stdout"]
                type = type.lower()
                if "file" == type:
                    file = self.interpreter.filePool.create_file(
                        suffix=DEFAULTFILESUFFIX)
                    f = open(file.name, 'w')
                    f.write(stdout)
                    f.close()
                    self.setResult(name, file)
                else:  # assume String - set to string value after execution
                    self.setResult(name, stdout)
            if stderr and "stderr" in self.conf:
                name, type, options = self.conf["stderr"]
                type = type.lower()
                if "file" == type:
                    file = self.interpreter.filePool.create_file(
                        suffix=DEFAULTFILESUFFIX)
                    f = open(file.name, 'w')
                    f.write(stderr)
                    f.close()
                    self.setResult(name, file)
                else:  # assume String - set to string value after execution
                    self.setResult(name, stderr)
Exemple #38
0
        def execDotVistrails(tried_once=False):
            """ execDotVistrails() -> None
            Actually execute the Vistrail initialization
            
            """
            # if it is file, then must move old-style .vistrails to
            # directory.
            if os.path.isfile(self.temp_configuration.dotVistrails):
                debug.warning(
                    "Old-style initialization hooks. Will try to set things correctly."
                )
                (fd, name) = tempfile.mkstemp()
                os.close(fd)
                shutil.copyfile(self.temp_configuration.dotVistrails, name)
                try:
                    os.unlink(self.temp_configuration.dotVistrails)
                except:
                    debug.critical("""Failed to remove old initialization file.
                    This could be an indication of a permissions problem.
                    Make sure file '%s' is writable.""" %
                                   self.temp_configuration.dotVistrails)
                    sys.exit(1)
                self.create_default_directory()
                try:
                    destiny = os.path.join(
                        self.temp_configuration.dotVistrails, 'startup.py')
                    shutil.copyfile(name, destiny)
                except:
                    debug.critical("""Failed to copy old initialization file to
                    newly-created initialization directory. This must have been
                    a race condition. Please remove '%s' and
                    restart VisTrails.""" %
                                   self.temp_configuration.dotVistrails)
                    sys.exit(1)
                debug.critical("Successful move!")
                try:
                    os.unlink(name)
                except:
                    debug.warning("Failed to erase temporary file.")

            if os.path.isdir(self.temp_configuration.dotVistrails):
                if self.temp_configuration.check('userPackageDirectory'):
                    userpackages = self.temp_configuration.userPackageDirectory
                else:
                    userpackages = os.path.join(
                        self.temp_configuration.dotVistrails, 'userpackages')
                startup = os.path.join(self.temp_configuration.dotVistrails,
                                       'startup.py')
                if self.temp_configuration.check('abstractionsDirectory'):
                    abstractions = self.temp_configuration.abstractionsDirectory
                else:
                    abstractions = os.path.join(
                        self.temp_configuration.dotVistrails, 'subworkflows')
                if (self.temp_configuration.has('thumbs')
                        and self.temp_configuration.thumbs.check(
                            'cacheDirectory')):
                    thumbnails = self.temp_configuration.thumbs.cacheDirectory
                else:
                    thumbnails = os.path.join(
                        self.temp_configuration.dotVistrails, 'thumbs')
                if not os.path.isdir(userpackages):
                    create_user_packages_dir(userpackages)
                if not os.path.isfile(os.path.join(userpackages,
                                                   '__init__.py')):
                    create_user_packages_init(userpackages)
                if not os.path.isdir(abstractions):
                    create_abstractions_dir(abstractions)
                if not os.path.isdir(thumbnails):
                    create_thumbnails_dir(thumbnails)
                try:

                    dotVistrails = file(startup)
                    g = {}
                    localsDir = {
                        'configuration': self.temp_configuration,
                        'addStartupHook': addStartupHook,
                        'addPackage': addPackage
                    }
                    old_path = copy.copy(sys.path)
                    sys.path.append(self.temp_configuration.dotVistrails)
                    exec dotVistrails in localsDir
                    sys.path = old_path
                    del localsDir['addPackage']
                    del localsDir['addStartupHook']
                    return localsDir
                except IOError:
                    if tried_once:
                        debug.critical("""Still cannot find default file.
                        Something has gone wrong. Please make sure ~/.vistrails
                        exists, is writable, and ~/.vistrails/startup.py does
                        not exist.""")
                        sys.exit(1)
                    debug.log('%s not found\nWill try to install default '
                              'startup file' % startup)
                    install_default_startup()
                    install_default_startupxml_if_needed()
                    return execDotVistrails(True)
            elif not os.path.lexists(self.temp_configuration.dotVistrails):
                debug.log('%s not found' %
                          self.temp_configuration.dotVistrails)
                self.create_default_directory()
                create_user_packages_dir()
                create_abstractions_dir()
                create_thumbnails_dir()
                install_default_startup()
                install_default_startupxml_if_needed()
                return execDotVistrails(True)
Exemple #39
0
    def setupDefaultFolders(self):
        """ setupDefaultFolders() -> None        
        Give default values to folders when there are no values specified
        
        """
        if self.temp_configuration.has('rootDirectory'):
            system.set_vistrails_root_directory(
                self.temp_configuration.rootDirectory)
        if self.temp_configuration.has('dataDirectory'):
            system.set_vistrails_data_directory( \
                self.temp_configuration.dataDirectory)
        if self.temp_configuration.has('fileDirectory'):
            system.set_vistrails_file_directory( \
                self.temp_configuration.fileDirectory)
        if (self.temp_configuration.has('verbosenessLevel')
                and self.temp_configuration.verbosenessLevel != -1):
            verbose = self.temp_configuration.verbosenessLevel
            if verbose < 0:
                msg = ("""Don't know how to set verboseness level to %s - "
                       "setting to the lowest one I know of: 0""" % verbose)
                debug.critical(msg)
                verbose = 0
            if verbose > 2:
                msg = ("""Don't know how to set verboseness level to %s - "
                       "setting to the highest one I know of: 2""" % verbose)
                debug.critical(msg)
                verbose = 2
            dbg = debug.DebugPrint.getInstance()
            levels = [dbg.Critical, dbg.Warning, dbg.Log]
            dbg.set_message_level(levels[verbose])
            debug.log("Set verboseness level to %s" % verbose)

        #these checks may need to update the persistent configuration, so
        # we have to change both objects
        #userpackages directory
        if not self.temp_configuration.check('userPackageDirectory'):
            s = os.path.join(self.temp_configuration.dotVistrails,
                             'userpackages')
            self.temp_configuration.userPackageDirectory = s
        if not self.configuration.check('userPackageDirectory'):
            s = os.path.join(self.configuration.dotVistrails, 'userpackages')
            self.configuration.userPackageDirectory = s
        #abstractions directory
        if not self.temp_configuration.check('abstractionsDirectory') or \
                self.temp_configuration.abstractionsDirectory == \
                os.path.join(self.temp_configuration.userPackageDirectory,
                             'abstractions'):
            s = os.path.join(self.temp_configuration.dotVistrails,
                             'subworkflows')
            self.temp_configuration.abstractionsDirectory = s
        if not self.configuration.check('abstractionsDirectory') or \
                self.configuration.abstractionsDirectory == \
                os.path.join(self.configuration.userPackageDirectory,
                             'abstractions'):
            s = os.path.join(self.configuration.dotVistrails, 'subworkflows')
            self.configuration.abstractionsDirectory = s
        #thumbnails directory
        if self.temp_configuration.has('thumbs'):
            if not self.temp_configuration.thumbs.check('cacheDirectory'):
                s = os.path.join(self.temp_configuration.dotVistrails,
                                 'thumbs')
                self.temp_configuration.thumbs.cacheDirectory = s
        if self.configuration.has('thumbs'):
            if not self.configuration.thumbs.check('cacheDirectory'):
                s = os.path.join(self.configuration.dotVistrails, 'thumbs')
                self.configuration.thumbs.cacheDirectory = s