diff options
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hig.py')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py index b586b6c274..2001ff424f 100644 --- a/bitbake/lib/bb/ui/crumbs/hig.py +++ b/bitbake/lib/bb/ui/crumbs/hig.py | |||
@@ -28,6 +28,7 @@ import os | |||
28 | import re | 28 | import re |
29 | import shlex | 29 | import shlex |
30 | import subprocess | 30 | import subprocess |
31 | import tempfile | ||
31 | from bb.ui.crumbs.hobcolor import HobColors | 32 | from bb.ui.crumbs.hobcolor import HobColors |
32 | from bb.ui.crumbs.hobwidget import hcc, hic, HobViewTable, HobInfoButton, HobButton, HobAltButton, HobIconChecker | 33 | from bb.ui.crumbs.hobwidget import hcc, hic, HobViewTable, HobInfoButton, HobButton, HobAltButton, HobIconChecker |
33 | from bb.ui.crumbs.progressbar import HobProgressBar | 34 | from bb.ui.crumbs.progressbar import HobProgressBar |
@@ -869,21 +870,16 @@ class DeployImageDialog (CrumbsDialog): | |||
869 | if combo_item and combo_item != self.__dummy_usb__ and self.image_path: | 870 | if combo_item and combo_item != self.__dummy_usb__ and self.image_path: |
870 | cmdline = bb.ui.crumbs.utils.which_terminal() | 871 | cmdline = bb.ui.crumbs.utils.which_terminal() |
871 | if cmdline: | 872 | if cmdline: |
872 | tmpname = os.tmpnam() | 873 | tmpfile = tempfile.NamedTemporaryFile() |
873 | cmdline += "\"sudo dd if=" + self.image_path + \ | 874 | cmdline += "\"sudo dd if=" + self.image_path + \ |
874 | " of=" + combo_item + "; echo $? > " + tmpname + "\"" | 875 | " of=" + combo_item + "; echo $? > " + tmpfile.name + "\"" |
875 | subprocess.call(shlex.split(cmdline)) | 876 | subprocess.call(shlex.split(cmdline)) |
876 | 877 | ||
877 | # if file tmpname not exists, that means there is something wrong with xterm | 878 | if int(tmpfile.readline().strip()) == 0: |
878 | # user can get the error message from xterm so no more warning need. | 879 | lbl = "<b>Deploy image successfully.</b>" |
879 | if os.path.exists(tmpname): | 880 | else: |
880 | tmpfile = open(tmpname) | 881 | lbl = "<b>Failed to deploy image.</b>\nPlease check image <b>%s</b> exists and USB device <b>%s</b> is writable." % (self.image_path, combo_item) |
881 | if int(tmpfile.readline().strip()) == 0: | 882 | tmpfile.close() |
882 | lbl = "<b>Deploy image successfully.</b>" | ||
883 | else: | ||
884 | lbl = "<b>Failed to deploy image.</b>\nPlease check image <b>%s</b> exists and USB device <b>%s</b> is writable." % (self.image_path, combo_item) | ||
885 | tmpfile.close() | ||
886 | os.remove(tmpname) | ||
887 | else: | 883 | else: |
888 | if not self.image_path: | 884 | if not self.image_path: |
889 | lbl = "<b>No selection made.</b>\nYou have not selected an image to deploy." | 885 | lbl = "<b>No selection made.</b>\nYou have not selected an image to deploy." |