mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Back-ported format strings for compatibility with Py 3.5
Also fixed a encoding error where Heroku --json return needs to be treated as UTF8
This commit is contained in:
parent
a9b9d42791
commit
fb505de11c
2 changed files with 21 additions and 9 deletions
|
|
@ -59,13 +59,18 @@ def publish(publisher, files, name, metadata, extra_options, force, branch, **ex
|
||||||
"""Exit (with error message) if ``binary` isn't installed"""
|
"""Exit (with error message) if ``binary` isn't installed"""
|
||||||
if not shutil.which(binary):
|
if not shutil.which(binary):
|
||||||
click.secho(
|
click.secho(
|
||||||
f" Publishing to {publish_target} requires {binary} to be installed and configured ",
|
"Publishing to {publish_target} requires {binary} to be installed and configured".format(
|
||||||
|
publish_target=publish_target,
|
||||||
|
binary=binary,
|
||||||
|
),
|
||||||
bg='red',
|
bg='red',
|
||||||
fg='white',
|
fg='white',
|
||||||
bold=True,
|
bold=True,
|
||||||
err=True
|
err=True
|
||||||
)
|
)
|
||||||
click.echo(f"Follow the instructions at {install_link}", err=True)
|
click.echo("Follow the instructions at {install_link}".format(
|
||||||
|
install_link=install_link,
|
||||||
|
), err=True)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if publisher == 'now':
|
if publisher == 'now':
|
||||||
|
|
@ -87,10 +92,13 @@ def publish(publisher, files, name, metadata, extra_options, force, branch, **ex
|
||||||
call(["heroku", "plugins:install", "heroku-builds"])
|
call(["heroku", "plugins:install", "heroku-builds"])
|
||||||
|
|
||||||
with temporary_heroku_directory(files, name, metadata, extra_options, branch, extra_metadata):
|
with temporary_heroku_directory(files, name, metadata, extra_options, branch, extra_metadata):
|
||||||
create_output = check_output(['heroku', 'apps:create', '--json'])
|
create_output = check_output(
|
||||||
|
['heroku', 'apps:create', '--json']
|
||||||
|
).decode('utf8')
|
||||||
app_name = json.loads(create_output)["name"]
|
app_name = json.loads(create_output)["name"]
|
||||||
call(["heroku", "builds:create", "-a", app_name])
|
call(["heroku", "builds:create", "-a", app_name])
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.argument('files', type=click.Path(exists=True), nargs=-1, required=True)
|
@click.argument('files', type=click.Path(exists=True), nargs=-1, required=True)
|
||||||
@click.option(
|
@click.option(
|
||||||
|
|
|
||||||
|
|
@ -151,8 +151,8 @@ def temporary_docker_directory(files, name, metadata, extra_options, branch=None
|
||||||
os.mkdir(datasette_dir)
|
os.mkdir(datasette_dir)
|
||||||
saved_cwd = os.getcwd()
|
saved_cwd = os.getcwd()
|
||||||
file_paths = [
|
file_paths = [
|
||||||
os.path.join(saved_cwd, name)
|
os.path.join(saved_cwd, file_path)
|
||||||
for name in files
|
for file_path in files
|
||||||
]
|
]
|
||||||
file_names = [os.path.split(f)[-1] for f in files]
|
file_names = [os.path.split(f)[-1] for f in files]
|
||||||
if metadata:
|
if metadata:
|
||||||
|
|
@ -185,8 +185,8 @@ def temporary_heroku_directory(files, name, metadata, extra_options, branch=None
|
||||||
saved_cwd = os.getcwd()
|
saved_cwd = os.getcwd()
|
||||||
|
|
||||||
file_paths = [
|
file_paths = [
|
||||||
os.path.join(saved_cwd, name)
|
os.path.join(saved_cwd, file_path)
|
||||||
for name in files
|
for file_path in files
|
||||||
]
|
]
|
||||||
file_names = [os.path.split(f)[-1] for f in files]
|
file_names = [os.path.split(f)[-1] for f in files]
|
||||||
|
|
||||||
|
|
@ -207,7 +207,9 @@ def temporary_heroku_directory(files, name, metadata, extra_options, branch=None
|
||||||
open('runtime.txt', 'w').write('python-3.6.2')
|
open('runtime.txt', 'w').write('python-3.6.2')
|
||||||
|
|
||||||
if branch:
|
if branch:
|
||||||
install_from = f'https://github.com/simonw/datasette/archive/{branch}.zip'
|
install_from = 'https://github.com/simonw/datasette/archive/{branch}.zip'.format(
|
||||||
|
branch=branch
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
install_from = 'datasette'
|
install_from = 'datasette'
|
||||||
|
|
||||||
|
|
@ -216,7 +218,9 @@ def temporary_heroku_directory(files, name, metadata, extra_options, branch=None
|
||||||
open('bin/post_compile', 'w').write('datasette build --inspect-file inspect-data.json')
|
open('bin/post_compile', 'w').write('datasette build --inspect-file inspect-data.json')
|
||||||
|
|
||||||
quoted_files = " ".join(map(shlex.quote, files))
|
quoted_files = " ".join(map(shlex.quote, files))
|
||||||
procfile_cmd = f'web: datasette serve --host 0.0.0.0 {quoted_files} --cors --port $PORT --inspect-file inspect-data.json'
|
procfile_cmd = 'web: datasette serve --host 0.0.0.0 {quoted_files} --cors --port $PORT --inspect-file inspect-data.json'.format(
|
||||||
|
quoted_files=quoted_files,
|
||||||
|
)
|
||||||
open('Procfile', 'w').write(procfile_cmd)
|
open('Procfile', 'w').write(procfile_cmd)
|
||||||
|
|
||||||
for path, filename in zip(file_paths, file_names):
|
for path, filename in zip(file_paths, file_names):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue