def compute_evaluation_order(self, aliases): # Build the dependencies graph dp = {} for alias,(atype,(base,exp)) in aliases.items(): edges = [] for e in exp: edges += self.get_name_dependencies() dp[alias] = edges # Topological Sort to find the order to compute aliases # Just a slow implementation, O(n^3)... unordered = copy.copy(list(aliases.keys())) ordered = [] while unordered: added = [] for i in xrange(len(unordered)): ok = True u = unordered[i] for j in xrange(len(unordered)): if i!=j: for v in dp[unordered[j]]: if u==v: ok = False break if not ok: break if ok: added.append(i) if not added: debug.warning('Looping dependencies detected!') break for i in reversed(added): ordered.append(unordered[i]) del unordered[i] return ordered
def open(self): retry = True while retry: config = {'host': self.host, 'port': self.port, 'user': self.user} # unfortunately keywords are not standard across libraries if self.protocol == 'mysql': config['db'] = self.db_name if self.password is not None: config['passwd'] = self.password elif self.protocol == 'postgresql': config['database'] = self.db_name if self.password is not None: config['password'] = self.password try: self.conn = self.get_db_lib().connect(**config) break except self.get_db_lib().Error, e: debug.warning(str(e)) if (e[0] == 1045 or self.get_db_lib().OperationalError and self.password is None): passwd_dlg = QPasswordEntry() if passwd_dlg.exec_(): self.password = passwd_dlg.get_password() else: retry = False else: raise ModuleError(self, str(e))
def download(self, url): """download(url:string) -> (result: int, downloaded_file: File, local_filename:string) Tries to download a file from url. It returns a tuple with: result: 0 -> success 1 -> couldn't download the file, but found a cached version 2 -> failed (in this case downloaded_file will contain the error message) downloaded_file: The downloaded file or the error message in case it failed local_filename: the path to the local_filename """ self._parse_url(url) opener = urllib2.build_opener() local_filename = self._local_filename(url) request = urllib2.Request(url) try: f1 = opener.open(url) except urllib2.URLError, e: if self._file_is_in_local_cache(local_filename): debug.warning(('A network error occurred. HTTPFile will use' ' cached version of file')) result = core.modules.basic_modules.File() result.name = local_filename return (1, result, local_filename) else: return (2, (str(e)), local_filename)
def linux_ubuntu_install(package_name): qt = has_qt() hide_splash_if_necessary() if qt: cmd = core.system.vistrails_root_directory() cmd += '/gui/bundles/linux_ubuntu_install.py' else: cmd = 'apt-get install -y' if type(package_name) == str: cmd += ' ' + package_name elif type(package_name) == list: for package in package_name: if type(package) != str: raise TypeError("Expected string or list of strings") cmd += ' ' + package if qt: sucmd = guess_graphical_sudo() + " '" + cmd + "'" else: debug.warning("VisTrails wants to install package(s) '%s'" % package_name) sucmd = "sudo " + cmd result = os.system(sucmd) return (result == 0) # 0 indicates success
def download(self, url): """download(url:string) -> (result: int, downloaded_file: File, local_filename:string) Tries to download a file from url. It returns a tuple with: result: 0 -> success 1 -> couldn't download the file, but found a cached version 2 -> failed (in this case downloaded_file will contain the error message) downloaded_file: The downloaded file or the error message in case it failed local_filename: the path to the local_filename """ self._parse_url(url) opener = urllib2.build_opener() local_filename = self._local_filename(url) request = urllib2.Request(url) try: f1 = opener.open(url) except urllib2.URLError, e: if self._file_is_in_local_cache(local_filename): debug.warning(("A network error occurred. HTTPFile will use" " cached version of file")) result = core.modules.basic_modules.File() result.name = local_filename return (1, result, local_filename) else: return (2, (str(e)), local_filename)
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 = VistrailController.update_parameter(controller, 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.warning("CDAT Package: Change parameter %s in widget %s was not generated"%(k, self.name)) else: debug.warning( "CDAT Package: Alias %s does not exist in pipeline" % (k) ) if len(param_changes) > 0: action = core.db.action.create_action(param_changes) vistrail.add_action(action, parent_version, controller.current_session) controller.set_changed(True) controller.recompute_terse_graph() controller.invalidate_version_tree() newid = action.id return newid
def package_requirements(): import core.requirements if not core.requirements.python_module_exists('vtk'): raise core.requirements.MissingRequirement('vtk') if not core.requirements.python_module_exists('PyQt4'): from core import debug debug.warning('PyQt4 is not available. There will be no interaction ' 'between VTK and the spreadsheet.')
def package_requirements(): import core.requirements if not core.requirements.python_module_exists('vtk'): raise core.requirements.MissingRequirement('vtk') if not core.requirements.python_module_exists('PyQt4'): from core import debug debug.warning('PyQt4 is not available. There will be no interaction ' 'between VTK and the spreadsheet.') import vtk
def _delete_files(dirname): """delete_files(dirname: str) -> None Deletes all files inside dirname """ try: for root, dirs, files in os.walk(dirname): for fname in files: os.unlink(os.path.join(root, fname)) except OSError, e: debug.warning("Error when removing thumbnails: %s" % str(e))
def _delete_files(dirname): """delete_files(dirname: str) -> None Deletes all files inside dirname """ try: for root, dirs, files in os.walk(dirname): for fname in files: os.unlink(os.path.join(root,fname)) except OSError, e: debug.warning("Error when removing thumbnails: %s"%str(e))
def package_requirements(): import core.requirements if not core.requirements.python_module_exists('visit'): raise core.requirements.MissingRequirement('visit') if not core.requirements.python_module_exists('visit.pyqt_gui'): raise core.requirements.MissingRequirement('visit.pyqt_gui') # Figure out how to check on pvvariable if not core.requirements.python_module_exists('PyQt4'): from core import debug debug.warning('PyQt4 is not available. There will be no interaction ' 'between VisIt and the spreadsheet.') import visit.pyqt_gui import visit
def _is_outdated(self, remoteHeader, localFile): """Checks whether local file is outdated.""" local_time = datetime.datetime.utcfromtimestamp(os.path.getmtime(localFile)) try: remote_time = datetime.datetime.strptime(remoteHeader, "%a, %d %b %Y %H:%M:%S %Z") except ValueError: try: remote_time = datetime.datetime.strptime(remoteHeader, "%a, %d %B %Y %H:%M:%S %Z") except ValueError: # unable to parse last-modified header, download file again debug.warning("Unable to parse Last-Modified header" ", downloading file") return True return remote_time > local_time
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 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 get_latest_vistrails_version(): """get_latest_vistrails_version() -> string - Returns latest vistrails release version as queried from vistrails.org""" version = '' version_url = \ "http://www.vistrails.org/download/download.php?id=release_version.txt" try: request = urllib2.Request(version_url) get_latest_version = urllib2.urlopen(request) version = get_latest_version.read().strip() except urllib2.HTTPError, err: debug.warning("Unable to check for updates: %s" % str(err)) return version
def data_sync(self): """ downloads/uploads/uses the local file depending on availability """ self.checksum_lookup() # local file not on repository, so upload if not self.on_server and os.path.isfile(self.in_file.name): cookiejar = gui.repository.QRepositoryDialog.cookiejar if cookiejar: register_openers(cookiejar=cookiejar) params = { 'dataset_file': open(self.in_file.name, 'rb'), 'name': self.in_file.name.split('/')[-1], 'origin': 'vistrails', 'checksum': self.checksum } upload_url = "%s/datasets/upload/" % self.base_url datagen, headers = multipart_encode(params) request = urllib2.Request(upload_url, datagen, headers) try: result = urllib2.urlopen(request) if result.code != 200: show_warning("Upload Failure", "Data failed to upload to repository") # make temporarily uncachable self.is_cacheable = self.invalidate_cache else: debug.warning("Push to repository was successful") # make sure module caches self.is_cacheable = self.validate_cache except Exception, e: show_warning("Upload Failure", "Data failed to upload to repository") # make temporarily uncachable self.is_cacheable = self.invalidate_cache debug.warning('RepoSync uploaded %s to the repository' % \ self.in_file.name) else: show_warning("Please login", ("You must be logged into the web" " repository in order to upload " "data. No data was synced")) # make temporarily uncachable self.is_cacheable = self.invalidate_cache # use local data self.setResult("file", self.in_file)
def move_cache_directory(self, sourcedir, destdir): """change_cache_directory(sourcedir: str, dest_dir: str) -> None" Moves files from sourcedir to destdir """ if os.path.exists(destdir): for entry in self.elements.itervalues(): try: srcname = entry.abs_name dstname = os.path.join(destdir,entry.name) shutil.move(srcname,dstname) entry.abs_name = dstname except shutil.Error, e: debug.warning("Could not move thumbnail from %s to %s: %s" \ % (sourcedir, destdir, str(e)))
def move_cache_directory(self, sourcedir, destdir): """change_cache_directory(sourcedir: str, dest_dir: str) -> None" Moves files from sourcedir to destdir """ if os.path.exists(destdir): for entry in self.elements.itervalues(): try: srcname = entry.abs_name dstname = os.path.join(destdir, entry.name) shutil.move(srcname, dstname) entry.abs_name = dstname except shutil.Error, e: debug.warning("Could not move thumbnail from %s to %s: %s" \ % (sourcedir, destdir, str(e)))
def load_persistent_configuration(self): (dom, element) = ( None, None ) for iAttempt in range(10): try: (dom, element) = self.find_own_dom_element() break except: time.sleep( 0.5 ) if element <> None: configuration = enter_named_element(element, 'configuration') if configuration and self.configuration: if self.configuration: self.configuration.set_from_dom_node(configuration) else: debug.warning("Error, missing configuration in package") if dom <> None: dom.unlink() else: debug.warning("Error reading dom for package")
def data_sync(self): """ downloads/uploads/uses the local file depending on availability """ self.checksum_lookup() # local file not on repository, so upload if not self.on_server and os.path.isfile(self.in_file.name): cookiejar = gui.repository.QRepositoryDialog.cookiejar if cookiejar: register_openers(cookiejar=cookiejar) params = { "dataset_file": open(self.in_file.name, "rb"), "name": self.in_file.name.split("/")[-1], "origin": "vistrails", "checksum": self.checksum, } upload_url = "%s/datasets/upload/" % self.base_url datagen, headers = multipart_encode(params) request = urllib2.Request(upload_url, datagen, headers) try: result = urllib2.urlopen(request) if result.code != 200: show_warning("Upload Failure", "Data failed to upload to repository") # make temporarily uncachable self.is_cacheable = self.invalidate_cache else: debug.warning("Push to repository was successful") # make sure module caches self.is_cacheable = self.validate_cache except Exception, e: show_warning("Upload Failure", "Data failed to upload to repository") # make temporarily uncachable self.is_cacheable = self.invalidate_cache debug.warning("RepoSync uploaded %s to the repository" % self.in_file.name) else: show_warning( "Please login", ("You must be logged into the web" " repository in order to upload " "data. No data was synced"), ) # make temporarily uncachable self.is_cacheable = self.invalidate_cache # use local data self.setResult("file", self.in_file)
def _is_outdated(self, remoteHeader, localFile): """Checks whether local file is outdated.""" local_time = \ datetime.datetime.utcfromtimestamp(os.path.getmtime(localFile)) try: remote_time = datetime.datetime.strptime( remoteHeader, "%a, %d %b %Y %H:%M:%S %Z") except ValueError: try: remote_time = datetime.datetime.strptime( remoteHeader, "%a, %d %B %Y %H:%M:%S %Z") except ValueError: # unable to parse last-modified header, download file again debug.warning("Unable to parse Last-Modified header" ", downloading file") return True return remote_time > local_time
def create_user_packages_dir(userpackagesname=None): debug.warning('Will try to create userpackages directory') if userpackagesname is None: userpackagesname = os.path.join( self.temp_configuration.dotVistrails, 'userpackages') if not os.path.isdir(userpackagesname): try: os.mkdir(userpackagesname) self.configuration.userPackageDirectory = userpackagesname self.temp_configuration.userPackageDirectory = \ userpackagesname except: msg = ("""Failed to create userpackages directory: '%s'. This could be an indication of a permissions problem. Make sure directory '%s' in writable.""" % (userpackagesname, self.configuration.dotVistrails)) debug.critical(msg) sys.exit(1) create_user_packages_init(userpackagesname)
def guess_graphical_sudo(): """Tries to guess what to call to run a shell with elevated privileges.""" if core.system.executable_is_in_path("kdesu"): return "kdesu -c" elif core.system.executable_is_in_path("gksu"): return "gksu" elif core.system.executable_is_in_path("sudo") and core.system.executable_is_in_path("zenity"): # This is a reasonably convoluted hack to only prompt for the password # if user has not recently entered it return ( '((echo "" | sudo -v -S -p "") || ' + '(zenity --entry --title "sudo password prompt" --text "Please enter your password ' 'to give the system install authorization." --hide-text="" | sudo -v -S -p "")); sudo -S -p ""' ) else: debug.warning("Could not find a graphical su-like command.") debug.warning("Will use regular su") return "su -c"
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 = VistrailController.update_parameter( controller, 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.warning( "CDAT Package: Change parameter %s in widget %s was not generated" % (k, self.name)) else: debug.warning( "CDAT Package: Alias %s does not exist in pipeline" % (k)) if len(param_changes) > 0: action = core.db.action.create_action(param_changes) vistrail.add_action(action, parent_version, controller.current_session) controller.set_changed(True) controller.recompute_terse_graph() controller.invalidate_version_tree() newid = action.id return newid
def create_startup_package_node(self): (dom, element) = self.find_own_dom_element() doc = dom.documentElement disabledpackages = enter_named_element(doc, 'disabledpackages') packages = enter_named_element(doc, 'packages') oldpackage = self.find_disabledpackage_element(doc) if oldpackage is not None: # Must remove element from oldpackages, # _and_ the element that was just created in find_own_dom_element() disabledpackages.removeChild(oldpackage) packages.removeChild(element) packages.appendChild(oldpackage) configuration = enter_named_element(oldpackage, 'configuration') if configuration: if self.configuration: self.configuration.set_from_dom_node(configuration) else: debug.warning("Error, missing configuration in package") get_vistrails_application().vistrailsStartup.write_startup_dom(dom) dom.unlink()
def create_user_packages_dir(userpackagesname=None): debug.warning('Will try to create userpackages directory') if userpackagesname is None: userpackagesname = os.path.join(self.temp_configuration.dotVistrails, 'userpackages') if not os.path.isdir(userpackagesname): try: os.mkdir(userpackagesname) self.configuration.userPackageDirectory = userpackagesname self.temp_configuration.userPackageDirectory = \ userpackagesname except: msg = ("""Failed to create userpackages directory: '%s'. This could be an indication of a permissions problem. Make sure directory '%s' in writable.""" % (userpackagesname, self.configuration.dotVistrails)) debug.critical(msg) sys.exit(1) create_user_packages_init(userpackagesname)
def guess_graphical_sudo(): """Tries to guess what to call to run a shell with elevated privileges.""" if core.system.executable_is_in_path('kdesu'): return 'kdesu -c' elif core.system.executable_is_in_path('gksu'): return 'gksu' elif (core.system.executable_is_in_path('sudo') and core.system.executable_is_in_path('zenity')): # This is a reasonably convoluted hack to only prompt for the password # if user has not recently entered it return ( '((echo "" | sudo -v -S -p "") || ' + '(zenity --entry --title "sudo password prompt" --text "Please enter your password ' 'to give the system install authorization." --hide-text="" | sudo -v -S -p "")); sudo -S -p ""' ) else: debug.warning("Could not find a graphical su-like command.") debug.warning("Will use regular su") return 'su -c'
def initialize(*args, **keywords): # import core.packagemanager global webServicesDict global package_cache #Create a directory for the SUDSWebServices package location = os.path.join(core.system.default_dot_vistrails(), "SUDSWebServices") if not os.path.isdir(location): try: debug.log("Creating SUDS cache directory...") os.mkdir(location) except: debug.critical( """Could not create SUDS cache directory. Make sure '%s' does not exist and parent directory is writable""" % location) sys.exit(1) # the number of days to cache wsdl files days = 1 if configuration.check("cache_days"): days = configuration.cache_days suds.client.ObjectCache.protocol = 0 # windows needs this package_cache = suds.client.ObjectCache(location, days=days) #reg = core.modules.module_registry.get_module_registry() #reg.add_module(SUDSWebService, abstract=True) wsdlList = [] if configuration.check('wsdlList'): wsdlList = configuration.wsdlList.split(";") else: configuration.wsdlList = '' for wsdl in wsdlList: if not wsdl.startswith('http://'): wsdl = 'http://' + wsdl if wsdl in webServicesDict: debug.warning('Duplicate WSDL entry: '+wsdl) continue s = Service(wsdl) if s.service: webServicesDict[wsdl] = s
def linux_fedora_install(package_name): qt = has_qt() hide_splash_if_necessary() if qt: cmd = core.system.vistrails_root_directory() cmd += '/gui/bundles/linux_fedora_install.py' else: cmd = 'yum -y install' if type(package_name) == str: cmd += ' ' + package_name elif type(package_name) == list: for package in package_name: if type(package) != str: raise TypeError("Expected string or list of strings") cmd += ' ' + package if qt: sucmd = guess_graphical_sudo() + " " + cmd else: debug.warning(("VisTrails wants to install package(s) '%s' through " "_sudo_. Make sure you are a sudoer.") % package_name) sucmd = "sudo " + cmd debug.warning("EXECUTING: sucmd") result = os.system(sucmd) debug.warning("RETURN VALUE: %s" % result) return (result == 0)
def initialize(*args, **keywords): # import core.packagemanager global webServicesDict global package_cache #Create a directory for the SUDSWebServices package location = os.path.join(core.system.default_dot_vistrails(), "SUDSWebServices") if not os.path.isdir(location): try: debug.log("Creating SUDS cache directory...") os.mkdir(location) except: debug.critical("""Could not create SUDS cache directory. Make sure '%s' does not exist and parent directory is writable""" % location) sys.exit(1) # the number of days to cache wsdl files days = 1 if configuration.check("cache_days"): days = configuration.cache_days suds.client.ObjectCache.protocol = 0 # windows needs this package_cache = suds.client.ObjectCache(location, days=days) #reg = core.modules.module_registry.get_module_registry() #reg.add_module(SUDSWebService, abstract=True) wsdlList = [] if configuration.check('wsdlList'): wsdlList = configuration.wsdlList.split(";") else: configuration.wsdlList = '' for wsdl in wsdlList: if not wsdl.startswith('http://'): wsdl = 'http://' + wsdl if wsdl in webServicesDict: debug.warning('Duplicate WSDL entry: ' + wsdl) continue s = Service(wsdl) if s.service: webServicesDict[wsdl] = s
def update_from_console(self): config = self.find_connection_info(self._host, self._port, self._db) if config is None: # the problem here is if VisTrails is being run through command # line from LaTex, stdout is being redirected to a log file, so # the user does not see the prompt in raw_input. getpass uses the # controlling terminal so it works fine. Just to make sure he sees # the first message prompt we will the controlling terminal try: f = open('/dev/tty', 'w') f.write("\nConnect to db with username [%s]: " % self._user) f.close() user = raw_input() except: debug.warning("Couldn't write to terminal. Will try stdout") user = raw_input("Connecting to db with username[%s]: " % self._user) try: if user != '': self._user = user passwd = getpass.getpass("password:") self._passwd = passwd config = { 'host': self._host, 'port': int(self._port), 'user': self._user, 'passwd': self._passwd, 'db': self._db } test_db_connection(config) config['succeeded'] = True config['name'] = '%s@%s' % (self._user, self._host) config['id'] = -1 except VistrailsDBException, e: debug.critical('VisTrails DB Exception', str(e)) config['succeeded'] = False except Exception, e2: debug.critical('VisTrails Exception', str(e2)) config['succeeded'] = False
class FileSink(NotCacheable, Module): """FileSink takes a file and writes it to a user-specified location in the file system. The file is stored at location specified by the outputPath. The overwrite flag allows users to specify whether an existing path should be overwritten.""" def compute(self): input_file = self.getInputFromPort("file") output_path = self.getInputFromPort("outputPath") full_path = output_path.name try: core.system.link_or_copy(input_file.name, full_path) except OSError, e: if self.hasInputFromPort("overwrite") and \ self.getInputFromPort("overwrite"): try: os.unlink(full_path) core.system.link_or_copy(input_file.name, full_path) except OSError: msg = "(override true) Could not create file '%s'" % \ full_path raise ModuleError(self, msg) else: msg = "Could not create file '%s': %s" % (full_path, e) raise ModuleError(self, msg) if (self.hasInputFromPort("publishFile") and self.getInputFromPort("publishFile") or not self.hasInputFromPort("publishFile")): if self.moduleInfo.has_key('extra_info'): if self.moduleInfo['extra_info'].has_key('pathDumpCells'): folder = self.moduleInfo['extra_info']['pathDumpCells'] base_fname = os.path.basename(full_path) (base_fname, file_extension) = os.path.splitext(base_fname) base_fname = os.path.join(folder, base_fname) # make a unique filename filename = base_fname + file_extension counter = 2 while os.path.exists(filename): filename = base_fname + "_%d%s" % (counter, file_extension) counter += 1 try: core.system.link_or_copy(input_file.name, filename) except OSError: msg = "Could not publish file '%s' \n on '%s': %s" % \ (full_path, filename, e) # I am not sure whether we should raise an error # I will just print a warning for now (Emanuele) debug.warning("%s" % msg)
def update_from_console(self): config = self.find_connection_info(self._host, self._port, self._db) if config is None: # the problem here is if VisTrails is being run through command # line from LaTex, stdout is being redirected to a log file, so # the user does not see the prompt in raw_input. getpass uses the # controlling terminal so it works fine. Just to make sure he sees # the first message prompt we will the controlling terminal try: f= open('/dev/tty', 'w') f.write("\nConnect to db with username [%s]: "%self._user) f.close() user = raw_input() except: debug.warning("Couldn't write to terminal. Will try stdout") user = raw_input("Connecting to db with username[%s]: "%self._user) try: if user != '': self._user = user passwd = getpass.getpass("password:") self._passwd = passwd config = {'host': self._host, 'port': int(self._port), 'user': self._user, 'passwd': self._passwd, 'db': self._db } test_db_connection(config) config['succeeded'] = True config['name'] = '%s@%s'%(self._user,self._host) config['id'] = -1 except VistrailsDBException, e: debug.critical('VisTrails DB Exception', str(e)) config['succeeded'] = False except Exception, e2: debug.critical('VisTrails Exception', str(e2)) config['succeeded'] = False
def __init__(self, category=None, detail=None): """detail can range from -2 to +1, with larger numbers returning more information. Beware of +1, it can take several minutes for system_profiler to generate the data.""" command = ['system_profiler', '-xml'] if category is not None: command.append(str(category)) if detail is not None: command.extend(['-detailLevel', '%d' % detail]) p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() stderr = stderr.strip() if stderr: lines = stderr.splitlines() if len(lines) > 1 or len(lines[0]) > 44: line = "%s..." % lines[0][:41] else: line = lines[0] debug.warning("Error output from system_profiler: %s" % line, stderr) self.document = ElementTree.XML(stdout)
def create_module(value, signature): """ Creates a module for value, in order to do the type checking. """ if type(value)==bool: v_module = Boolean() return v_module elif type(value)==str: v_module = String() return v_module elif type(value)==int: if type(signature)==list: signature = signature[0] if signature[0]==Float().__class__: v_module = Float() else: v_module = Integer() return v_module elif type(value)==float: v_module = Float() return v_module elif type(value)==list: v_module = List() return v_module elif type(value)==file: v_module = File() return v_module elif type(value)==tuple: v_modules = () for element in xrange(len(value)): v_modules += (create_module(value[element], signature[element]),) return v_modules else: debug.warning("Could not identify the type of the list element.") debug.warning("Type checking is not going to be done inside Fold module.") return None
def run_and_get_results(w_list, parameters='', workflow_info=None, update_vistrail=True, extra_info=None, reason='Console Mode Execution'): """run_and_get_results(w_list: list of (locator, version), parameters: str, workflow_info:str, update_vistrail: boolean, extra_info:dict) Run all workflows in w_list, and returns an interpreter result object. version can be a tag name or a version id. """ elements = parameters.split("$&$") aliases = {} result = [] for locator, workflow in w_list: (v, abstractions, thumbnails, mashups) = load_vistrail(locator) controller = VistrailController(auto_save=update_vistrail) controller.set_vistrail(v, locator, abstractions, thumbnails, mashups) if type(workflow) == type("str"): version = v.get_version_number(workflow) elif type(workflow) in [type(1), long]: version = workflow elif workflow is None: version = controller.get_latest_version_in_graph() else: msg = "Invalid version tag or number: %s" % workflow raise VistrailsInternalError(msg) controller.change_selected_version(version) for e in elements: pos = e.find("=") if pos != -1: key = e[:pos].strip() value = e[pos + 1:].strip() if controller.current_pipeline.has_alias(key): aliases[key] = value if workflow_info is not None and controller.current_pipeline is not None: if is_running_gui(): from gui.pipeline_view import QPipelineView pipeline_view = QPipelineView() pipeline_view.scene().setupScene(controller.current_pipeline) base_fname = "%s_%s_pipeline.pdf" % (locator.short_name, version) filename = os.path.join(workflow_info, base_fname) pipeline_view.scene().saveToPDF(filename) del pipeline_view else: debug.critical("Cannot save pipeline figure when not " "running in gui mode") base_fname = "%s_%s_pipeline.xml" % (locator.short_name, version) filename = os.path.join(workflow_info, base_fname) core.db.io.save_workflow(controller.current_pipeline, filename) if not update_vistrail: conf = get_vistrails_configuration() if conf.has('thumbs'): conf.thumbs.autoSave = False (results, _) = \ controller.execute_current_workflow(custom_aliases=aliases, extra_info=extra_info, reason=reason) new_version = controller.current_version if new_version != version: debug.warning("Version '%s' (%s) was upgraded. The actual " "version executed was %s" % \ (workflow, version, new_version)) run = results[0] run.workflow_info = (locator.name, new_version) run.pipeline = controller.current_pipeline if update_vistrail: controller.write_vistrail(locator) result.append(run) return result
## - Redistributions in binary form must reproduce the above copyright ## notice, this list of conditions and the following disclaimer in the ## documentation and/or other materials provided with the distribution. ## - Neither the name of the University of Utah nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ## ############################################################################### # *** MOVED *** to gui.modules.query_configuration import traceback from core import debug debug.warning("The use of core.modules.query_configuration is deprecated. " "Please use gui.modules.query_configuration.", ''.join(traceback.format_stack())) from gui.modules.query_configuration import *
## notice, this list of conditions and the following disclaimer in the ## documentation and/or other materials provided with the distribution. ## - Neither the name of the University of Utah nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ## ############################################################################### # *** MOVED *** to gui.modules.port_configure import traceback from core import debug debug.warning( "The use of core.modules.port_configure is deprecated. " "Please use gui.modules.port_configure.", ''.join(traceback.format_stack())) from gui.modules.port_configure import *
# the reference in the package list package.remove_own_dom_element() failed.append(package) else: if package.identifier not in self._package_versions: self._package_versions[package.identifier] = {} self._dependency_graph.add_vertex(package.identifier) elif package.version in \ self._package_versions[package.identifier]: raise VistrailsInternalError("Duplicate package version: " "'%s' (version %s) in %s" % \ (package.identifier, package.version, package_codepath)) 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("Will disable package %s" % package.name) debug.critical(str(e)) # print "DEPENDENCIES FAILED TO LOAD, let's disable this"
def _vanilla_import(module_name): return __import__(module_name, globals(), locals(), []) def unknown_py_import(module_name, package_name): return _vanilla_import(module_name) def py_import(module_name, dependency_dictionary): """Tries to import a python module. If unsuccessful, tries to install the appropriate bundle and then reimport. py_import tries to be smart about which system it runs on.""" try: result = _vanilla_import(module_name) return result except ImportError, e: pass debug.warning("Import failed. Will try to install bundle.") success = core.bundles.installbundle.install(dependency_dictionary) if not success: debug.critical("Package installation failed.") debug.critical("Package might not be available in the provided repositories.") raise e try: result = _vanilla_import(module_name) return result except ImportError, e: debug.critical("Package installation successful, but import still failed.") debug.critical("This means py_import was called with bad arguments.") debug.critical("Please report this bug to the package developer.")
## documentation and/or other materials provided with the distribution. ## - Neither the name of the University of Utah nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ## ############################################################################### # *** MOVED *** to gui.modules.query_configuration import traceback from core import debug debug.warning( "The use of core.modules.query_configuration is deprecated. " "Please use gui.modules.query_configuration.", "".join(traceback.format_stack()), ) from gui.modules.query_configuration import *
def load(self, loadworkflow=True): config = ConfigParser.ConfigParser() if config.read(self.config_file): if config.has_section('global'): if config.has_option('global', 'cellnum'): self.cellnum = config.getint('global', 'cellnum') if config.has_option('global', 'filenum'): self.filenum = config.getint('global', 'filenum') if config.has_option('global', 'varnum'): self.varnum = config.getint('global', 'varnum') print " ------ Loaded plot %s, varnum = %d ------ " % ( self.name, self.varnum ) if config.has_option('global', 'workflow_tag'): self.workflow_tag = config.get('global', 'workflow_tag') # else: # debug.warning("CDAT Package: file %s does not contain a required option 'workflow_tag'. Widget will not be loaded."%self.config_file) # self.loaded = False # return if config.has_option('global', 'filetypes'): types = config.get('global', 'filetypes') tlist = [t.strip() for t in types.split(";")] for t in tlist: kv = t.split(":") self.filetypes[kv[0].strip()] = [v.strip() for v in kv[1].split(",")] if config.has_option('global', 'qt_filter'): self.qt_filter = config.get('global', 'qt_filter') if config.has_option('global', 'dependencies'): deps = config.get('global', 'dependencies') self.dependencies = [d.strip() for d in deps.split(",")] if config.has_option('global', 'serialized_config_alias'): self.serializedConfigAlias = config.get('global', 'serialized_config_alias') for y in range(self.filenum): self.files.append( 'Filename' + str(y+1) ) for v in range(self.varnum): self.vars.append( 'VariableName' + str(v+1) ) self.axes.append( 'Axes' + str(v+1) ) for x in range(self.cellnum): section_name = 'cell' + str(x+1) if config.has_section(section_name): cellType = config.get(section_name, 'celltype') if config.has_option(section_name, 'address_alias'): self.cells.append( Cell( cellType, None, None, config.get(section_name, 'address_alias') ) ) else: self.cells.append(Cell( cellType,"Row"+str(x+1), "Column"+str(x+1) ) ) else: for y in range(self.filenum): option_name = 'filename_alias' + str(y+1) if config.has_option('global', option_name): self.files.append(config.get('global', option_name)) for v in range(self.varnum): option_name = 'varname_alias' + str(v+1) if config.has_option('global', option_name): self.vars.append(config.get('global', option_name)) axes_name = 'axes_alias' + str(v+1) if config.has_option('global', axes_name): self.axes.append(config.get('global', axes_name)) for x in range(self.cellnum): section_name = 'cell' + str(x+1) if (config.has_section(section_name) and config.has_option(section_name, 'celltype') and config.has_option(section_name, 'row_alias') and config.has_option(section_name, 'col_alias')): self.cells.append(Cell(config.get(section_name, 'celltype'), config.get(section_name, 'row_alias'), config.get(section_name, 'col_alias'))) if loadworkflow: #load workflow in vistrail #only if dependencies are enabled manager = get_package_manager() self.unsatisfied_deps = [] for dep in self.dependencies: if not manager.has_package(dep): self.unsatisfied_deps.append(dep) if len(self.unsatisfied_deps) == 0: try: (self.plot_vistrail, abstractions , thumbnails, mashups) = load_vistrail(self.locator) controller = VistrailController() controller.set_vistrail(self.plot_vistrail, self.locator, abstractions, thumbnails, mashups) self.workflow_version = self.plot_vistrail.get_version_number(self.workflow_tag) if self.workflow_tag else controller.get_latest_version_in_graph() print " Loaded %s version: %s" % ( self.name, str( self.workflow_version ) ) controller.change_selected_version(self.workflow_version) self.workflow = controller.current_pipeline self.loaded = True except Exception, err: debug.warning( "Error loading workflow %s: %s" % ( self.name, err ) ) self.loaded = False else: debug.warning("UV-CDAT: %s widget could not be loaded \ because it depends on packages that are not loaded:"%self.name) debug.warning(" %s"%", ".join(self.unsatisfied_deps)) self.loaded = False else: debug.warning("UV-CDAT: file %s does not contain a 'global'\ section. Widget will not be loaded."%self.config_file) self.loaded = False
## - Redistributions in binary form must reproduce the above copyright ## notice, this list of conditions and the following disclaimer in the ## documentation and/or other materials provided with the distribution. ## - Neither the name of the University of Utah nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ## ############################################################################### # *** MOVED *** to gui.modules.tuple_configuration import traceback from core import debug debug.warning("The use of core.modules.tuple_configuration is deprecated. " "Please use gui.modules.tuple_configuration.", ''.join(traceback.format_stack())) from gui.modules.tuple_configuration import *
# file on repository mirrors local file, so use local file if self.up_to_date and os.path.isfile(self.in_file.name): self.setResult("file", self.in_file) else: # local file not present or out of date, download or used cached self.url = "%s/datasets/download/%s" % (self.base_url, self.checksum) local_filename = package_directory + "/" + urllib.quote_plus(self.url) if not self._file_is_in_local_cache(local_filename): # file not in cache, download. try: urllib.urlretrieve(self.url, local_filename) except IOError, e: raise ModuleError(self, ("Invalid URL: %s" % e)) out_file = core.modules.basic_modules.File() out_file.name = local_filename debug.warning("RepoSync is using repository data") self.setResult("file", out_file) def compute(self): # if server, grab local file using checksum id if self.is_server: self.checkInputPort("checksum") self.checksum = self.getInputFromPort("checksum") # get file path path_url = "%s/datasets/path/%s/" % (self.base_url, self.checksum) try: dataset_path_request = urllib2.urlopen(url=path_url) dataset_path = dataset_path_request.read() except urllib2.HTTPError: pass
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.critical('%s not found' % startup) debug.critical('Will try to install default ' 'startup file') 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)
def convertWarning(self, before, after, _from, to): text = ["Value truncated when saving to database", "%s truncated to %s\nwhile converting '%s' to '%s'"] debug.warning(text[0], text[1] % (before, after, _from, to))
def unknown_py_import(module_name, package_name): return _vanilla_import(module_name) def py_import(module_name, dependency_dictionary): """Tries to import a python module. If unsuccessful, tries to install the appropriate bundle and then reimport. py_import tries to be smart about which system it runs on.""" try: result = _vanilla_import(module_name) return result except ImportError, e: pass debug.warning("Import of python module '%s' failed. " "Will try to install bundle." % module_name) success = core.bundles.installbundle.install(dependency_dictionary) if not success: raise PyImportException(module_name, traceback.format_exc()) try: result = _vanilla_import(module_name) return result except ImportError, e: raise PyImportBug(module_name, traceback.format_exc()) ##############################################################################
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.critical('%s not found' % startup) debug.critical('Will try to install default ' 'startup file') 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)
# the reference in the package list package.remove_own_dom_element() failed.append(package) else: if package.identifier not in self._package_versions: self._package_versions[package.identifier] = {} self._dependency_graph.add_vertex(package.identifier) elif package.version in \ self._package_versions[package.identifier]: raise VistrailsInternalError("Duplicate package version: " "'%s' (version %s) in %s" % \ (package.identifier, package.version, package.codepath)) 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: if report_missing_dependencies: debug.critical( "Dependencies of package %s are missing "
def run_and_get_results(w_list, parameters='', workflow_info=None, update_vistrail=True, extra_info=None, reason='Console Mode Execution'): """run_and_get_results(w_list: list of (locator, version), parameters: str, workflow_info:str, update_vistrail: boolean, extra_info:dict) Run all workflows in w_list, and returns an interpreter result object. version can be a tag name or a version id. """ elements = parameters.split("$&$") aliases = {} result = [] for locator, workflow in w_list: (v, abstractions , thumbnails, mashups) = load_vistrail(locator) controller = VistrailController(auto_save=update_vistrail) controller.set_vistrail(v, locator, abstractions, thumbnails, mashups) if type(workflow) == type("str"): version = v.get_version_number(workflow) elif type(workflow) in [ type(1), long]: version = workflow elif workflow is None: version = controller.get_latest_version_in_graph() else: msg = "Invalid version tag or number: %s" % workflow raise VistrailsInternalError(msg) controller.change_selected_version(version) for e in elements: pos = e.find("=") if pos != -1: key = e[:pos].strip() value = e[pos+1:].strip() if controller.current_pipeline.has_alias(key): aliases[key] = value if workflow_info is not None and controller.current_pipeline is not None: if is_running_gui(): from gui.pipeline_view import QPipelineView pipeline_view = QPipelineView() pipeline_view.scene().setupScene(controller.current_pipeline) base_fname = "%s_%s_pipeline.pdf" % (locator.short_name, version) filename = os.path.join(workflow_info, base_fname) pipeline_view.scene().saveToPDF(filename) del pipeline_view else: debug.critical("Cannot save pipeline figure when not " "running in gui mode") base_fname = "%s_%s_pipeline.xml" % (locator.short_name, version) filename = os.path.join(workflow_info, base_fname) core.db.io.save_workflow(controller.current_pipeline, filename) if not update_vistrail: conf = get_vistrails_configuration() if conf.has('thumbs'): conf.thumbs.autoSave = False (results, _) = \ controller.execute_current_workflow(custom_aliases=aliases, extra_info=extra_info, reason=reason) new_version = controller.current_version if new_version != version: debug.warning("Version '%s' (%s) was upgraded. The actual " "version executed was %s" % \ (workflow, version, new_version)) run = results[0] run.workflow_info = (locator.name, new_version) run.pipeline = controller.current_pipeline if update_vistrail: controller.write_vistrail(locator) result.append(run) return result
## - Redistributions in binary form must reproduce the above copyright ## notice, this list of conditions and the following disclaimer in the ## documentation and/or other materials provided with the distribution. ## - Neither the name of the University of Utah nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ## ############################################################################### # *** MOVED *** to gui.modules.paramexplore import traceback from core import debug debug.warning("The use of core.modules.paramexplore is deprecated. " "Please use gui.modules.paramexplore.", ''.join(traceback.format_stack())) from gui.modules.paramexplore import *
## - Redistributions in binary form must reproduce the above copyright ## notice, this list of conditions and the following disclaimer in the ## documentation and/or other materials provided with the distribution. ## - Neither the name of the University of Utah nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ## ############################################################################### # *** MOVED *** to gui.modules.source_configure import traceback from core import debug debug.warning("The use of core.modules.source_configure is deprecated. " "Please use gui.modules.source_configure.", ''.join(traceback.format_stack())) from gui.modules.source_configure import *