Exemplo n.º 1
0
    def create_virtualenv(self):
        sh.virtualenv(self.tmp_dir_env, python='python2.7')
        pip = sh.Command(os.path.join(self.tmp_dir_env, 'bin/pip'))
        reqs_file = os.path.join(self.tmp_dir_src, 'requirements.txt')

        print('Installing virtualenv...')
        for line in pip.install(requirement=reqs_file, _iter=True):
            print(line)
Exemplo n.º 2
0
def chargingbackend(ctx):
    print("Installing charging backend")
    name = charg.get("url").split("/")[-1][:-4]
    cd(name)

    virtualenv("virtenv")

    bash("python-dep-install.sh")
    cd("..")
Exemplo n.º 3
0
	def install_tool(self):
		sh.rm("-rf", S3CMD_HOME)
		sh.rm("-f", TOOL_HOME + "/bin/s3cmd")
		sh.mkdir("-p", S3CMD_HOME)
		sh.virtualenv(S3CMD_HOME)
		sh.mkdir("-p", TOOL_HOME + "/bin")
		pip = sh.Command(S3CMD_HOME + "/bin/pip")
		pip("install", "s3cmd")
		sh.ln("-s", S3CMD_HOME + "/bin/s3cmd", TOOL_HOME + "/bin/s3cmd")
Exemplo n.º 4
0
Arquivo: aws.py Projeto: Knewton/k.aws
	def install_tool(self):
		sh.rm("-rf", AWS_CLI_HOME)
		sh.rm("-f", TOOL_HOME + "/bin/aws")
		sh.mkdir("-p", AWS_CLI_HOME)
		sh.virtualenv(AWS_CLI_HOME)
		sh.mkdir("-p", TOOL_HOME + "/bin")
		pip = sh.Command(AWS_CLI_HOME + "/bin/pip")
		pip("install", "awscli")
		sh.ln("-s", AWS_CLI_HOME + "/bin/aws", TOOL_HOME + "/bin/aws")
Exemplo n.º 5
0
 def setup_env(self, quiet=False):
     if quiet:
         outproc = lambda x:None
     else:
         outproc = self.print_output
     env_dir = self.dir.ENV_DIR
     if not os.path.exists(env_dir):
         sh.virtualenv("--system-site-packages", env_dir, _out=outproc).wait()
     activate_this = self.dir.append("ENV_DIR",'bin/activate_this.py')
     execfile(activate_this, dict(__file__=activate_this))
     self.read_mods()
     if self.mods:
         sh.pip.install(self.mods, _out=outproc).wait()
Exemplo n.º 6
0
 def setup_env(self, quiet=False):
     if quiet:
         outproc = lambda x: None
     else:
         outproc = self.print_output
     env_dir = self.dir.ENV_DIR
     if not os.path.exists(env_dir):
         sh.virtualenv("--system-site-packages", env_dir,
                       _out=outproc).wait()
     activate_this = self.dir.append("ENV_DIR", 'bin/activate_this.py')
     execfile(activate_this, dict(__file__=activate_this))
     self.read_mods()
     if self.mods:
         sh.pip.install(self.mods, _out=outproc).wait()
        def init_virtualenv(self):
            '''
                Initialize the virtualenv.

                Overwrite this function if you want
                special switches used when running virtualenv.
            '''

            if os.path.exists(self.VIRTUAL_SUBDIR):
                sh.rm('-fr', self.VIRTUAL_SUBDIR)
            if IS_PY2:
                sh.virtualenv(self.VIRTUAL_SUBDIR)
            else:
                sh.virtualenv('-p', '/usr/bin/python3.4', self.VIRTUAL_SUBDIR)
Exemplo n.º 8
0
    def make_venv(self, venv_dir):
        """creates a virtualenv

        :param string venv_dir: venv path to create
        """
        lgr.debug('Creating virtualenv in {0}'.format(venv_dir))
        return sh.virtualenv(venv_dir)
Exemplo n.º 9
0
def chargingbackend(ctx):
    print("Installing charging backend")
    name = charg.get("url").split("/")[-1][:-4]
    cd(name)

    virtualenv("virtenv")

    bash("python-dep-install.sh")

    cd('src')
    mkdir('media')
    cd('media')
    mkdir('assets')
    mkdir('bills')

    cd("..")
    cd("..")
    cd("..")
