Example #1
0
def main():
    sh.git.clone('https://github.com/creationix/nvm.git')
    sh.source('~/nvm/nvm.sh')
    sh.nvm.install('v9.6.1')
    sh.nvm.alias('default', 'v9.6.1')
    sh.cd('rumble-react')
    sh.npm('install')
Example #2
0
def run_npm(npm_output_file_path, npm_args):
    """
    Run an npm command

    Parameters
    ----------
    npm_output_file_path:
        String
    npm_args:
        Commandline arguments to npm
    """
    try:
        with open(npm_output_file_path, 'w',
                  encoding='utf-8') as npm_output_file:
            out_callback = create_sh_redirect_to_multiple_streams_fn_callback(
                [sys.stdout, npm_output_file])
            err_callback = create_sh_redirect_to_multiple_streams_fn_callback(
                [sys.stderr, npm_output_file])

            sh.npm(  # pylint: disable=no-member
                npm_args,
                _out=out_callback,
                _err=err_callback)
    except sh.ErrorReturnCode as error:
        raise StepRunnerException(f"Error running npm. {error}") from error
Example #3
0
def main():
    sh.git('clone https://github.com/creationix/nvm.git')
    subprocess.Popen('source ~/nvm/nvm.sh')
    subprocess.Popen('nvm install v9.6.1')
    subprocess.Popen('nvm alias default v9.6.1')
    sh.cd('rumble-react')
    sh.npm('install')
Example #4
0
def emmet(abbr: str) -> Optional[str]:
    npmdir = os.path.join(os.path.dirname(__file__), "htmltools")

    if not os.path.isdir(os.path.join(npmdir, "node_modules")):
        print2("Installing Node.js dependencies...\n")
        sh.npm("install", "@emmetio/expand-abbreviation", _cwd=npmdir)

    return sh.node("emmet.js", abbr, _cwd=npmdir)
Example #5
0
def download_depends(depends, type_, path):
    logger.debug('Downloading dependencies for %s', path)
    if type_ == 'python':
        install_path = "%s/depends" % path
        #        pip install -b /tmp  --src=/tmp --install-option="--install-lib=/home/inkvi/test" -v msgpack-python
        output = sh.pip("install", "-v", "-I", "-b", path, "--src", path, "--install-option",
                        "--install-lib=%s" % install_path, *depends)
        return os.listdir(install_path)
    elif type_ == 'nodejs':
        install_path = "%s/node_modules"%path 
        sh.mkdir("-p",install_path)
        sh.npm("install","--production",_cwd=path)
        return os.listdir(install_path)
Example #6
0
def build_wasm(args):
  crate_paths = [os.path.normpath(crate_path) for crate_path in args.crate_path]
  for crate_path in crate_paths:
    sh.npm("install", "--prefix", crate_path, **SH_KWARGS)
    sh.bash(os.path.join(crate_path, "build_dist.sh"), **SH_KWARGS)

    output_dir_path = os.path.join(args.upload_path, APP_NAME)
    os.makedirs(output_dir_path)
    shutil.copytree(
        os.path.join(crate_path, "dist"),
        os.path.join(output_dir_path, "v%s" % args.version))

    shutil.copytree(
        os.path.join(crate_path, "dist"),
        os.path.join(output_dir_path, "%s" % args.branch))
Example #7
0
def setup_grunt(site, git):
    """Set up grunt"""
    os.chdir(site.path)
    puts("Installing node packages")
    print(sh.npm("install", _cwd=site.path))
    puts("Running grunt")
    print(sh.grunt(_cwd=site.path))
Example #8
0
def setup_grunt(site, git):
    """Set up grunt"""
    os.chdir(site.path)
    puts("Installing node packages")
    print(sh.npm("install", _cwd=site.path))
    puts("Running grunt")
    print(sh.grunt(_cwd=site.path))
