ogClonningEngine
Last change
on this file since 937f1b5 was
937f1b5,
checked in by Antonio Emmanuel Guerrero Silva <aguerrero@…>, 7 months ago
|
refs #693 Code migration from the scripts directory
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | import sys |
---|
2 | import os |
---|
3 | import re |
---|
4 | import subprocess |
---|
5 | |
---|
6 | #!/usr/bin/env python3 |
---|
7 | |
---|
8 | def main(): |
---|
9 | PROG = os.path.basename(__file__) |
---|
10 | REDUCED = "no" |
---|
11 | |
---|
12 | if len(sys.argv) > 1 and sys.argv[1] == "-r": |
---|
13 | REDUCED = "yes" |
---|
14 | sys.argv.pop(1) |
---|
15 | |
---|
16 | if len(sys.argv) != 3: |
---|
17 | og_raise_error(1, f"Usage: {PROG} [-r] ndisk npart") |
---|
18 | |
---|
19 | ndisk = sys.argv[1] |
---|
20 | npart = sys.argv[2] |
---|
21 | |
---|
22 | OGLOG = "/path/to/log" # Replace with actual log path |
---|
23 | SERVERLOGDIR = None |
---|
24 | |
---|
25 | # Simulate the mount command and awk processing |
---|
26 | mounts = subprocess.check_output(['mount']).decode('utf-8') |
---|
27 | for line in mounts.splitlines(): |
---|
28 | parts = line.split() |
---|
29 | if len(parts) > 3 and parts[2] == OGLOG: |
---|
30 | SERVERLOGDIR = parts[1] |
---|
31 | break |
---|
32 | |
---|
33 | if SERVERLOGDIR is None: |
---|
34 | og_raise_error(1, "Could not determine server log directory") |
---|
35 | |
---|
36 | SOFTFILE = f"soft-{og_get_ip_address()}-{ndisk}-{npart}" |
---|
37 | softfile_path = os.path.join(OGLOG, SOFTFILE) |
---|
38 | |
---|
39 | try: |
---|
40 | if REDUCED == "no": |
---|
41 | software_list = og_list_software(ndisk, npart) |
---|
42 | else: |
---|
43 | software_list = "\n".join( |
---|
44 | line for line in og_list_software(ndisk, npart).splitlines() |
---|
45 | if not re.search(r"\(KB[0-9]{6}\)", line) |
---|
46 | ) |
---|
47 | |
---|
48 | with open(softfile_path, 'w') as f: |
---|
49 | f.write(software_list) |
---|
50 | except Exception as e: |
---|
51 | og_raise_error(1, str(e)) |
---|
52 | |
---|
53 | print(softfile_path) |
---|
54 | |
---|
55 | if __name__ == "__main__": |
---|
56 | main() |
---|
Note: See
TracBrowser
for help on using the repository browser.