Exemplo n.º 10
0
    def setup_virtualenv(self):
        virtualenv_dir = self.get_virtualenv_dir()
        exists = os.path.exists(virtualenv_dir)
        if not exists:
            log.info('Setting up virtualenv in {}'.format(virtualenv_dir))
            os.makedirs(virtualenv_dir)

            # Setup virtualenv.
            sh.virtualenv(virtualenv_dir)

            pip = self.get_virtualenv_command('pip')

            # Activate virtualenv. Needs to come before setup.py install.
            self.activate_virtualenv()

            # Install Sphinx.
            if self.dependencies:
                for output in pip.install(
                        '--upgrade',
                        *self.dependencies,
                        _iter=True):
                    log.debug('pip install: {}'.format(output))

            # Install python package if needed.
            if self.shall_install_python_package():
                python = self.get_virtualenv_command('python')
                with cd(self.get_project_dir()):
                    log.info('Installing python package')
                    python('setup.py', 'install')

            # Install project's dependencies if there are any.
            pip_requirements_file = self.get_pip_requirements_file()
            if pip_requirements_file:
                requirements_file = os.path.join(
                    self.get_project_dir(),
                    pip_requirements_file)
                log.info('Installing python dependencies from {}'.format(
                    requirements_file))
                pip.install(r=requirements_file)
        else:
            log.debug('Using existing virtualenv: {}'.format(
                virtualenv_dir))
            self.activate_virtualenv()
Exemplo n.º 11
0
def main():
    log = logging.getLogger("zulip-provisioner")

    if platform.architecture()[0] == '64bit':
        arch = 'amd64'
        phantomjs_arch = 'x86_64'
    elif platform.architecture()[0] == '32bit':
        arch = "i386"
        phantomjs_arch = 'i686'
    else:
        log.critical("Only x86 is supported; ping [email protected] if you want another architecture.")
        sys.exit(1)

    vendor, version, codename = platform.dist()

    if not (vendor in SUPPORTED_PLATFORMS and codename in SUPPORTED_PLATFORMS[vendor]):
        log.critical("Unsupported platform: {} {}".format(vendor, codename))

    with sh.sudo:
        sh.apt_get.update(**LOUD)

        sh.apt_get.install(*APT_DEPENDENCIES["trusty"], assume_yes=True, **LOUD)

    temp_deb_path = sh.mktemp("package_XXXXXX.deb", tmpdir=True)

    sh.wget(
        "{}/{}_{}_{}.deb".format(
            TSEARCH_URL_BASE,
            TSEARCH_PACKAGE_NAME["trusty"],
            TSEARCH_VERSION,
            arch,
        ),
        output_document=temp_deb_path,
        **LOUD
    )

    with sh.sudo:
        sh.dpkg("--install", temp_deb_path, **LOUD)

    with sh.sudo:
        PHANTOMJS_PATH = "/srv/phantomjs"
        PHANTOMJS_BASENAME = "phantomjs-1.9.8-linux-%s" % (phantomjs_arch,)
        PHANTOMJS_TARBALL_BASENAME = PHANTOMJS_BASENAME + ".tar.bz2"
        PHANTOMJS_TARBALL = os.path.join(PHANTOMJS_PATH, PHANTOMJS_TARBALL_BASENAME)
        PHANTOMJS_URL = "https://bitbucket.org/ariya/phantomjs/downloads/%s" % (PHANTOMJS_TARBALL_BASENAME,)
        sh.mkdir("-p", PHANTOMJS_PATH, **LOUD)
        if not os.path.exists(PHANTOMJS_TARBALL):
            sh.wget(PHANTOMJS_URL, output_document=PHANTOMJS_TARBALL, **LOUD)
        sh.tar("xj", directory=PHANTOMJS_PATH, file=PHANTOMJS_TARBALL, **LOUD)
        sh.ln("-sf", os.path.join(PHANTOMJS_PATH, PHANTOMJS_BASENAME, "bin", "phantomjs"),
              "/usr/local/bin/phantomjs", **LOUD)

    with sh.sudo:
        sh.rm("-rf", VENV_PATH, **LOUD)
        sh.mkdir("-p", VENV_PATH, **LOUD)
        sh.chown("{}:{}".format(os.getuid(), os.getgid()), VENV_PATH, **LOUD)

    sh.virtualenv(VENV_PATH, **LOUD)

    # Add the ./tools and ./scripts/setup directories inside the repository root to
    # the system path; we'll reference them later.
    orig_path = os.environ["PATH"]
    os.environ["PATH"] = os.pathsep.join((
            os.path.join(ZULIP_PATH, "tools"),
            os.path.join(ZULIP_PATH, "scripts", "setup"),
            orig_path
    ))


    # Put Python virtualenv activation in our .bash_profile.
    with open(os.path.expanduser('~/.bash_profile'), 'w+') as bash_profile:
        bash_profile.writelines([
            "source .bashrc\n",
            "source %s\n" % (os.path.join(VENV_PATH, "bin", "activate"),),
        ])

    # Switch current Python context to the virtualenv.
    activate_this = os.path.join(VENV_PATH, "bin", "activate_this.py")
    execfile(activate_this, dict(__file__=activate_this))

    sh.pip.install(requirement=os.path.join(ZULIP_PATH, "requirements.txt"), **LOUD)

    with sh.sudo:
        sh.cp(REPO_STOPWORDS_PATH, TSEARCH_STOPWORDS_PATH, **LOUD)

    # npm install and management commands expect to be run from the root of the project.
    os.chdir(ZULIP_PATH)

    sh.npm.install(**LOUD)

    os.system("tools/download-zxcvbn")
    os.system("tools/emoji_dump/build_emoji")
    os.system("generate_secrets.py -d")
    if "--travis" in sys.argv:
        os.system("sudo service rabbitmq-server restart")
        os.system("sudo service redis-server restart")
        os.system("sudo service memcached restart")
    elif "--docker" in sys.argv:
        os.system("sudo service rabbitmq-server restart")
        os.system("sudo pg_dropcluster --stop 9.3 main")
        os.system("sudo pg_createcluster -e utf8 --start 9.3 main")
        os.system("sudo service redis-server restart")
        os.system("sudo service memcached restart")
    sh.configure_rabbitmq(**LOUD)
    sh.postgres_init_dev_db(**LOUD)
    sh.do_destroy_rebuild_database(**LOUD)
    sh.postgres_init_test_db(**LOUD)
    sh.do_destroy_rebuild_test_database(**LOUD)
    return 0
