def import_user_packages_module(self): """Imports the 'userspackages' package. This will need to manipulate the Python path to find it. """ if self._userpackages is not None: return self._userpackages # Imports user packages directory old_sys_path = copy.copy(sys.path) userPackageDir = system.get_vistrails_directory('userPackageDir') if userPackageDir is not None: sys.path.insert(0, os.path.join(userPackageDir, os.path.pardir)) try: import userpackages except ImportError: debug.critical('ImportError: "userpackages" sys.path: %s' % sys.path) raise finally: sys.path = old_sys_path os.environ['VISTRAILS_USERPACKAGES_DIR'] = userPackageDir self._userpackages = userpackages return userpackages # possible that we don't have userPackageDir set! return None
def __init__(self): upd = system.get_vistrails_directory('userPackageDir') if upd is not None: self._upd = upd else: conf = vistrails.core.configuration.get_vistrails_configuration() self._upd = os.path.join(conf.get('dotVistrails'), '.userpackages')
def import_user_packages_module(self): """Imports the packages module using path trickery to find it in the right place. """ if self._userpackages is not None: return self._userpackages # Imports user packages directory conf = self._startup.temp_configuration old_sys_path = copy.copy(sys.path) userPackageDir = system.get_vistrails_directory('userPackageDir') if userPackageDir is not None: sys.path.insert(0, os.path.join(userPackageDir, os.path.pardir)) try: import userpackages except ImportError: debug.critical('ImportError: "userpackages" sys.path: %s' % sys.path) raise finally: sys.path = old_sys_path os.environ['VISTRAILS_USERPACKAGES_DIR'] = userPackageDir self._userpackages = userpackages return userpackages # possible that we don't have userPackageDir set! return None
def clear_clicked(self, checked=False): thumbnail_dir = system.get_vistrails_directory("thumbs.cacheDir") res = show_question('VisTrails', ("All files in %s will be removed. " "Are you sure? " % thumbnail_dir), buttons=[YES_BUTTON, NO_BUTTON], default=NO_BUTTON) if res == YES_BUTTON: ThumbnailCache.getInstance().clear()
def setup_directory(self, config_key, default_dir, setup_init_file=False): abs_dir_name = get_vistrails_directory(config_key, self.temp_configuration) if abs_dir_name is not None: self.create_directory(abs_dir_name) if abs_dir_name is not None and setup_init_file: self.setup_init_file(abs_dir_name) return abs_dir_name
def clear_clicked(self, checked=False): thumbnail_dir = system.get_vistrails_directory("thumbs.cacheDir") res = show_question('VisTrails', ("All files in %s will be removed. " "Are you sure? " % thumbnail_dir), buttons = [YES_BUTTON,NO_BUTTON], default = NO_BUTTON) if res == YES_BUTTON: ThumbnailCache.getInstance().clear()
def get_directory(self): thumbnail_dir = system.get_vistrails_directory('thumbs.cacheDir') if thumbnail_dir is not None: if not os.path.exists(thumbnail_dir): raise VistrailsInternalError("Cannot find %s" % thumbnail_dir) return thumbnail_dir # raise VistrailsInternalError("'thumbs.cacheDir' not" # " specified in configuration") if self._temp_directory is None: self._temp_directory = tempfile.mkdtemp(prefix='vt_thumbs_') return self._temp_directory
def package_dependencies(): import vistrails.core.packagemanager manager = vistrails.core.packagemanager.get_package_manager() reg = vistrails.core.modules.module_registry.get_module_registry() conf = get_vistrails_configuration() abstraction_dir = get_vistrails_directory("subworkflowsDir") if abstraction_dir is None: debug.log("Subworkflows directory unset, cannot add any abstractions") return [] p = re.compile(r".*\.xml") all_packages = set() for abstraction in os.listdir(abstraction_dir): if p.match(abstraction): abs_fname = os.path.join(abstraction_dir, abstraction) vistrail = read_vistrail(abs_fname) try: dependencies = get_abstraction_dependencies(vistrail) except vistrails.core.modules.module_registry.MissingPackage, e: dependencies = {e._identifier: set()} add_abstraction = True inter_depends = [] for package, depends in dependencies.iteritems(): if package != identifier: if not manager.has_package(package): add_abstraction = False break else: inter_depends.append(depends) if add_abstraction: # print 'adding', abstraction[:-4] all_packages.update(p for p in dependencies.iterkeys() if p != identifier) my_vistrails[abstraction[:-4]] = \ (vistrail, abs_fname, inter_depends) else: debug.critical( ("Subworkflow '%s' is missing packages it " + "depends on") % abstraction)
def package_dependencies(): import vistrails.core.packagemanager manager = vistrails.core.packagemanager.get_package_manager() reg = vistrails.core.modules.module_registry.get_module_registry() conf = get_vistrails_configuration() abstraction_dir = get_vistrails_directory("subworkflowsDir") if abstraction_dir is None: debug.log("Subworkflows directory unset, cannot add any abstractions") return [] p = re.compile(r".*\.xml") all_packages = set() for abstraction in os.listdir(abstraction_dir): if p.match(abstraction): abs_fname = os.path.join(abstraction_dir, abstraction) vistrail = read_vistrail(abs_fname) try: dependencies = get_abstraction_dependencies(vistrail) except vistrails.core.modules.module_registry.MissingPackage, e: dependencies = {e._identifier: set()} add_abstraction = True inter_depends = [] for package, depends in dependencies.iteritems(): if package != identifier: if not manager.has_package(package): add_abstraction = False break else: inter_depends.append(depends) if add_abstraction: # print 'adding', abstraction[:-4] all_packages.update(p for p in dependencies.iterkeys() if p != identifier) my_vistrails[abstraction[:-4]] = \ (vistrail, abs_fname, inter_depends) else: debug.critical(("Subworkflow '%s' is missing packages it " + "depends on") % abstraction)