From 02f71654527a80e3bff556833286514bfa730530 Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos Date: Thu, 3 Jan 2013 14:19:48 +0200 Subject: [PATCH] Fix media selection in snf-mkimage Make sure the user cannot select a directory as input media --- image_creator/dialog_main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/image_creator/dialog_main.py b/image_creator/dialog_main.py index 16282c2..7af17f2 100644 --- a/image_creator/dialog_main.py +++ b/image_creator/dialog_main.py @@ -36,6 +36,7 @@ import dialog import sys import os +import stat import textwrap import signal import optparse @@ -139,11 +140,13 @@ def select_file(d, media): d.msgbox("The file `%s' you choose does not exist." % media, width=SMALL_WIDTH) else: - break + mode = os.stat(media).st_mode + if not stat.S_ISDIR(mode): + break (code, media) = d.fselect(root, 10, 60, extra_button=1, title="Please select an input media.", - extra_label="Running System") + extra_label="Bundle Host") if code in (d.DIALOG_CANCEL, d.DIALOG_ESC): if confirm_exit(d, "You canceled the media selection dialog box."): sys.exit(0) @@ -151,7 +154,7 @@ def select_file(d, media): media = None continue elif code == d.DIALOG_EXTRA: - media = '/' + return '/' return media -- 1.7.10.4