This repository was archived by the owner on Jan 15, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 411
Expand file tree
/
Copy pathdump-python39.py
More file actions
69 lines (57 loc) · 1.67 KB
/
dump-python39.py
File metadata and controls
69 lines (57 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from __future__ import print_function
import os
import sys
import subprocess
import json
import boto3
from boto3.s3.transfer import S3Transfer
TRANSFER = S3Transfer(boto3.client("s3"))
def lambda_handler(event, context):
if "cmd" in event:
return print(
subprocess.check_output(["sh", "-c", event["cmd"]]).decode("utf-8")
)
filename = "python3.9.tgz"
subprocess.call(
[
"sh",
"-c",
f"tar -cpzf /tmp/{filename} --numeric-owner --ignore-failed-read "
+ "/var/runtime /var/lang /var/rapid",
]
)
print("Zipping done! Uploading...")
TRANSFER.upload_file(
f"/tmp/{filename}",
"lambci",
f"fs/{filename}",
extra_args={"ACL": "public-read"},
)
print("Uploading done!")
info = {
"sys.executable": sys.executable,
"sys.argv": sys.argv,
"sys.path": sys.path,
"os.getcwd": os.getcwd(),
"__file__": __file__,
"os.environ": {k: str(v) for k, v in os.environ.items()},
"context": {k: str(v) for k, v in context.__dict__.items()},
"proc environ": subprocess.check_output(
["sh", "-c", "echo /proc/1/environ; xargs -n 1 -0 < /proc/1/environ"]
)
.decode("utf-8")
.splitlines(),
"ps aux": subprocess.check_output(
[
"bash",
"-O",
"extglob",
"-c",
"for cmd in /proc/+([0-9])/cmdline; do echo $cmd; xargs -n 1 -0 < $cmd; done",
]
)
.decode("utf-8")
.splitlines(),
}
print(json.dumps(info, indent=2))
return info