Patchwork [bitbake-devel,2/6] ui/crumbs/hig.py: fix run time error

login
register
mail settings
Submitter Kang Kai
Date June 6, 2012, 9:52 a.m.
Message ID <51b90e87ce488333de3cd279968aaf4807ab4df7.1338976258.git.kai.kang@windriver.com>
Download mbox | patch
Permalink /patch/29273/
State New
Headers show

Comments

Kang Kai - June 6, 2012, 9:52 a.m.
Commit 094742bed2fc01d55f572da946fcfa7a48521401 re-implement the
function popen_read(). If there is no USB device, it crashes with
"ExecutionError: Execution of 'ls /dev/disk/by-id/usb*' failed with exit
code 2:"

Replace popen_read() way with glob module to get the USB devices.

Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
 bitbake/lib/bb/ui/crumbs/hig.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Patch

diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py
index 7c9e73f..893fad4 100644
--- a/bitbake/lib/bb/ui/crumbs/hig.py
+++ b/bitbake/lib/bb/ui/crumbs/hig.py
@@ -20,6 +20,7 @@ 
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
+import glob
 import gtk
 import gobject
 import hashlib
@@ -806,7 +807,7 @@  class DeployImageDialog (CrumbsDialog):
 
     def find_all_usb_devices(self):
         usb_devs = [ os.readlink(u)
-            for u in self.popen_read('ls /dev/disk/by-id/usb*').split()
+            for u in glob.glob('/dev/disk/by-id/usb*')
             if not re.search(r'part\d+', u) ]
         return [ '%s' % u[u.rfind('/')+1:] for u in usb_devs ]