Exemplo n.º 12
0
def main():
    log = logging.getLogger("zulip-provisioner")
    # TODO: support other architectures
    if platform.architecture()[0] == '64bit':
        arch = 'amd64'
    else:
        log.critical("Only amd64 is supported.")

    vendor, version, codename = platform.dist()

    if not (vendor in SUPPORTED_PLATFORMS and codename in SUPPORTED_PLATFORMS[vendor]):
        log.critical("Unsupported platform: {} {}".format(vendor, codename))

    with sh.sudo:
        sh.apt_get.update(**LOUD)

        sh.apt_get.install(*APT_DEPENDENCIES["trusty"], assume_yes=True, **LOUD)

    temp_deb_path = sh.mktemp("package_XXXXXX.deb", tmpdir=True)

    sh.wget(
        "{}/{}_{}_{}.deb".format(
            TSEARCH_URL_BASE,
            TSEARCH_PACKAGE_NAME["trusty"],
            TSEARCH_VERSION,
            arch,
        ),
        output_document=temp_deb_path,
        **LOUD
    )

    with sh.sudo:
        sh.dpkg("--install", temp_deb_path, **LOUD)

    with sh.sudo:
        PHANTOMJS_PATH = "/srv/phantomjs"
        PHANTOMJS_TARBALL = os.path.join(PHANTOMJS_PATH, "phantomjs-1.9.8-linux-x86_64.tar.bz2")
        sh.mkdir("-p", PHANTOMJS_PATH, **LOUD)
        sh.wget("https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2",
                output_document=PHANTOMJS_TARBALL, **LOUD)
        sh.tar("xj", directory=PHANTOMJS_PATH, file=PHANTOMJS_TARBALL, **LOUD)
        sh.ln("-sf", os.path.join(PHANTOMJS_PATH, "phantomjs-1.9.8-linux-x86_64", "bin", "phantomjs"),
              "/usr/local/bin/phantomjs", **LOUD)

    with sh.sudo:
        sh.rm("-rf", VENV_PATH, **LOUD)
        sh.mkdir("-p", VENV_PATH, **LOUD)
        sh.chown("{}:{}".format(os.getuid(), os.getgid()), VENV_PATH, **LOUD)

    sh.virtualenv(VENV_PATH, **LOUD)

    # Add the ./tools and ./scripts/setup directories inside the repository root to
    # the system path; we'll reference them later.
    orig_path = os.environ["PATH"]
    os.environ["PATH"] = os.pathsep.join((
            os.path.join(ZULIP_PATH, "tools"),
            os.path.join(ZULIP_PATH, "scripts", "setup"),
            orig_path
    ))


    # Put Python virtualenv activation in our .bash_profile.
    with open(os.path.expanduser('~/.bash_profile'), 'w+') as bash_profile:
        bash_profile.writelines([
            "source .bashrc\n",
            "source %s\n" % (os.path.join(VENV_PATH, "bin", "activate"),),
        ])

    # Switch current Python context to the virtualenv.
    activate_this = os.path.join(VENV_PATH, "bin", "activate_this.py")
    execfile(activate_this, dict(__file__=activate_this))

    sh.pip.install(requirement=os.path.join(ZULIP_PATH, "requirements.txt"), **LOUD)

    with sh.sudo:
        sh.cp(REPO_STOPWORDS_PATH, TSEARCH_STOPWORDS_PATH, **LOUD)

    # npm install and management commands expect to be run from the root of the project.
    os.chdir(ZULIP_PATH)

    sh.npm.install(**LOUD)

    os.system("tools/download-zxcvbn")
    os.system("tools/emoji_dump/build_emoji")
    os.system("generate_secrets.py -d")
    if "--travis" in sys.argv:
        os.system("sudo service rabbitmq-server restart")
        os.system("sudo service redis-server restart")
        os.system("sudo service memcached restart")
    sh.configure_rabbitmq(**LOUD)
    sh.postgres_init_dev_db(**LOUD)
    sh.do_destroy_rebuild_database(**LOUD)
    sh.postgres_init_test_db(**LOUD)
    sh.do_destroy_rebuild_test_database(**LOUD)
