src/eric7/MicroPython/Devices/DeviceBase.py

branch
eric7
changeset 10034
bf2d02317ba6
parent 10022
a95800b414b7
child 10069
435cc5875135
equal deleted inserted replaced
10033:91b0939626ff 10034:bf2d02317ba6
139 if connected: 139 if connected:
140 self._interface = self.microPython.deviceInterface() 140 self._interface = self.microPython.deviceInterface()
141 with contextlib.suppress(OSError): 141 with contextlib.suppress(OSError):
142 self._deviceData = self.__getDeviceData() 142 self._deviceData = self.__getDeviceData()
143 self._deviceData["local_mip"] = ( 143 self._deviceData["local_mip"] = (
144 not self._deviceData["mip"] and not self._deviceData["upip"] 144 not self._deviceData["mip"]
145 and not self._deviceData["upip"]
146 and not self.hasCircuitPython()
145 ) 147 )
146 self._deviceData["wifi"], self._deviceData["wifi_type"] = self.hasWifi() 148 self._deviceData["wifi"], self._deviceData["wifi_type"] = self.hasWifi()
147 self._deviceData["bluetooth"] = self.hasBluetooth() 149 self._deviceData["bluetooth"] = self.hasBluetooth()
148 ( 150 (
149 self._deviceData["ethernet"], 151 self._deviceData["ethernet"],
162 """ 164 """
163 return self._deviceType 165 return self._deviceType
164 166
165 def getDeviceData(self, key=None): 167 def getDeviceData(self, key=None):
166 """ 168 """
167 Public method to get a copy of the determined device data. 169 Public method to get a copy of the determined device data or part of them.
168 170
169 @param key name of the data to get (None to get all data) (defaults to None) 171 @param key name or a list of names of the data to get (None to get all data)
170 @type str (optional) 172 (defaults to None)
173 @type str or list of str (optional)
171 @return dictionary containing the essential device data 174 @return dictionary containing the essential device data
172 @rtype dict 175 @rtype dict or Any
173 """ 176 """
174 if key is None: 177 if key is None:
175 return copy.deepcopy(self._deviceData) 178 return copy.deepcopy(self._deviceData)
179 elif isinstance(key, list):
180 res = {}
181 for name in key:
182 try:
183 res[name] = self._deviceData[name]
184 except KeyError:
185 res[name] = None
186 return res
176 else: 187 else:
177 try: 188 try:
178 return self._deviceData[key] 189 return self._deviceData[key]
179 except KeyError: 190 except KeyError:
180 return None 191 return None

eric ide

mercurial