Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@task
def cargo(feed_base_url = None):
"""Builds docset for cargo project
If feed base url is present also generates a feed file. \
Base url isn't checked, so it could be a marker, which will be \
processed later by other tools like sed."""
proj_loc = cargo_result(["locate-project"])
proj_root = os.path.dirname(proj_loc["root"])
manifest = cargo_result(["read-manifest", "--manifest-path=%s" % proj_root])
docset_dir = os.path.join(proj_root, "target", "docset")
shutil.rmtree(docset_dir, True)
ds = {
"name": manifest["name"],
"version": manifest["version"],
@task
def install_yarn(c):
"""Install yarn."""
if not c.run('which yarn', warn=True).failed:
return
if not exists('/etc/apt/sources.list.d/yarn.list'):
c.run('echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee -a /etc/apt/sources.list.d/yarn.list')
c.run('curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -')
c.sudo('apt-get update')
c.sudo('apt-get install -y yarn')
@invoke.task()
def get_changelog(ctx):
changelog = _render_log()
print(changelog)
return changelog
@task
def build_server_image(ctx):
if 'key' not in ctx:
raise RuntimeError('pleas provde key for access server to gitlab')
server_dir = f'{CONTAINERS_BASE}/server'
with (pathlib.Path(server_dir) / 'key').open('w') as key_file:
key = os.linesep.join((
'-----BEGIN RSA PRIVATE KEY-----',
*ctx['key'],
'-----END RSA PRIVATE KEY-----',
'',
))
key_file.write(key)
ctx.run(f'rm {server_dir}/lektorium*.whl', warn=True)
ctx.run(f'pip wheel -w {server_dir} --no-deps .')
ctx.run((
@task(check_environment)
def delete_celery(ctx, apply=False):
_delete('celery', ctx, apply)
@invoke.task()
def build(ctx, release=False, verbose=False):
build_params = [
'--release' * release,
'--verbose' * verbose,
]
with ctx.cd(SHIMSDIR):
ctx.run('cargo build {}'.format(' '.join(build_params)))
@invoke.task
def tox_clean(context):
"Remove tox virtualenvs and logs"
#pylint: disable=unused-argument
rmrf('.tox')
namespace_clean.add_task(tox_clean, 'tox')
@task
def install_conda(yes=False):
cmd = 'conda install --file conda-requirements.txt'
if yes:
cmd += ' --yes'
run(cmd, pty=True)
@task
def invoke_lambda(ctx, lambda_name, async=False, payload=None, no_payload=False):
client = boto3.client("lambda", region_name=AWS_REGION)
kwargs = {
"FunctionName": lambda_name,
"InvocationType": "Event" if async else "RequestResponse",
}
if not no_payload:
payload = payload if payload else {}
payload["submitted"] = str(datetime.now())
kwargs["Payload"] = dumps(payload)
response = client.invoke(**kwargs)
print(response)
@_invoke.task()
def cacheclean(ctx):
""" Wipe Cache files """
ctx.shell.rm_rf(
'.tox',
'bench/.tox',
'.cache',
'tests/.cache',
'tests/.pytest_cache',
'.mypy_cache',
)