@@ -97,76 +97,77 @@ def postBuild():
97
97
def preBuild ():
98
98
global dockerComposeServicesYaml
99
99
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 = {}
107
100
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
113
113
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 "
139
131
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
146
151
else :
147
152
currentCommand = dockerComposeServicesYaml [currentServiceName ]["command" ]
148
153
if "--paa-root-cert-dir /data/credentials\n " in currentCommand :
149
154
newCommand = currentCommand .replace ("--paa-root-cert-dir /data/credentials\n " , "" )
150
155
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
156
156
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" )
164
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
165
164
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
170
171
171
172
172
173
0 commit comments