Example #1
0
def pip_install(package_name):
    hide_splash_if_necessary()

    if executable_is_in_path('pip'):
        cmd = '%s install' % shell_escape(get_executable_path('pip'))
    else:
        cmd = shell_escape(sys.executable) + ' -m pip install'
    return run_install_command_as_root(has_qt(), cmd, package_name)
Example #2
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
def pip_install(package_name):
    hide_splash_if_necessary()

    if get_executable_path('pip'):
        cmd = '%s install' % shell_escape(get_executable_path('pip'))
    else:
        cmd = shell_escape(sys.executable) + ' -m pip install'

    if systemType != 'Windows':
        use_root = True
        try:
            from distutils.sysconfig import get_python_lib
            f = get_python_lib()
        except Exception:
            f = sys.executable
        use_root = os.stat(f).st_uid == 0
    else:
        use_root = False

    return run_install_command(qt_available(), cmd, package_name, use_root)
Example #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
def linux_debian_install(package_name):
    qt = qt_available()
    try:
        import apt
        import apt_pkg
    except ImportError:
        qt = False
    hide_splash_if_necessary()

    if qt:
        cmd = shell_escape(vistrails_root_directory() +
                           '/gui/bundles/linux_debian_install.py')
    else:
        cmd = '%s install -y' % ('aptitude'
                                 if get_executable_path('aptitude')
                                 else 'apt-get')

    return run_install_command(qt, cmd, package_name)
Example #6
0
def pip_install(package_name):
    hide_splash_if_necessary()

    if executable_is_in_path('pip'):
        cmd = '%s install' % shell_escape(get_executable_path('pip'))
    else:
        cmd = shell_escape(sys.executable) + ' -m pip install'

    if systemType != 'Windows':
        use_root = True
        try:
            from distutils.sysconfig import get_python_lib
            f = get_python_lib()
        except Exception:
            f = sys.executable
        use_root = os.stat(f).st_uid == 0
    else:
        use_root = False

    return run_install_command(qt_available(), cmd, package_name, use_root)
Example #7
0
def run_install_command(graphical, cmd, args, as_root=True):
    if isinstance(args, basestring):
        cmd += ' %s' % shell_escape(args)
    elif isinstance(args, list):
        for package in args:
            if not isinstance(package, basestring):
                raise TypeError("Expected string or list of strings")
            cmd += ' %s' % shell_escape(package)
    else:
        raise TypeError("Expected string or list of strings")

    debug.warning("VisTrails wants to install package(s) %r" %
                  args)

    if as_root and systemType != 'Windows':
        if graphical:
            sucmd, escape = guess_graphical_sudo()
        else:
            if get_executable_path('sudo'):
                sucmd, escape = "sudo %s", False
            elif systemType != 'Darwin':
                sucmd, escape = "su -c %s", True
            else:
                sucmd, escape = '%s', False

        if escape:
            cmd = sucmd % shell_escape(cmd)
        else:
            cmd = sucmd % cmd

    print "about to run: %s" % cmd
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                              stderr=subprocess.STDOUT,
                              shell=True)
    lines = []
    try:
        for line in iter(p.stdout.readline, ''):
            print line,
            lines.append(line)
    except IOError, e:
        print "Ignoring IOError: %s" % e