Exemplo n.º 13
0
def main():
    log = logging.getLogger("zulip-provisioner")
    # TODO: support other architectures
    if platform.architecture()[0] == '64bit':
        arch = 'amd64'
    else:
        log.critical("Only amd64 is supported.")

    vendor, version, codename = platform.dist()

    if not (vendor in SUPPORTED_PLATFORMS and codename in SUPPORTED_PLATFORMS[vendor]):
        log.critical("Unsupported platform: {} {}".format(vendor, codename))

    with sh.sudo:
        sh.apt_get.update(**LOUD)

        sh.apt_get.install(*APT_DEPENDENCIES["trusty"], assume_yes=True, **LOUD)

    temp_deb_path = sh.mktemp("package_XXXXXX.deb", tmpdir=True)

    sh.wget(
        "{}/{}_{}_{}.deb".format(
            TSEARCH_URL_BASE,
            TSEARCH_PACKAGE_NAME["trusty"],
            TSEARCH_VERSION,
            arch,
        ),
        output_document=temp_deb_path,
        **LOUD
    )

    with sh.sudo:
        sh.dpkg("--install", temp_deb_path, **LOUD)

    with sh.sudo:
        PHANTOMJS_PATH = "/srv/phantomjs"
        PHANTOMJS_TARBALL = os.path.join(PHANTOMJS_PATH, "phantomjs-1.9.8-linux-x86_64.tar.bz2")
        sh.mkdir("-p", PHANTOMJS_PATH, **LOUD)
        sh.wget("https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2",
                output_document=PHANTOMJS_TARBALL, **LOUD)
        sh.tar("xj", directory=PHANTOMJS_PATH, file=PHANTOMJS_TARBALL, **LOUD)
        sh.ln("-sf", os.path.join(PHANTOMJS_PATH, "phantomjs-1.9.8-linux-x86_64", "bin", "phantomjs"),
              "/usr/local/bin/phantomjs", **LOUD)

    with sh.sudo:
        sh.rm("-rf", VENV_PATH, **LOUD)
        sh.mkdir("-p", VENV_PATH, **LOUD)
        sh.chown("{}:{}".format(os.getuid(), os.getgid()), VENV_PATH, **LOUD)

    sh.virtualenv(VENV_PATH, **LOUD)

    # Add the ./tools and ./scripts/setup directories inside the repository root to
    # the system path; we'll reference them later.
    orig_path = os.environ["PATH"]
    os.environ["PATH"] = os.pathsep.join((
            os.path.join(ZULIP_PATH, "tools"),
            os.path.join(ZULIP_PATH, "scripts", "setup"),
            orig_path
    ))


    # Put Python virtualenv activation in our .bash_profile.
    with open(os.path.expanduser('~/.bash_profile'), 'w+') as bash_profile:
        bash_profile.writelines([
            "source .bashrc\n",
            "source %s\n" % (os.path.join(VENV_PATH, "bin", "activate"),),
        ])

    # Switch current Python context to the virtualenv.
    activate_this = os.path.join(VENV_PATH, "bin", "activate_this.py")
    execfile(activate_this, dict(__file__=activate_this))

    sh.pip.install(requirement=os.path.join(ZULIP_PATH, "requirements.txt"), **LOUD)

    with sh.sudo:
        sh.cp(REPO_STOPWORDS_PATH, TSEARCH_STOPWORDS_PATH, **LOUD)

    # Add additional node packages for test-js-with-node.
    with sh.sudo:
        sh.npm.install(*NPM_DEPENDENCIES["trusty"], g=True, prefix="/usr", **LOUD)

    # Management commands expect to be run from the root of the project.
    os.chdir(ZULIP_PATH)

    os.system("tools/download-zxcvbn")
    os.system("tools/emoji_dump/build_emoji")
    os.system("generate_secrets.py -d")
    sh.configure_rabbitmq(**LOUD)
    sh.postgres_init_db(**LOUD)
    sh.do_destroy_rebuild_database(**LOUD)
    sh.postgres_init_test_db(**LOUD)
    sh.do_destroy_rebuild_test_database(**LOUD)
Exemplo n.º 14
0
 def create_env(self):
     """Create a virtual environment."""
     virtualenv(self.env, _err=sys.stderr)
     os.mkdir(self.env_bin)