예제 #1
0
파일: init.py 프로젝트: hjanime/VisTrails
def initialize():
    # First check if spec for this VTK version exists
    v = vtk.vtkVersion()
    vtk_version = [
        v.GetVTKMajorVersion(),
        v.GetVTKMinorVersion(),
        v.GetVTKBuildVersion()
    ]

    # vtk-VTKVERSION-spec-PKGVERSION.xml
    spec_name = os.path.join(
        current_dot_vistrails(), 'vtk-%s-spec-%s.xml' %
        ('_'.join([str(v)
                   for v in vtk_version]), package_version.replace('.', '_')))
    # TODO: how to patch with diff/merge
    if not os.path.exists(spec_name):
        from .vtk_wrapper.parse import parse
        parse(spec_name)
    vtk_classes.initialize(spec_name)
    _modules.insert(0, BaseClassModule)
    _modules.extend([
        gen_class_module(spec,
                         vtk_classes,
                         klasses,
                         signature=hasher.vtk_hasher)
        for spec in vtk_classes.specs.module_specs
    ])
예제 #2
0
def initialize():
    if configuration.check('file_store'):
        file_store_path = configuration.file_store
    else:
        file_store_path = os.path.join(current_dot_vistrails(), 'file_archive')
    if not os.path.exists(file_store_path) or not os.listdir(file_store_path):
        FileStore.create_store(file_store_path)
    set_default_store(FileStore(file_store_path))
예제 #3
0
파일: job.py 프로젝트: cjh1/VisTrails
    def save_to_file(self, filename=None):
        """ save_to_file(filename: str) -> None
            Saves running jobs to a file

        """ 
        if not filename:
            filename = os.path.join(current_dot_vistrails(), JOBS_FILENAME)
        f = open(filename, 'w')
        f.write(self.__serialize__())
        f.close()
예제 #4
0
def initialize():
    global global_db, local_db, search_dbs, compress_by_default, db_access, \
        git_bin, debug

    if configuration.check('git_bin'):
        git_bin = configuration.git_bin
    if git_bin.startswith("@executable_path/"):
        non_expand_path = git_bin
        git_bin = get_executable_path(git_bin[len("@executable_path/"):])
        if git_bin is not None:
            configuration.git_bin = non_expand_path
    if git_bin is None:
        git_bin = 'git'
        configuration.git_bin = git_bin

    if configuration.check('compress_by_default'):
        compress_by_default = configuration.compress_by_default
    if configuration.check('debug'):
        debug = configuration.debug
    if configuration.check('global_db'):
        global_db = configuration.global_db
    if configuration.check('local_db'):
        local_db = configuration.local_db
        if not os.path.exists(local_db):
            raise RuntimeError('local_db "%s" does not exist' % local_db)
    else:
        local_db = os.path.join(current_dot_vistrails(), 'persistent_files')
        if not os.path.exists(local_db):
            try:
                os.mkdir(local_db)
            except OSError:
                raise RuntimeError('local_db "%s" does not exist' % local_db)

    local_repo = repo.get_repo(local_db)
    repo.set_current_repo(local_repo)

    debug_print('creating DatabaseAccess')
    db_path = os.path.join(local_db, '.files.db')
    db_access = DatabaseAccessSingleton(db_path)
    debug_print('done', db_access)

    search_dbs = [
        local_db,
    ]
    if configuration.check('search_dbs'):
        try:
            check_paths = literal_eval(configuration.search_dbs)
        except Exception:
            print "*** persistence error: cannot parse search_dbs ***"
        else:
            for path in check_paths:
                if os.path.exists(path):
                    search_dbs.append(path)
                else:
                    print '*** persistence warning: cannot find path "%s"' % path
예제 #5
0
파일: init.py 프로젝트: Nikea/VisTrails
def initialize():
    global global_db, local_db, search_dbs, compress_by_default, db_access, \
        git_bin, debug
    
    if configuration.check('git_bin'):
        git_bin = configuration.git_bin
    if git_bin.startswith("@executable_path/"):
        non_expand_path = git_bin
        git_bin = get_executable_path(git_bin[len("@executable_path/"):])
        if git_bin is not None:
            configuration.git_bin = non_expand_path
    if git_bin is None:
        git_bin = 'git'
        configuration.git_bin = git_bin
        
    if configuration.check('compress_by_default'):
        compress_by_default = configuration.compress_by_default
    if configuration.check('debug'):
        debug = configuration.debug
    if configuration.check('global_db'):
        global_db = configuration.global_db
    if configuration.check('local_db'):
        local_db = configuration.local_db
        if not os.path.exists(local_db):
            raise RuntimeError('local_db "%s" does not exist' % local_db)
    else:
        local_db = os.path.join(current_dot_vistrails(), 'persistent_files')
        if not os.path.exists(local_db):
            try:
                os.mkdir(local_db)
            except OSError:
                raise RuntimeError('local_db "%s" does not exist' % local_db)

    local_repo = repo.get_repo(local_db)
    repo.set_current_repo(local_repo)

    debug_print('creating DatabaseAccess')
    db_path = os.path.join(local_db, '.files.db')
    db_access = DatabaseAccessSingleton(db_path)
    debug_print('done', db_access)
    
    search_dbs = [local_db,]
    if configuration.check('search_dbs'):
        try:
            check_paths = literal_eval(configuration.search_dbs)
        except Exception:
            print "*** persistence error: cannot parse search_dbs ***"
        else:
            for path in check_paths:
                if os.path.exists(path):
                    search_dbs.append(path)
                else:
                    print '*** persistence warning: cannot find path "%s"' % path
