jdahlin - in flumotion/trunk: . flumotion/admin/text

flumotion-commit at lists.fluendo.com flumotion-commit at lists.fluendo.com
Thu Dec 27 17:53:30 CET 2007


Author: jdahlin
Date: Thu Dec 27 17:52:59 2007
New Revision: 6041

Modified:
   flumotion/trunk/ChangeLog
   flumotion/trunk/flumotion/admin/text/view.py
Log:
2007-12-27  Johan Dahlin  <johan at gnome.org>

	* flumotion/admin/text/view.py (AdminTextView.doRead): Remove
	a particularly evil try/except.



Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog	(original)
+++ flumotion/trunk/ChangeLog	Thu Dec 27 17:52:59 2007
@@ -1,3 +1,8 @@
+2007-12-27  Johan Dahlin  <johan at gnome.org>
+
+	* flumotion/admin/text/view.py (AdminTextView.doRead): Remove
+	a particularly evil try/except.
+
 2007-12-27  Michael Smith <msmith at fluendo.com>
 
 	* flumotion/component/bouncers/htpasswdcrypt.py:

Modified: flumotion/trunk/flumotion/admin/text/view.py
==============================================================================
--- flumotion/trunk/flumotion/admin/text/view.py	(original)
+++ flumotion/trunk/flumotion/admin/text/view.py	Thu Dec 27 17:52:59 2007
@@ -558,82 +558,78 @@
     # act as keyboard input
     def doRead(self):
         """ Input is ready! """
-        try:
-            c = self.stdscr.getch() # read a character
-
-            if c == curses.KEY_BACKSPACE or c == 127:
-                self.inputText = self.inputText[:-1]
-            elif c == curses.KEY_STAB or c == 9:
-                available_commands = self.get_available_completions(self.inputText)
-                if len(available_commands) == 1:
-                    input_split = self.inputText.split()
-                    if len(input_split) > 1:
-                        if not self.inputText.endswith(' '):
-                            input_split.pop()
-                        self.inputText = ' '.join(input_split) + ' ' + available_commands[0]
-                    else:
-                        self.inputText = available_commands[0]
-
-            elif c == curses.KEY_ENTER or c == 10:
-                # run command
-                self.run_command(self.inputText)
-                # re-display status
-                self.display_status()
-                # clear the prompt line
-                self.stdscr.move(self.lasty+1,0)
-                self.stdscr.clrtoeol()
-                self.stdscr.addstr(self.lasty+1,0,'Prompt: ')
-                self.stdscr.refresh()
-                if len(self.nextcommands) > 0:
-                    self.lastcommands = self.lastcommands + self.nextcommands
-                    self.nextcommands = []
-                self.lastcommands.append(self.inputText)
-                self.inputText = ''
-                self.command_result = ''
-            elif c == curses.KEY_UP:
-                lastcommand = ""
-                if len(self.lastcommands) > 0:
-                    lastcommand = self.lastcommands.pop()
-                if self.inputText != "":
-                    self.nextcommands.append(self.inputText)
-                self.inputText = lastcommand
-            elif c == curses.KEY_DOWN:
-                nextcommand = ""
-                if len(self.nextcommands) > 0:
-                    nextcommand = self.nextcommands.pop()
-                if self.inputText != "":
-                    self.lastcommands.append(self.inputText)
-                self.inputText = nextcommand
-            elif c == curses.KEY_PPAGE: # page up
-                if self._first_onscreen_component > 0:
-                    self._first_onscreen_component = \
-                        self._first_onscreen_component - 1
-                    self.show()
-            elif c == curses.KEY_NPAGE: # page down
-                if self._first_onscreen_component < len(self._components) - \
-                        self.max_components_per_page:
-                    self._first_onscreen_component = \
-                        self._first_onscreen_component + 1
-                    self.show()
-
-            else:
-                # too long
-                if len(self.inputText) == self.cols-2: return
-                # add to input text
-                if c<=256:
-                    self.inputText = self.inputText + chr(c)
+        c = self.stdscr.getch() # read a character
 
-            # redisplay status
+        if c == curses.KEY_BACKSPACE or c == 127:
+            self.inputText = self.inputText[:-1]
+        elif c == curses.KEY_STAB or c == 9:
+            available_commands = self.get_available_completions(self.inputText)
+            if len(available_commands) == 1:
+                input_split = self.inputText.split()
+                if len(input_split) > 1:
+                    if not self.inputText.endswith(' '):
+                        input_split.pop()
+                    self.inputText = ' '.join(input_split) + ' ' + available_commands[0]
+                else:
+                    self.inputText = available_commands[0]
+
+        elif c == curses.KEY_ENTER or c == 10:
+            # run command
+            self.run_command(self.inputText)
+            # re-display status
             self.display_status()
-
+            # clear the prompt line
             self.stdscr.move(self.lasty+1,0)
             self.stdscr.clrtoeol()
-
-            self.stdscr.addstr(self.lasty+1, 0,
-                           'Prompt: %s' % self.inputText)
+            self.stdscr.addstr(self.lasty+1,0,'Prompt: ')
             self.stdscr.refresh()
-        except Exception, e:
-            print e
+            if len(self.nextcommands) > 0:
+                self.lastcommands = self.lastcommands + self.nextcommands
+                self.nextcommands = []
+            self.lastcommands.append(self.inputText)
+            self.inputText = ''
+            self.command_result = ''
+        elif c == curses.KEY_UP:
+            lastcommand = ""
+            if len(self.lastcommands) > 0:
+                lastcommand = self.lastcommands.pop()
+            if self.inputText != "":
+                self.nextcommands.append(self.inputText)
+            self.inputText = lastcommand
+        elif c == curses.KEY_DOWN:
+            nextcommand = ""
+            if len(self.nextcommands) > 0:
+                nextcommand = self.nextcommands.pop()
+            if self.inputText != "":
+                self.lastcommands.append(self.inputText)
+            self.inputText = nextcommand
+        elif c == curses.KEY_PPAGE: # page up
+            if self._first_onscreen_component > 0:
+                self._first_onscreen_component = \
+                    self._first_onscreen_component - 1
+                self.show()
+        elif c == curses.KEY_NPAGE: # page down
+            if self._first_onscreen_component < len(self._components) - \
+                    self.max_components_per_page:
+                self._first_onscreen_component = \
+                    self._first_onscreen_component + 1
+                self.show()
+
+        else:
+            # too long
+            if len(self.inputText) == self.cols-2: return
+            # add to input text
+            if c<=256:
+                self.inputText = self.inputText + chr(c)
+
+        # redisplay status
+        self.display_status()
+
+        self.stdscr.move(self.lasty+1,0)
+        self.stdscr.clrtoeol()
+
+        self.stdscr.addstr(self.lasty+1, 0, 'Prompt: %s' % self.inputText)
+        self.stdscr.refresh()
 
 
     # remote calls


More information about the flumotion-commit mailing list