Repository: conjure-up/conjure-up

Issue:
Need warning about small terminal sizes affecting usability

Discussion:

Patch:
diff --git a/conjureup/app.py b/conjureup/app.py
index 2183f65..eab3469 100644
--- a/conjureup/app.py
+++ b/conjureup/app.py
@@ -317,6 +317,16 @@ def main():
         _start()
 
     else:
+        if EventLoop.rows() < 43 or EventLoop.columns() < 132:
+            print("")
+            utils.warning(
+                "conjure-up is best viewed with a terminal geometry of "
+                "at least 132x43. Please increase the size of your terminal "
+                "before starting conjure-up.")
+            print("")
+            acknowledge = input("Do you wish to continue? [Y/n] ")
+            if 'N' in acknowledge or 'n' in acknowledge:
+                sys.exit(1)
         app.ui = ConjureUI()
         EventLoop.build_loop(app.ui, STYLES,
                              unhandled_input=unhandled_input)
diff --git a/conjureup/controllers/clouds/gui.py b/conjureup/controllers/clouds/gui.py
index b63f6d8..8b441ff 100644
--- a/conjureup/controllers/clouds/gui.py
+++ b/conjureup/controllers/clouds/gui.py
@@ -1,7 +1,7 @@
 from conjureup import controllers
 from conjureup.app_config import app
 from conjureup.controllers.clouds.common import list_clouds
-from conjureup.telemetry import track_screen
+from conjureup.telemetry import track_event, track_screen
 from conjureup.ui.views.cloud import CloudView
 
 
@@ -20,6 +20,7 @@ class CloudsController:
 
         """
         app.current_cloud = cloud
+        track_event("Cloud selection", app.current_cloud, "")
         return controllers.use('newcloud').render()
 
     def render(self):
diff --git a/conjureup/ui/views/destroy_confirm.py b/conjureup/ui/views/destroy_confirm.py
index 77683d7..a3226de 100644
--- a/conjureup/ui/views/destroy_confirm.py
+++ b/conjureup/ui/views/destroy_confirm.py
@@ -1,4 +1,5 @@
 import datetime
+
 from urwid import Columns, Filler, Frame, Pile, Text, WidgetWrap
 
 from conjureup.api.models import model_status
diff --git a/ubuntui/ev.py b/ubuntui/ev.py
index 3b5eab5..4c90b84 100644
--- a/ubuntui/ev.py
+++ b/ubuntui/ev.py
@@ -18,23 +18,22 @@ class EventLoop:
     """
     loop = None
     alarms = {}
+    extra_opts = {
+        'screen': urwid.raw_display.Screen(),
+        'handle_mouse': True
+    }
 
     @classmethod
     def build_loop(cls, ui, palette, **kwargs):
         """ Builds eventloop
         """
-        extra_opts = {
-            'screen': urwid.raw_display.Screen(),
-            'handle_mouse': True
-        }
-        extra_opts['screen'].set_terminal_properties(colors=256)
-        extra_opts['screen'].reset_default_terminal_palette()
-        extra_opts.update(**kwargs)
+        cls.extra_opts['screen'].set_terminal_properties(colors=256)
+        cls.extra_opts.update(**kwargs)
         evl = asyncio.get_event_loop()
         cls.loop = urwid.MainLoop(ui, palette,
                                   event_loop=urwid.AsyncioEventLoop(loop=evl),
                                   pop_ups=True,
-                                  **extra_opts)
+                                  **cls.extra_opts)
 
     @classmethod
     def exit(cls, err=0):
@@ -85,3 +84,15 @@ class EventLoop:
             log.exception("Exception in ev.run():")
             raise
         return
+
+    @classmethod
+    def rows(cls):
+        """ Returns rows
+        """
+        return cls.extra_opts['screen'].get_cols_rows()[1]
+
+    @classmethod
+    def columns(cls):
+        """ Returns columns
+        """
+        return cls.extra_opts['screen'].get_cols_rows()[0]


Test patch:
diff --git a/test/test_controllers_clouds_gui.py b/test/test_controllers_clouds_gui.py
index 933f81a..6798cfc 100644
--- a/test/test_controllers_clouds_gui.py
+++ b/test/test_controllers_clouds_gui.py
@@ -67,10 +67,15 @@ class CloudsGUIFinishTestCase(unittest.TestCase):
 
         self.cloudname = 'testcloudname'
 
+        self.track_event_patcher = patch(
+            'conjureup.controllers.clouds.gui.track_event')
+        self.mock_track_event = self.track_event_patcher.start()
+
     def tearDown(self):
         self.controllers_patcher.stop()
         self.render_patcher.stop()
         self.app_patcher.stop()
+        self.track_event_patcher.stop()
 
     def test_finish_no_controller(self):
         "clouds.finish without existing controller"