Example #9
0
def proxyCommand(host, port, chargingport, glassfishport):
    print("Installing logic proxy")
    name = proxy.get("url").split("/")[-1][:-4]
    cd(name)
    npm("install")
    if not os.path.isfile("config.js"):
        shutil.copy2("config.js.template", "config.js")

        text = ""
        with open("config.js") as f:
            text = f.read()

        text = text.replace("config.port = 80", "config.port = {}".format(port))\
                   .replace("'/proxy'", "''")

        texts = text.split("\n")
        texts = texts[:47] + generate_endpoints(glassfishport,
                                                chargingport) + texts[109:]

        text = "\n".join(texts)

        with open("config.js", "w") as f:
            f.write(text)

        mkdir('indexes')
        node('fill_indexes.js')

    print("""
    Finished!
    Now, go to https://account.lab.fiware.org and create an application with this settings:

    - URL: http://{host}:{port}
    - Callback URL: http://{host}:{port}/auth/fiware/callback

    Create a role called "seller"
    Attach the role to the users you prefer.
    Modify config.js file with:

    - config.oauth2.clientID: The client ID that you got when you created the Application
    - config.oauth2.clientSecret: The client Secret that you got when you created the Application
    - config.oauth2.callbackURL = http://{host}:{port}/auth/fiware/callback

    Once you've done all, execute the proxy with:
    node server.js
    """.format(host=host, port=port))
Example #10
0
File: cli.py Project: mardix/Mocha
def _npm_install_static():
    print("NPM Install packages...")
    static_path = os.path.join(CWD, "application/static")
    package_json = os.path.join(static_path, "package.json")

    try:
        if os.path.isfile(package_json):
            with sh.pushd(static_path):
                sh.npm("install", "-f")
        else:
            print(
                "**ERROR: Can't install static files, `package.json` is missing at `%s`"
                % package_json)
            print("*" * 80)
    except sh.CommandNotFound as e:
        print("")
        print(
            "*** Error Command Not Found: `{0}` is not found. You need to install `{0}` to continue"
            .format(str(e)))
        print("*" * 80)
Example #11
0
def run_npm(npm_output_file_path, npm_args, npm_envs=None):
    """
    Run an npm command

    Parameters
    ----------
    npm_output_file_path:
        String
    npm_args:
        Commandline arguments to npm
    npm_envs:
        Dictionary representing additional environment variables
    """
    try:
        with open(npm_output_file_path, 'w',
                  encoding='utf-8') as npm_output_file:
            out_callback = create_sh_redirect_to_multiple_streams_fn_callback(
                [sys.stdout, npm_output_file])
            err_callback = create_sh_redirect_to_multiple_streams_fn_callback(
                [sys.stderr, npm_output_file])

            if npm_envs:
                new_env = os.environ.copy()
                new_env.update(npm_envs)

                sh.npm(  # pylint: disable=no-member
                    npm_args,
                    _env=new_env,
                    _out=out_callback,
                    _err=err_callback)
            else:
                sh.npm(  # pylint: disable=no-member
                    npm_args,
                    _out=out_callback,
                    _err=err_callback)
    except sh.ErrorReturnCode as error:
        raise StepRunnerException(f"Error running npm. {error}") from error
Example #12
0
def generate_style():
    with Path("libs/openstreetmap-carto"):
        click.echo("Installing carto")
        npm('install', 'carto')

        click.echo("Updating credentials in project.mml")
        credentials = {
            'host': DB_HOST,
            'dbname': DB_NAME,
            'user': DB_USER,
            'password': DB_PASS
        }
        with open("project.mml", "r+") as f:
            project = yaml.safe_load(f)
            for layer in project['Layer']:
                layer['Datasource'].update(credentials)
            f.seek(0)
            f.write(yaml.dump(project))

        click.echo("Downloading shapefiles")
        python("scripts/get-shapefiles.py", "-s")

        click.echo("Generating style")
        carto("project.mml", "-f", OSM_CARTO_STYLE_FILE)
import sh, shutil, glob, subprocess

def main():
    root = '/home/saarsayfan/'

    subprocess.Popen('nvm alias default v9.6.1')
    print(nvm.stdout)

    gp = sh.git('pull')
    if gp.stdout.startswith('Already up-to-date.'):
        continue = input('UP TO DATE. CONTINUE (Y/N)?')
        if continue.lower() != 'y':
            return

    nrb = sh.npm('run', 'build')
    if 'STDERR' in nrb.stdout:
        print(nrb.stdout)
        return

    print('BUILD SUCCESSFUL')

    cdbs = sh.cd(root + 'rumble-react/build/static')
    shutil.copytree('js', '../js')
    shutil.copytree('css', '../css')
    shutil.copytree('media', '../media')
    cdb = sh.cd(root + 'rumble-react/build')
    shutil.rmtree('static')

    with open('index.html', 'r+') as f:
        t = f.read()
        t = t.replace('favicon.ico', 'static/rumble-react/favicon.ico')