add usody connection
This commit is contained in:
parent
2de3a3e456
commit
249398f6f3
|
@ -4,3 +4,4 @@ token = '1234'
|
||||||
# path = /path/to/save
|
# path = /path/to/save
|
||||||
# device = your_device_name
|
# device = your_device_name
|
||||||
# # erase = basic
|
# # erase = basic
|
||||||
|
# usody = true
|
||||||
|
|
|
@ -14,6 +14,31 @@ import requests
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
## Usody Functions ##
|
||||||
|
def convert_to_usody_snapshot(snapshot):
|
||||||
|
snapshot["sid"] = str(uuid.uuid4()).split("-")[0]
|
||||||
|
snapshot["software"] = "UsodyOS"
|
||||||
|
snapshot["version"] = "2023.4.0-alpha"
|
||||||
|
snapshot["schema_api"] = "1.0.0"
|
||||||
|
snapshot["settings_version"] = "No Settings Version (NaN)"
|
||||||
|
snapshot["timestamp"] = snapshot["timestamp"].replace(" ", "T")
|
||||||
|
snapshot["tests"] = []
|
||||||
|
snapshot["sanitize"] = []
|
||||||
|
snapshot["hwmd"] = {
|
||||||
|
"hwmd_version": "1.1.0-alpha",
|
||||||
|
"lshw": snapshot["data"].get("lshw", ""),
|
||||||
|
"hwinfo": snapshot["data"].get("hwinfo", ""),
|
||||||
|
"smart": snapshot["data"].get("smart", ""),
|
||||||
|
"dmidecode": snapshot["data"].get("dmidecode", ""),
|
||||||
|
"lspci": snapshot["data"].get("lspci", "")
|
||||||
|
}
|
||||||
|
snapshot.pop("data")
|
||||||
|
snapshot.pop("code")
|
||||||
|
snapshot.pop("erase")
|
||||||
|
|
||||||
|
## End Usody Functions ##
|
||||||
|
|
||||||
|
|
||||||
## Utility Functions ##
|
## Utility Functions ##
|
||||||
def logs(f):
|
def logs(f):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
|
@ -296,17 +321,19 @@ def load_config(config_file="settings.ini"):
|
||||||
# TODO validate that the device exists?
|
# TODO validate that the device exists?
|
||||||
device = config.get('settings', 'device', fallback=None)
|
device = config.get('settings', 'device', fallback=None)
|
||||||
erase = config.get('settings', 'erase', fallback=None)
|
erase = config.get('settings', 'erase', fallback=None)
|
||||||
|
usody = config.get('settings', 'usody', fallback=None)
|
||||||
else:
|
else:
|
||||||
print(f"workbench: ERROR: Config file '{config_file}' not found. Using default values.")
|
print(f"workbench: ERROR: Config file '{config_file}' not found. Using default values.")
|
||||||
path = os.path.join(os.getcwd())
|
path = os.path.join(os.getcwd())
|
||||||
url, token, device, erase = None, None, None, None
|
url, token, device, erase, usody = None, None, None, None, None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'path': path,
|
'path': path,
|
||||||
'url': url,
|
'url': url,
|
||||||
'token': token,
|
'token': token,
|
||||||
'device': device,
|
'device': device,
|
||||||
'erase': erase
|
'erase': erase,
|
||||||
|
'usody': usody
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
|
@ -336,11 +363,14 @@ def main():
|
||||||
all_disks = get_disks()
|
all_disks = get_disks()
|
||||||
snapshot = gen_snapshot(all_disks)
|
snapshot = gen_snapshot(all_disks)
|
||||||
|
|
||||||
if config['erase'] and config['device']:
|
if config['erase'] and config['device'] and not config.get("usody"):
|
||||||
snapshot['erase'] = gen_erase(all_disks, config['erase'], user_disk=config['device'])
|
snapshot['erase'] = gen_erase(all_disks, config['erase'], user_disk=config['device'])
|
||||||
elif config['erase']:
|
elif config['erase'] and not config.get("usody"):
|
||||||
snapshot['erase'] = gen_erase(all_disks, config['erase'])
|
snapshot['erase'] = gen_erase(all_disks, config['erase'])
|
||||||
|
|
||||||
|
if config.get("usody"):
|
||||||
|
convert_to_usody_snapshot(snapshot)
|
||||||
|
|
||||||
save_snapshot_in_disk(snapshot, config['path'])
|
save_snapshot_in_disk(snapshot, config['path'])
|
||||||
|
|
||||||
if config['url']:
|
if config['url']:
|
||||||
|
|
Loading…
Reference in New Issue