-
Notifications
You must be signed in to change notification settings - Fork 2
/
cleanup.py
70 lines (68 loc) · 3.3 KB
/
cleanup.py
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
70
import os
def clean_aws_creds():
changes_made = 0
for root, dirs, files in os.walk("."):
for file_name in files:
if file_name.endswith(".py") and file_name != "cleanup.py":
file_path = os.path.join(root, file_name)
with open(file_path, 'r') as file:
lines = file.readlines()
with open(file_path, 'w') as file:
for line in lines:
if "os.environ['AWS_ACCESS_KEY_ID']" in line and not "os.environ['AWS_ACCESS_KEY_ID'] = 'PLACE_AWS_ID_HERE'" in line:
line = "os.environ['AWS_ACCESS_KEY_ID'] = 'PLACE_AWS_ID_HERE'\n"
changes_made += 1
elif "os.environ['AWS_SECRET_ACCESS_KEY']" in line and not "os.environ['AWS_SECRET_ACCESS_KEY'] = 'PLACE_AWS_KEY_HERE'" in line:
line = "os.environ['AWS_SECRET_ACCESS_KEY'] = 'PLACE_AWS_KEY_HERE'\n"
changes_made += 1
file.write(line)
if changes_made == 0:
print("AWS cleanup complete, no changes made.")
elif changes_made == 1:
print("AWS cleanup complete, 1 change made.")
else:
print("AWS cleanup complete, {} changes made.".format(changes_made))
def clean_slack_creds():
changes_made = 0
for root, dirs, files in os.walk("."):
for file_name in files:
if file_name.endswith(".env") and file_name != "cleanup.py":
file_path = os.path.join(root, file_name)
with open(file_path, 'r') as file:
lines = file.readlines()
with open(file_path, 'w') as file:
for line in lines:
if "SLACK_BOT_TOKEN=" in line and not "SLACK_BOT_TOKEN=ENTER_TOKEN_HERE" in line:
line = "SLACK_BOT_TOKEN=ENTER_TOKEN_HERE\n"
changes_made += 1
file.write(line)
if changes_made == 0:
print("Slack cleanup complete, no changes made.")
elif changes_made == 1:
print("Slack cleanup complete, 1 change made.")
else:
print("Slack cleanup complete, {} changes made.".format(changes_made))
def clean_firebase_path():
changes_made = 0
for root, dirs, files in os.walk("."):
for file_name in files:
if file_name.endswith(".env") and file_name != "cleanup.py":
file_path = os.path.join(root, file_name)
with open(file_path, 'r') as file:
lines = file.readlines()
with open(file_path, 'w') as file:
for line in lines:
if "FIREBASE_CREDENTIALS=" in line and not "FIREBASE_CREDENTIALS=/path/to/credentials.json" in line:
line = "FIREBASE_CREDENTIALS=/path/to/credentials.json\n"
changes_made += 1
file.write(line)
if changes_made == 0:
print("Firebase cleanup complete, no changes made.")
elif changes_made == 1:
print("Firebase cleanup complete, 1 change made.")
else:
print("Firebase cleanup complete, {} changes made.".format(changes_made))
if __name__ == '__main__':
clean_aws_creds()
clean_slack_creds()
clean_firebase_path()