Skip to content

Commit 562a01c

Browse files
committed
Update command scripts
1 parent a2211b8 commit 562a01c

File tree

4 files changed

+43
-22
lines changed

4 files changed

+43
-22
lines changed

dodo_webdev_commands/aws-connect.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ def _args():
2121
profiles = Dodo.get_config("/AWS/profiles", {})
2222
profile = profiles[args.profile]
2323

24+
Dodo.run(["pass", "landler/aws"])
2425
Dodo.run(["aws", "configure", "sso", f"--profile={profile}"])
2526
Dodo.run(["aws", "sts", "get-caller-identity", f"--profile={profile}"])
2627

28+
for key, value in dict(AWS_PROFILE=profile).items():
29+
Dodo.get_container().command_line.env_vars_from_input_args.append(
30+
f"{key}={value}"
31+
)
32+
2733
print("Connecting to tailscale")
2834
Dodo.run(["sudo", "tailscale", "up", "--accept-dns", "--accept-routes"])
2935
Dodo.run(
@@ -35,5 +41,4 @@ def _args():
3541
f"--name={profile}-eks",
3642
f"--alias={profile}",
3743
],
38-
variable_map=dict(AWS_PROFILE=profile),
3944
)

dodo_webdev_commands/django-manage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def _args():
77
Dodo.parser.add_argument(
88
"--name",
99
)
10-
Dodo.parser.add_argument("cmd_args", nargs="?")
10+
Dodo.parser.add_argument("cmd_args", nargs="*")
1111
args = Dodo.parse_args()
1212
args.python = Dodo.get_config("/DJANGO/python")
1313
args.cwd = Dodo.get_config("/DJANGO/cwd")

dodo_webdev_commands/download-dump.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,44 @@
22
from argparse import ArgumentParser
33

44
from dodo_commands import Dodo
5-
from dodo_commands.framework.config import merge_into_config
65
from dodo_commands.framework.choice_picker import ChoicePicker
6+
from dodo_commands.framework.config import merge_into_config
77
from dodo_ssh_agent_commands.utils import add_ssh_agent_args
88

99

1010
def _args():
1111
parser = ArgumentParser()
12-
parser.add_argument('host')
12+
parser.add_argument("host")
1313
args = Dodo.parse_args(parser)
1414
return args
1515

1616

1717
def _get_timestamp(fn):
18-
return fn.split('_')[-1]
18+
return fn.split("_")[-1]
1919

2020

2121
if Dodo.is_main(__name__, safe=True):
2222
args = _args()
23-
project_name = Dodo.get_config('/ROOT/project_name')
24-
cmd = 'root@{host}:/srv/{projectName}/dumps'.format(
25-
host=args.host, projectName=project_name)
26-
dumps_dir = '/srv/%s/dumps' % project_name
23+
project_name = Dodo.get_config("/ROOT/project_name")
24+
cmd = "root@{host}:/srv/{projectName}/dumps".format(
25+
host=args.host, projectName=project_name
26+
)
27+
dumps_dir = "/srv/%s/dumps" % project_name
2728

2829
merge_into_config(
29-
Dodo.get_config('/DOCKER').setdefault('options', {}),
30-
{Dodo.command_name: add_ssh_agent_args({'is_interactive': False})})
31-
32-
dump_fns = Dodo.run([
33-
'ssh',
34-
'root@%s' % args.host,
35-
'ls',
36-
os.path.join(dumps_dir, '*.sql'),
37-
],
38-
capture=True).split()
30+
Dodo.get_config("/DOCKER").setdefault("options", {}),
31+
{Dodo.command_name: add_ssh_agent_args({"is_interactive": False})},
32+
)
33+
34+
dump_fns = Dodo.run(
35+
[
36+
"ssh",
37+
"root@%s" % args.host,
38+
"ls",
39+
os.path.join(dumps_dir, "*.sql"),
40+
],
41+
capture=True,
42+
).split()
3943

4044
dump_fns = sorted([x for x in dump_fns if x], key=_get_timestamp)
4145

@@ -45,10 +49,10 @@ def print_choices(self, choices):
4549
print("%d: %s" % (idx + 1, dump_fn))
4650

4751
def question(self):
48-
return 'Select files to download (e.g. 1,3-4): '
52+
return "Select files to download (e.g. 1,3-4): "
4953

5054
picker = Picker()
5155
picker.pick(dump_fns)
5256

5357
for dump_fn in picker.get_choices():
54-
Dodo.run(['scp', 'root@%s:%s' % (args.host, dump_fn), dump_fn])
58+
Dodo.run(["scp", "root@%s:%s" % (args.host, dump_fn), dump_fn])

dodo_webdev_commands/kubectl-cp.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from argparse import ArgumentParser
23

34
from dodo_commands import Dodo
@@ -9,6 +10,7 @@
910
def _args():
1011
parser = ArgumentParser(description="")
1112
parser.add_argument("filename")
13+
parser.add_argument("--rev", action="store_true")
1214

1315
# Use the parser to create the command arguments
1416
args = Dodo.parse_args(parser, config_args=[])
@@ -21,4 +23,14 @@ def _args():
2123
args = _args()
2224
container_name = KubeCtlDecorator.get_full_container_name(Dodo.get_config)
2325

24-
Dodo.run(["kubectl", "cp", args.filename, f"{container_name}:/app"])
26+
if args.rev:
27+
Dodo.run(
28+
[
29+
"kubectl",
30+
"cp",
31+
f"{container_name}:/app/{args.filename}",
32+
f"./{os.path.basename(args.filename)}",
33+
]
34+
)
35+
else:
36+
Dodo.run(["kubectl", "cp", args.filename, f"{container_name}:/app"])

0 commit comments

Comments
 (0)