Beispiel #1
0
    def release_python_sdist():

        if pypi:
            info("PyPI credentials:")
            invoke_run("twine upload dist/*", echo=True)
        else:
            run("python setup.py sdist upload -r pypicloud")
Beispiel #2
0
def install():
    """ Installs node, bower packages and creates tables """
    print("Installing node packages")
    invoke_run("npm install")
    print("Installing bower packages")
    invoke_run("bower install")
    create_db()
def run(command, **kwargs):
    result = invoke_run(command, hide=True, warn=True, **kwargs)
    if result.exited != 0:
        error(f"Error running {command}")
        print(result.stdout)
        print()
        print(result.stderr)
        exit(result.exited)
Beispiel #4
0
def run(command, **kwargs):
    print(f'{command}')
    result = invoke_run(command, hide=True, warn=True, **kwargs)
    if (result.exited is not None) and (result.exited != 0):
        error(f"Error running {command}")
        print(result.stdout)
        print()
        print(result.stderr)
        exit(result.exited)
def run(command, exit_on_error=True, **kwargs):
    result = invoke_run(command, hide=True, warn=True, **kwargs)
    if result.exited != 0:
        if not exit_on_error:
            raise RuntimeError(result.stderr)
        error(f"Error running {command}")
        print(result.stdout)
        print()
        print(result.stderr)
        exit(result.exited)

    return result.stdout.strip()
Beispiel #6
0
def capture(cmd, **kw):
    """Run a command and return its stripped captured output."""
    kw = kw.copy()
    kw['hide'] = 'out'
    if not kw.get('echo', False):
        kw['echo'] = False
    ignore_failures = kw.pop('ignore_failures', False)
    try:
        return invoke_run(cmd, **kw).stdout.strip()
    except exceptions.Failure as exc:
        if not ignore_failures:
            notify.error("Command `{}` failed with RC={}!".format(cmd, exc.result.return_code,))
            raise
Beispiel #7
0
def run(cmd, pty=None, env=None, *args, **kwargs):
    """
    invoke's default runner, with some customisation.

    Customisations:
    - Ensure PYTHONPATH is present and allows package to be imported.
    - Do not use UnexpectedExit's default message format. stderr & stdout will be output and then the task will exit
    """
    if pty is None:
        pty = True
    if env is None:
        env = {"PYTHONPATH": "./"}

    try:
        return invoke_run(cmd, env=env, pty=pty, *args, **kwargs)
    except UnexpectedExit as err:
        result: Result = err.result
        exit(result.return_code)
 def local(self, command, **kwargs):
     given_command = command
     # Apply cd(), path() etc
     with_env = _prefix_env_vars(command, local=True)
     wrapped_command = _prefix_commands(with_env, 'local')
     if kwargs.get('use_sudo'):
         #cmd = cmd.replace('"','\\"').replace('$','\\$')
         wrapped_command = 'sudo -E -S -p \'sudo password:\' /bin/bash -c "{0}"'.format(wrapped_command)
     wrapped_command = self.fmt(wrapped_command, **kwargs)
     print "[local]",wrapped_command
     try:
         hide = None
         warn_only = False
         if not state.output.stdout:
             hide = 'stdout'
         if self.env.warn_only:
             warn_only = True
         rs = invoke_run(wrapped_command, hide=hide, warn=warn_only)
         rs.succeeded = not rs.failed
     except invoke.exceptions.Failure as e:
         print red(e)
         rs = NoOp()
     return rs
Beispiel #9
0
 def release_python_sdist():
     run("rm -f dist/*")
     run("python setup.py sdist")
     info("PyPI credentials:")
     invoke_run("twine upload dist/*", echo=True)
Beispiel #10
0
def run(cmd, **kwargs):
    """wrapper around invoke.run that accepts a Popen list"""
    if isinstance(cmd, list):
        cmd = " ".join(pipes.quote(s) for s in cmd)
    kwargs.setdefault('echo', True)
    return invoke_run(cmd, **kwargs)
Beispiel #11
0
def release_python_sdist():
    run("rm -f dist/*")
    run("python setup.py sdist")
    invoke_run("twine upload dist/*")
Beispiel #12
0
def run():
    invoke_run(
        "%s runserver_plus 0.0.0.0:%d --verbosity=2 --threaded" % (
            manage_file, settings.SERVER_PORT
        ), pty=True
    )
Beispiel #13
0
def local_run(command, *args, **kwargs):
    print('$: {}'.format(command))
    invoke_run(command, *args, **kwargs)
Beispiel #14
0
def pip():
    invoke_run('pip-compile %s' % os.path.join(BASE_DIR, 'requirements.in'))
    invoke_run('pip-sync %s' % os.path.join(BASE_DIR, 'requirements.txt'))
Beispiel #15
0
def shell():
    invoke_run(
        "%s shell_plus" % (manage_file,), pty=True
    )
Beispiel #16
0
def migrate():
    invoke_run("%s makemigrations" % (manage_file,), pty=True)
    invoke_run("%s migrate" % (manage_file,), pty=True)
Beispiel #17
0
def run(cmd, **kwargs):
    """wrapper around invoke.run that accepts a Popen list"""
    if isinstance(cmd, list):
        cmd = " ".join(pipes.quote(s) for s in cmd)
    kwargs.setdefault('echo', True)
    return invoke_run(cmd, **kwargs)
Beispiel #18
0
def clean():
    invoke_run("find %s -name '*.pyc' -exec rm {} \;" % settings.BASE_DIR)