From c83c7c7a5a5efac5631191fb87e98ad37c5b9379 Mon Sep 17 00:00:00 2001 From: flatsiedatsie Date: Tue, 30 Jan 2024 19:22:39 +0100 Subject: [PATCH] Add files via upload --- pkg/candleappstore_adapter.py | 39 ++++++++++++++++++++++++++++------- pkg/util.py | 4 ++-- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/pkg/candleappstore_adapter.py b/pkg/candleappstore_adapter.py index 3d61c9f..2d2d8d5 100755 --- a/pkg/candleappstore_adapter.py +++ b/pkg/candleappstore_adapter.py @@ -104,10 +104,14 @@ def __init__(self, verbose=True): self.update_free_memory_and_disk_space() - + # Paths self.addon_path = os.path.join(self.user_profile['addonsDir'], self.addon_name) self.data_dir_path = os.path.join(self.user_profile['dataDir'], self.addon_name) + self.hostname_image_target_path = os.path.join(self.user_profile['gatewayDir'],'build','static','images','candle_hostname.svg') + + print("self.user_profile: " + str(self.user_profile)) + # Make sure the data directory exists try: @@ -149,7 +153,9 @@ def __init__(self, verbose=True): #time.sleep(3) # give the network some more time to settle #self.mac = get_own_mac("wlan0") - #self.hostname = get_own_hostname() + + + #print("self.hostname = " + str(self.hostname)) #self.mac_zero = self.mac.replace(self.mac[len(self.mac)-1], '0') @@ -237,15 +243,16 @@ def __init__(self, verbose=True): self.python_minor_version = 11 try: python_check = shell('python3 --version') - print("python_check: " + str(python_check)) + if self.DEBUG: + print("python_check: " + str(python_check)) python_check = python_check.replace("Python ", "") python_version_parts = python_check.split('.') if len(python_version_parts) == 3: - self.python_version = str(python_version_parts[0]) + "." + str(python_version_parts[1]) self.python_minor_version = int(python_version_parts[1]) else: - print("error, python version did not consist of three parts: " + str(python_version_parts)) + if self.DEBUG: + print("error, python version string did not consist of three parts: " + str(python_version_parts)) if self.DEBUG: print("Python version: " + str(self.python_version)) except Exception as ex: @@ -268,8 +275,7 @@ def __init__(self, verbose=True): if self.DEBUG: print("Current working directory: " + str(os.getcwd())) print("End of candle app store adapter init") - - print("doing scans") + print("doing scans") # Find out which addons are really installed, and what their default settings are self.scan_installed_addons() @@ -279,6 +285,25 @@ def __init__(self, verbose=True): self.scan_addons_file_size() + # Write hostname SVG image, which can be displayed in the controller network scanner at https://www.candlesmarthome.com/scanner + try: + self.hostname = get_own_hostname() + self.hostname_svg = '' + str(self.hostname).title() + '' + # self.hostname_icon_svg = '' + str(self.hostname).title() + '' + + if self.DEBUG: + print("self.hostname_svg: " + str(self.hostname_svg)) + with open(self.hostname_image_target_path, 'w') as ff: + ff.write(self.hostname_svg) + if self.DEBUG: + print("wrote hostname SVG image to: " + str(self.hostname_image_target_path)) + if os.path.exists(self.hostname_image_target_path): + os.chmod(self.hostname_image_target_path, 0o644) + + except Exception as ex: + print("Error creating hostname_svg image: " + str(ex)) + + self.ready = True diff --git a/pkg/util.py b/pkg/util.py index 0d8a807..1ac18fa 100755 --- a/pkg/util.py +++ b/pkg/util.py @@ -30,8 +30,8 @@ def get_own_hostname(): hostname = hostname.replace("\n","") return hostname except Exception as ex: - print("Error while checking own hostname! Will default to 'gateway'. Error was: " + str(ex) ) - return "gateway" + print("Error while checking own hostname! Will default to 'candle'. Error was: " + str(ex) ) + return "candle" def get_own_ip():