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")
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)
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()
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
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
def release_python_sdist(): run("rm -f dist/*") run("python setup.py sdist") info("PyPI credentials:") invoke_run("twine upload dist/*", echo=True)
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)
def release_python_sdist(): run("rm -f dist/*") run("python setup.py sdist") invoke_run("twine upload dist/*")
def run(): invoke_run( "%s runserver_plus 0.0.0.0:%d --verbosity=2 --threaded" % ( manage_file, settings.SERVER_PORT ), pty=True )
def local_run(command, *args, **kwargs): print('$: {}'.format(command)) invoke_run(command, *args, **kwargs)
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'))
def shell(): invoke_run( "%s shell_plus" % (manage_file,), pty=True )
def migrate(): invoke_run("%s makemigrations" % (manage_file,), pty=True) invoke_run("%s migrate" % (manage_file,), pty=True)
def clean(): invoke_run("find %s -name '*.pyc' -exec rm {} \;" % settings.BASE_DIR)