source: client/shared/scripts/listHardwareInfo.py @ 937f1b5

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.0 KB
Line 
1import os
2import subprocess
3import sys
4
5#!/usr/bin/env python3
6
7def main():
8    PROG = os.path.basename(__file__)
9    if len(sys.argv) != 1:
10        og_raise_error(os.getenv('OG_ERR_FORMAT'), f"{os.getenv('MSG_FORMAT')}: {PROG}")
11
12    # Directory of the server where log files are exported
13    OGLOG = os.getenv('OGLOG')
14    SERVERLOGDIR = None
15    mount_output = subprocess.check_output(['mount']).decode('utf-8')
16    for line in mount_output.splitlines():
17        parts = line.split()
18        if len(parts) > 3 and parts[3] == OGLOG:
19            SERVERLOGDIR = parts[1]
20            break
21
22    # List file: hard-IP
23    HARDFILE = f"hard-{og_get_ip_address()}"
24    # Redirect output to the list file
25    try:
26        with open(f"{OGLOG}/{HARDFILE}", 'w') as f:
27            f.write(og_list_hardware_info())
28    except Exception as e:
29        sys.exit(1)
30
31    # Output: path of the list file in the repository server
32    # print(f"{SERVERLOGDIR}/{HARDFILE}")
33    print(f"{OGLOG}/{HARDFILE}")
34
35if __name__ == "__main__":
36    main()
Note: See TracBrowser for help on using the repository browser.