@@ -33,6 +33,9 @@ def __init__(self):
33
33
self .name_link_pattern = "(usb-[0-9a-zA-Z_-]*_[0-9a-zA-Z]*-.*$)"
34
34
self .mount_media_pattern = "^/[a-zA-Z0-9/]* on (/[a-zA-Z0-9/]*) "
35
35
36
+ self .nlp = re .compile (self .name_link_pattern )
37
+ self .hup = re .compile (self .hex_uuid_pattern )
38
+
36
39
def list_mbeds (self ):
37
40
"""! Returns detailed list of connected mbeds
38
41
@return Returns list of structures with detailed info about each mbed
@@ -174,14 +177,12 @@ def get_disk_hex_ids(self, disk_list):
174
177
@return Returns map of disks and corresponding disks' Hex ids
175
178
@details Uses regular expressions to get Hex strings (TargeTIDs) from list of disks
176
179
"""
177
- nlp = re .compile (self .name_link_pattern )
178
- hup = re .compile (self .hex_uuid_pattern )
179
180
disk_hex_ids = {}
180
181
for dl in disk_list :
181
- m = nlp .search (dl )
182
+ m = self . nlp .search (dl )
182
183
if m and len (m .groups ()):
183
184
disk_link = m .group (1 )
184
- m = hup .search (disk_link )
185
+ m = self . hup .search (disk_link )
185
186
if m and len (m .groups ()):
186
187
disk_hex_ids [m .group (1 )] = disk_link
187
188
return disk_hex_ids
@@ -193,10 +194,9 @@ def get_mbed_serial(self, serial_list, dhi):
193
194
@return Returns None if corresponding serial device is not found, else returns serial device path
194
195
@details Devices are located in Linux '/dev/' directory structure
195
196
"""
196
- nlp = re .compile (self .name_link_pattern )
197
197
for sl in serial_list :
198
198
if dhi in sl :
199
- m = nlp .search (sl )
199
+ m = self . nlp .search (sl )
200
200
if m and len (m .groups ()):
201
201
serial_link = m .group (1 )
202
202
mbed_dev_serial = "/dev/" + self .get_dev_name (serial_link )
0 commit comments