예제 #6
0
파일: init.py 프로젝트: BowenYang/VisTrails
def initialize(*args, **keywords):
    reg = vistrails.core.modules.module_registry.get_module_registry()
    basic = vistrails.core.modules.basic_modules

    reg.add_module(DownloadFile)
    reg.add_input_port(DownloadFile, "url", (basic.String, 'URL'))
    reg.add_input_port(DownloadFile, 'insecure',
                       (basic.Boolean, "Allow invalid SSL certificates"),
                       optional=True, defaults="['False']")
    reg.add_output_port(DownloadFile, "file",
                        (basic.File, 'local File object'))
    reg.add_output_port(DownloadFile, "local_filename",
                        (basic.String, 'local filename'), optional=True)

    reg.add_module(HTTPDirectory)
    reg.add_input_port(HTTPDirectory, 'url', (basic.String, "URL"))
    reg.add_input_port(HTTPDirectory, 'insecure',
                       (basic.Boolean, "Allow invalid SSL certificates"),
                       optional=True, defaults="['False']")
    reg.add_output_port(HTTPDirectory, 'directory',
                        (basic.Directory, "local Directory object"))
    reg.add_output_port(HTTPDirectory, 'local_path',
                        (basic.String, "local path"), 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)

    reg.add_module(URLEncode)
    reg.add_input_port(URLEncode, "string", basic.String)
    reg.add_output_port(URLEncode, "encoded", basic.String)

    reg.add_module(URLDecode)
    reg.add_input_port(URLDecode, "encoded", basic.String)
    reg.add_output_port(URLDecode, "string", basic.String)

    global package_directory
    dotVistrails = current_dot_vistrails()
    package_directory = os.path.join(dotVistrails, "HTTP")

    if not os.path.isdir(package_directory):
        try:
            debug.log("Creating HTTP package directory: %s" % package_directory)
            os.mkdir(package_directory)
        except Exception, e:
            raise RuntimeError("Failed to create cache directory: %s" %
                               package_directory, e)
예제 #7
0
파일: job.py 프로젝트: cjh1/VisTrails
 def load_from_file(self, filename=None):
     """ load_from_file(filename: str) -> None
         Loads running jobs from a file
         
     """
     if not filename:
         filename = os.path.join(current_dot_vistrails(), JOBS_FILENAME)
     if not os.path.exists(filename):
         self.__unserialize__('{}')
         return {}
     f = open(filename)
     result =  self.__unserialize__(f.read())
     f.close()
     return result
예제 #8
0
파일: init.py 프로젝트: AnyarInc/VisTrails
def initialize():
    # First check if spec for this VTK version exists
    v = vtk.vtkVersion()
    vtk_version = [v.GetVTKMajorVersion(),
                   v.GetVTKMinorVersion(),
                   v.GetVTKBuildVersion()]

    # vtk-VTKVERSION-spec-PKGVERSION.xml
    spec_name = os.path.join(current_dot_vistrails(),
                             'vtk-%s-spec-%s.xml' %
                             ('_'.join([str(v) for v in vtk_version]),
                              package_version.replace('.', '_')))
    # TODO: how to patch with diff/merge
    if not os.path.exists(spec_name):
        from .vtk_wrapper.parse import parse
        parse(spec_name)
    vtk_classes.initialize(spec_name)
    _modules.insert(0, BaseClassModule)
    _modules.extend([gen_class_module(spec, vtk_classes, klasses, signature=hasher.vtk_hasher)
                     for spec in vtk_classes.specs.module_specs])
예제 #9
0
def initialize(*args, **keywords):
    reg = vistrails.core.modules.module_registry.get_module_registry()
    basic = vistrails.core.modules.basic_modules

    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(HTTPDirectory)
    reg.add_input_port(HTTPDirectory, 'url', (basic.String, "URL"))
    reg.add_output_port(HTTPDirectory, 'directory',
                        (basic.Directory, "local Directory object"))
    reg.add_output_port(HTTPDirectory, 'local_path',
                        (basic.String, "local path"), 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
    dotVistrails = current_dot_vistrails()
    package_directory = os.path.join(dotVistrails, "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)