-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpatcher-script.py
More file actions
32 lines (27 loc) · 933 Bytes
/
patcher-script.py
File metadata and controls
32 lines (27 loc) · 933 Bytes
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
patch_script = """
def run_patch_scripts(patch_script_path):
import os
for patch in os.listdir(patch_script_path):
full_patch_file = os.path.join(patch_script_path, patch)
if full_patch_file.endswith('.py') and os.path.isfile(full_patch_file):
with open(full_patch_file, 'r') as f:
try:
exec(f.read())
except:
pass
run_patch_scripts('/patcher-script.d')
"""
def main():
result_list = []
with open("/usr/local/bin/wal-e", "r") as f:
has_patched = False
for line in f:
if not has_patched and line.startswith('import'):
result_list.append(patch_script)
has_patched = True
result_list.append(line)
with open("/usr/local/bin/wal-e", "w") as f:
for line in result_list:
f.write(line)
if __name__ == '__main__':
main()