Skip to content

Commit 18c0ccb

Browse files
Fixed bug where menu would crash when no build options selected
1 parent 313faf2 commit 18c0ccb

File tree

3 files changed

+76
-73
lines changed

3 files changed

+76
-73
lines changed

.templates/otbr/build.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,25 @@ def preBuild():
140140
# #####################################
141141

142142
def checkForIssues():
143-
with open("{serviceDir}{buildSettings}".format(serviceDir=serviceService, buildSettings=buildSettingsFileName)) as objHardwareListFile:
144-
otbrYamlBuildOptions = yaml.load(objHardwareListFile)
143+
passed = True
144+
try:
145+
with open("{serviceDir}{buildSettings}".format(serviceDir=serviceService, buildSettings=buildSettingsFileName)) as objHardwareListFile:
146+
otbrYamlBuildOptions = yaml.load(objHardwareListFile)
147+
if not otbrYamlBuildOptions["hardware"] or len(otbrYamlBuildOptions["hardware"]) < 1:
148+
issues["hardware"] = "No Thread radio selected."
149+
passed = False
150+
if otbrYamlBuildOptions["hardware"] and len(otbrYamlBuildOptions["hardware"]) > 1:
151+
issues["hardware"] = "Two or more thread radios selected. The first listed one will be used"
152+
passed = False
153+
except Exception as err:
154+
issues["hardware"] = "No Thread radio selected."
145155
for (index, serviceName) in enumerate(dockerComposeServicesYaml):
146156
if not currentServiceName == serviceName: # Skip self
147157
currentServicePorts = getExternalPorts(currentServiceName, dockerComposeServicesYaml)
148158
portConflicts = checkPortConflicts(serviceName, currentServicePorts, dockerComposeServicesYaml)
149159
if (len(portConflicts) > 0):
150160
issues["portConflicts"] = portConflicts
151-
152-
print(otbrYamlBuildOptions["hardware"])
153-
if not otbrYamlBuildOptions["hardware"] or len(otbrYamlBuildOptions["hardware"]) < 1:
154-
issues["hardware"] = "No Thread radio selected."
155-
if otbrYamlBuildOptions["hardware"] and len(otbrYamlBuildOptions["hardware"]) > 1:
156-
issues["hardware"] = "Two or more thread radios selected. The first listed one will be used"
157-
158-
159-
161+
passed = False
160162

161163
# #####################################
162164
# End Supporting functions

.templates/otbr/service.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ otbr:
1313
stdin_open: true
1414
tty: true
1515
volumes:
16-
- otbr-data:/var/lib/otbr
17-
- otbr-wpantund:/etc/wpantund.conf
18-
- otbr-config:/etc/otbr
16+
- ./volumes/otbr/data:/var/lib/otbr
17+
- ./volumes/otbr/wpantund:/etc/wpantund.conf
18+
- ./volumes/otbr/config:/etc/otbr
1919
ports:
2020
- "80:8283"
2121
command: >

.templates/python-matter-server/build.py

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -97,76 +97,77 @@ def postBuild():
9797
def preBuild():
9898
global dockerComposeServicesYaml
9999
global currentServiceName
100-
with open("{serviceDir}{buildSettings}".format(serviceDir=serviceService, buildSettings=buildSettingsFileName)) as objExtrasListFile:
101-
pythonMatterServerYamlBuildOptions = yaml.load(objExtrasListFile)
102-
103-
with open((r'%s/' % serviceTemplate) + servicesFileName) as objServiceFile:
104-
serviceYamlTemplate = yaml.load(objServiceFile)
105-
106-
oldBuildCache = {}
107100
try:
108-
with open(r'%s' % buildCache) as objBuildCache:
109-
oldBuildCache = yaml.load(objBuildCache)
110-
except:
111-
pass
112-
101+
with open("{serviceDir}{buildSettings}".format(serviceDir=serviceService, buildSettings=buildSettingsFileName)) as objExtrasListFile:
102+
pythonMatterServerYamlBuildOptions = yaml.load(objExtrasListFile)
103+
104+
with open((r'%s/' % serviceTemplate) + servicesFileName) as objServiceFile:
105+
serviceYamlTemplate = yaml.load(objServiceFile)
106+
107+
oldBuildCache = {}
108+
try:
109+
with open(r'%s' % buildCache) as objBuildCache:
110+
oldBuildCache = yaml.load(objBuildCache)
111+
except:
112+
pass
113113

