Merge branch 'develop'
[snf-image-creator] / image_creator / dialog_main.py
index e0e4e04..2a56a1c 100644 (file)
@@ -101,6 +101,25 @@ def create_image(d, media, out, tmp):
                    "image": image,
                    "metadata": metadata}
 
+        if image.is_unsupported():
+
+            session['excluded_tasks'] = [-1]
+            session['task_metadata'] = ["EXCLUDE_ALL_TASKS"]
+
+            msg = "The system on the input media is not supported." \
+                "\n\nReason: %s\n\n" \
+                "We highly recommend not to create an image out of this, " \
+                "since the image won't be cleaned up and you will not be " \
+                "able to configure it during the deployment. Press <YES> if " \
+                "you still want to continue with the image creation process." \
+                % image._unsupported
+
+            if not d.yesno(msg, width=WIDTH, defaultno=1, height=12):
+                main_menu(session)
+
+            d.infobox("Thank you for using snf-image-creator. Bye", width=53)
+            return 0
+
         msg = "snf-image-creator detected a %s system on the input media. " \
               "Would you like to run a wizard to assist you through the " \
               "image creation process?\n\nChoose <Wizard> to run the wizard," \
@@ -178,7 +197,7 @@ def _dialog_form(self, text, height=20, width=60, form_height=15, fields=[],
         if len(field[0]) > label_len:
             label_len = len(field[0])
 
-    input_len = width - label_len - 2
+    input_len = width - label_len - 1
 
     line = 1
     for field in fields:
@@ -186,7 +205,7 @@ def _dialog_form(self, text, height=20, width=60, form_height=15, fields=[],
         item = field[1]
         item_len = field[2]
         cmd.extend((label, str(line), str(1), item, str(line),
-                   str(label_len + 2), str(input_len), str(item_len)))
+                   str(label_len + 1), str(input_len), str(item_len)))
         line += 1
 
     code, output = self._perform(*(cmd,), **kwargs)
@@ -199,6 +218,10 @@ def _dialog_form(self, text, height=20, width=60, form_height=15, fields=[],
 
 def main():
 
+    # In OpenSUSE dialog is buggy under xterm
+    if os.environ['TERM'] == 'xterm':
+        os.environ['TERM'] = 'linux'
+
     d = dialog.Dialog(dialog="dialog")
 
     # Add extra button in dialog library