mirror of https://git.48k.eu/ogclient
76 lines
2.2 KiB
Python
76 lines
2.2 KiB
Python
# Copyright (C) 2020-2025 Soleta Networks <info@soleta.eu>
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify it under
|
|
# the terms of the GNU Affero General Public License as published by the
|
|
# Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
from src.utils.probe import os_probe, get_os_family, OSFamily
|
|
from src.utils.fs import mount_mkdir, umount
|
|
from PyQt6.QtGui import QColor
|
|
from src.utils.disk import *
|
|
from src.utils.net import *
|
|
import json
|
|
import os
|
|
|
|
|
|
config_data = {}
|
|
|
|
|
|
def get_boot_os_list():
|
|
return config_data.get('os_list', [])
|
|
|
|
def probe_partitions():
|
|
os_list = []
|
|
for disknum, disk in enumerate(get_disks(), start=1):
|
|
try:
|
|
partitions = get_partition_data(device=f'/dev/{disk}')
|
|
except Exception as e:
|
|
continue
|
|
|
|
for pa in partitions:
|
|
partnum = pa.partno + 1
|
|
mountpoint = pa.padev.replace('dev', 'mnt')
|
|
if mount_mkdir(pa.padev, mountpoint):
|
|
try:
|
|
os_family = get_os_family(mountpoint)
|
|
if os_family == OSFamily.UNKNOWN:
|
|
continue
|
|
os_name = os_probe(mountpoint)
|
|
os_data = {
|
|
'name': os_name,
|
|
'partition': partnum,
|
|
'disk': disknum,
|
|
'os': os_family,
|
|
'image': ''
|
|
}
|
|
os_list.append(os_data)
|
|
finally:
|
|
umount(mountpoint)
|
|
config_data['os_list'] = os_list
|
|
|
|
def get_main_color_theme():
|
|
color_values = config_data.get('color_theme', [49, 69, 106])
|
|
return QColor(*color_values)
|
|
|
|
def side_panel_enabled():
|
|
return config_data.get('side_panel', True) and not is_busy_enabled()
|
|
|
|
def get_status():
|
|
return config_data.get('status', 'idle')
|
|
|
|
def set_status(value):
|
|
config_data['status'] = value
|
|
|
|
def is_busy_enabled():
|
|
return config_data.get('status', 'idle') == 'busy'
|
|
|
|
def get_ip():
|
|
return getifaddr(get_ethernet_interface())
|
|
|
|
def get_log_path():
|
|
return f'/opt/opengnsys/log/{get_ip()}.log'
|
|
|
|
def get_os_columns():
|
|
return config_data.get('os_columns', 2)
|