114-
buildCacheServices = {}
115-
if "services" in oldBuildCache:
116-
buildCacheServices = oldBuildCache["services"]
117-
118-
if not os.path.exists(serviceService):
119-
os.makedirs(serviceService, exist_ok=True)
120-
121-
try:
122-
if currentServiceName in dockerComposeServicesYaml:
123-
if pythonMatterServerYamlBuildOptions["extras"]:
124-
if "Mount Bluetooth: /run/dbus" in pythonMatterServerYamlBuildOptions["extras"]:
125-
if not "/run/dbus:/run/dbus:ro" in dockerComposeServicesYaml[currentServiceName]["volumes"]:
126-
dockerComposeServicesYaml[currentServiceName]["volumes"].append("/run/dbus:/run/dbus:ro")
127-
128-
currentCommand = dockerComposeServicesYaml[currentServiceName]["command"]
129-
if not "--bluetooth-adapter 0\n" in currentCommand:
130-
newCommand = currentCommand + "--bluetooth-adapter 0\n"
131-
dockerComposeServicesYaml[currentServiceName]["command"] = newCommand
132-
else:
133-
if "/run/dbus:/run/dbus:ro" in dockerComposeServicesYaml[currentServiceName]["volumes"]:
134-
dockerComposeServicesYaml[currentServiceName]["volumes"].remove("/run/dbus:/run/dbus:ro")
135-
136-
currentCommand = dockerComposeServicesYaml[currentServiceName]["command"]
137-
if "--bluetooth-adapter 0\n" in currentCommand:
138-
newCommand = currentCommand.replace("--bluetooth-adapter 0\n", "")
114+
buildCacheServices = {}
115+
if "services" in oldBuildCache:
116+
buildCacheServices = oldBuildCache["services"]
117+
118+
if not os.path.exists(serviceService):
119+
os.makedirs(serviceService, exist_ok=True)
120+
121+
try:
122+
if currentServiceName in dockerComposeServicesYaml:
123+
if pythonMatterServerYamlBuildOptions["extras"]:
124+
if "Mount Bluetooth: /run/dbus" in pythonMatterServerYamlBuildOptions["extras"]:
125+
if not "/run/dbus:/run/dbus:ro" in dockerComposeServicesYaml[currentServiceName]["volumes"]:
126+
dockerComposeServicesYaml[currentServiceName]["volumes"].append("/run/dbus:/run/dbus:ro")
127+
128+
currentCommand = dockerComposeServicesYaml[currentServiceName]["command"]
129+
if not "--bluetooth-adapter 0\n" in currentCommand:
130+
newCommand = currentCommand + "--bluetooth-adapter 0\n"
139131
dockerComposeServicesYaml[currentServiceName]["command"] = newCommand
140-
141-
if "Enabled Root Certificates" in pythonMatterServerYamlBuildOptions["extras"]:
142-
currentCommand = dockerComposeServicesYaml[currentServiceName]["command"]
143-
if not "--paa-root-cert-dir /data/credentials\n" in currentCommand:
144-
newCommand = currentCommand + "--paa-root-cert-dir /data/credentials\n"
145-
dockerComposeServicesYaml[currentServiceName]["command"] = newCommand
132+
else:
133+
if "/run/dbus:/run/dbus:ro" in dockerComposeServicesYaml[currentServiceName]["volumes"]:
134+
dockerComposeServicesYaml[currentServiceName]["volumes"].remove("/run/dbus:/run/dbus:ro")
135+
136+
currentCommand = dockerComposeServicesYaml[currentServiceName]["command"]
137+
if "--bluetooth-adapter 0\n" in currentCommand:
138+
newCommand = currentCommand.replace("--bluetooth-adapter 0\n", "")
139+
dockerComposeServicesYaml[currentServiceName]["command"] = newCommand
140+
141+
if "Enabled Root Certificates" in pythonMatterServerYamlBuildOptions["extras"]:
142+
currentCommand = dockerComposeServicesYaml[currentServiceName]["command"]
143+
if not "--paa-root-cert-dir /data/credentials\n" in currentCommand:
144+
newCommand = currentCommand + "--paa-root-cert-dir /data/credentials\n"
145+
dockerComposeServicesYaml[currentServiceName]["command"] = newCommand
146+
else:
147+
currentCommand = dockerComposeServicesYaml[currentServiceName]["command"]
148+
if "--paa-root-cert-dir /data/credentials\n" in currentCommand:
149+
newCommand = currentCommand.replace("--paa-root-cert-dir /data/credentials\n", "")
150+
dockerComposeServicesYaml[currentServiceName]["command"] = newCommand
146151
else:
147152
currentCommand = dockerComposeServicesYaml[currentServiceName]["command"]
148153
if "--paa-root-cert-dir /data/credentials\n" in currentCommand:
149154
newCommand = currentCommand.replace("--paa-root-cert-dir /data/credentials\n", "")
150155
dockerComposeServicesYaml[currentServiceName]["command"] = newCommand
151-
else:
152-
currentCommand = dockerComposeServicesYaml[currentServiceName]["command"]
153-
if "--paa-root-cert-dir /data/credentials\n" in currentCommand:
154-
newCommand = currentCommand.replace("--paa-root-cert-dir /data/credentials\n", "")
155-
dockerComposeServicesYaml[currentServiceName]["command"] = newCommand
156156

157-
if "/run/dbus:/run/dbus:ro" in dockerComposeServicesYaml[currentServiceName]["volumes"]:
158-
dockerComposeServicesYaml[currentServiceName]["volumes"].remove("/run/dbus:/run/dbus:ro")
159-
160-
currentCommand = dockerComposeServicesYaml[currentServiceName]["command"]
161-
if "--bluetooth-adapter 0\n" in currentCommand:
162-
newCommand = currentCommand.replace("--bluetooth-adapter 0\n", "")
163-
dockerComposeServicesYaml[currentServiceName]["command"] = newCommand
157+
if "/run/dbus:/run/dbus:ro" in dockerComposeServicesYaml[currentServiceName]["volumes"]:
158+
dockerComposeServicesYaml[currentServiceName]["volumes"].remove("/run/dbus:/run/dbus:ro")
164159

160+
currentCommand = dockerComposeServicesYaml[currentServiceName]["command"]
161+
if "--bluetooth-adapter 0\n" in currentCommand:
162+
newCommand = currentCommand.replace("--bluetooth-adapter 0\n", "")
163+
dockerComposeServicesYaml[currentServiceName]["command"] = newCommand
165164

166-
except Exception as err:
167-
print("Error setting pythonMatterServer extras: ", err)
168-
time.sleep(10)
169-
return False
165+
except Exception as err:
166+
print("Error setting pythonMatterServer extras: ", err)
167+
time.sleep(10)
168+
return False
169+
except:
170+
pass
170171

171172

172173

0 commit comments

Comments
 (0)