import os import subprocess import sys #!/usr/bin/env python3 def main(): PROG = os.path.basename(__file__) if len(sys.argv) != 1: og_raise_error(os.getenv('OG_ERR_FORMAT'), f"{os.getenv('MSG_FORMAT')}: {PROG}") # Directory of the server where log files are exported OGLOG = os.getenv('OGLOG') SERVERLOGDIR = None mount_output = subprocess.check_output(['mount']).decode('utf-8') for line in mount_output.splitlines(): parts = line.split() if len(parts) > 3 and parts[3] == OGLOG: SERVERLOGDIR = parts[1] break # List file: hard-IP HARDFILE = f"hard-{og_get_ip_address()}" # Redirect output to the list file try: with open(f"{OGLOG}/{HARDFILE}", 'w') as f: f.write(og_list_hardware_info()) except Exception as e: sys.exit(1) # Output: path of the list file in the repository server # print(f"{SERVERLOGDIR}/{HARDFILE}") print(f"{OGLOG}/{HARDFILE}") if __name__ == "__main__": main()