[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH 07/10] Removed Newt Syrup files that were still in the VMMTUI codebase.



From: "Darryl L. Pierce" <dpierce redhat com>

---
 src/virtManagerTui/configscreen.py |  326 ------------------------------------
 src/virtManagerTui/menuscreen.py   |   63 -------
 src/virtManagerTui/utils.py        |   38 ----
 3 files changed, 0 insertions(+), 427 deletions(-)
 delete mode 100644 src/virtManagerTui/configscreen.py
 delete mode 100644 src/virtManagerTui/menuscreen.py
 delete mode 100644 src/virtManagerTui/utils.py

diff --git a/src/virtManagerTui/configscreen.py b/src/virtManagerTui/configscreen.py
deleted file mode 100644
index 44059c4..0000000
--- a/src/virtManagerTui/configscreen.py
+++ /dev/null
@@ -1,326 +0,0 @@
-# configscreen.py - Copyright (C) 2009 Red Hat, Inc.
-# Written by Darryl L. Pierce <dpierce redhat com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA  02110-1301, USA.  A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-import snack
-from halworker import HALWorker
-from libvirtworker import LibvirtWorker, VirtManagerConfig
-import traceback
-
-BACK_BUTTON   = "back"
-NEXT_BUTTON   = "next"
-CANCEL_BUTTON = "cancel"
-FINISH_BUTTON = "finish"
-
-class ConfigScreen:
-    '''Enables the creation of navigable, multi-paged configuration screens.'''
-
-    def __init__(self, title):
-        self.__title = title
-        self.__current_page = 1
-        self.__finished = False
-        self.__hal = HALWorker()
-        self.__libvirt = LibvirtWorker()
-        self.__vm_config = VirtManagerConfig()
-
-    def get_title(self):
-        return self.__title
-
-    def get_hal(self):
-        return self.__hal
-
-    def get_libvirt(self):
-        return self.__libvirt
-
-    def get_virt_manager_config(self):
-        return self.__vm_config
-
-    def set_finished(self):
-        self.__finished = True
-
-    def get_elements_for_page(self, screen, page):
-        ignore = screen
-        ignore = page
-        return []
-
-    def page_has_next(self, page):
-        ignore = page
-        return False
-
-    def page_has_finish(self, page):
-        ignore = page
-        return False
-
-    def get_back_page(self, page):
-        if page > 1:
-            return page - 1
-        return page
-
-    def go_back(self):
-        self.__current_page = self.get_back_page(self.__current_page)
-
-    def get_next_page(self, page):
-        return page + 1
-
-    def go_next(self):
-        self.__current_page = self.get_next_page(self.__current_page)
-
-    def validate_input(self, page, errors):
-        ignore = page
-        ignore = errors
-        return True
-
-    def process_input(self, page):
-        ignore = page
-        return
-
-    def get_page_list(self):
-        return []
-
-    def get_current_page(self):
-        return 0
-
-    def start(self):
-        active = True
-        while active and (self.__finished == False):
-            screen = snack.SnackScreen()
-            elements = self.get_elements_for_page(screen, self.__current_page)
-            # TODO: need to set the form height to the number of elements on the page
-            gridform = snack.GridForm(screen, self.get_title(), 2, 2)
-
-            # Here you would put the list of elements
-            # and programmatically set the indicator as
-            # they're rendered
-            pages = self.get_page_list()
-            if len(pages) > 0:
-                leftmenu = snack.Grid(2, len(pages))
-                current_element = 0
-                for page in pages:
-                    leftmenu.setField(snack.Label(page), 0, current_element, anchorLeft = 1)
-                    indicator = " "
-                    if current_element == self.__current_page - 1:
-                        indicator = "<-"
-                    leftmenu.setField(snack.Label(indicator), 1, current_element)
-                    current_element += 1
-                gridform.add(leftmenu, 0, 0, anchorTop = 1, padding = (3, 0, 3, 0))
-
-            content = snack.Grid(1, len(elements) + 1)
-            current_element = 0
-            for element in elements:
-                content.setField(element, 0, current_element)
-                current_element += 1
-            # create the navigation buttons
-            buttons = []
-            if self.__current_page > 1:
-                buttons.append(["Back", BACK_BUTTON, "F11"])
-            if self.page_has_next(self.__current_page):
-                buttons.append(["Next", NEXT_BUTTON, "F12"])
-            if self.page_has_finish(self.__current_page):
-                buttons.append(["Finish", FINISH_BUTTON, "F10"])
-            buttons.append(["Cancel", CANCEL_BUTTON, "ESC"])
-            buttonbar = snack.ButtonBar(screen, buttons)
-            content.setField(buttonbar, 0, current_element, growx = 1)
-            gridform.add(content, 1, 0, anchorTop = 1)
-            current_element += 1
-            try:
-                result = gridform.runOnce()
-                pressed = buttonbar.buttonPressed(result)
-                if pressed == BACK_BUTTON:
-                    self.go_back()
-                elif pressed == NEXT_BUTTON or pressed == FINISH_BUTTON:
-                    errors = []
-                    if self.validate_input(self.__current_page, errors):
-                        self.process_input(self.__current_page)
-                        self.go_next()
-                    else:
-                        error_text = ""
-                        for error in errors:
-                            error_text += "%s\n" % error
-                            snack.ButtonChoiceWindow(screen,
-                                               "There Were Errors",
-                                               error_text,
-                                               buttons = ["OK"])
-                elif pressed == CANCEL_BUTTON:
-                    active = False
-            except Exception, error:
-                snack.ButtonChoiceWindow(screen,
-                                   "An Exception Has Occurred",
-                                   str(error) + "\n" + traceback.format_exc(),
-                                   buttons = ["OK"])
-            screen.popWindow()
-            screen.finish()
-
-class DomainListConfigScreen(ConfigScreen):
-    '''Provides a base class for all config screens that require a domain list.'''
-
-    def __init__(self, title):
-        ConfigScreen.__init__(self, title)
-        self.__has_domains = None
-        self.__domain_list = None
-
-    def get_domain_list_page(self, screen, defined=True, created=True):
-        ignore = screen
-        domuuids = self.get_libvirt().list_domains(defined, created)
-        self.__has_domains = bool(domuuids)
-        result = None
-
-        if self.__has_domains:
-            self.__domain_list = snack.Listbox(0)
-            for uuid in domuuids:
-                domain = self.get_libvirt().get_domain(uuid)
-
-                # dom is a vmmDomain
-                self.__domain_list.append(domain.get_name(), domain)
-            result = [self.__domain_list]
-        else:
-            grid = snack.Grid(1, 1)
-            grid.setField(snack.Label("There are no domains available."), 0, 0)
-            result = [grid]
-
-        return result
-
-    def get_selected_domain(self):
-        return self.__domain_list.current()
-
-    def has_selectable_domains(self):
-        return self.__has_domains
-
-class NetworkListConfigScreen(ConfigScreen):
-    '''Provides a base class for all config screens that require a network list.'''
-
-    def __init__(self, title):
-        ConfigScreen.__init__(self, title)
-        self.__has_networks = None
-        self.__network_list = None
-
-    def get_network_list_page(self, screen, defined=True, started=True):
-        ignore = screen
-        uuids = self.get_libvirt().list_networks(defined, started)
-        result = None
-
-        if len(uuids) > 0:
-            self.__has_networks = True
-            self.__network_list = snack.Listbox(0)
-            for uuid in uuids:
-                network = self.get_libvirt().get_network(uuid)
-                self.__network_list.append(uuid, network.get_name())
-            result = self.__network_list
-        else:
-            self.__has_networks = False
-            result = snack.Label("There are no networks available.")
-        grid = snack.Grid(1, 1)
-        grid.setField(result, 0, 0)
-        return [snack.Label("Network List"),
-                grid]
-
-    def get_selected_network(self):
-        uuid = self.__network_list.current()
-        return self.get_libvirt().get_network(uuid)
-
-    def has_selectable_networks(self):
-        return self.__has_networks
-
-class StorageListConfigScreen(ConfigScreen):
-    '''Provides a base class for any configuration screen that deals with storage pool lists.'''
-
-    def __init__(self, title):
-        ConfigScreen.__init__(self, title)
-        self.__has_pools = None
-        self.__pools_list = None
-        self.__has_volumes = None
-        self.__volumes_list = None
-
-    def get_storage_pool_list_page(self, screen, defined=True, created=True):
-        ignore = screen
-        pools = self.get_libvirt().list_storage_pools(defined=defined, created=created)
-        if len(pools) > 0:
-            self.__has_pools = True
-            self.__pools_list = snack.Listbox(0)
-            for pool in pools:
-                self.__pools_list.append(pool, pool)
-            result = self.__pools_list
-        else:
-            self.__has_pools = False
-            result = snack.Label("There are no storage pools available.")
-        grid = snack.Grid(1, 1)
-        grid.setField(result, 0, 0)
-        return [snack.Label("Storage Pool List"),
-                grid]
-
-    def get_selected_pool(self):
-        return self.__pools_list.current()
-
-    def has_selectable_pools(self):
-        return self.__has_pools
-
-    def get_storage_volume_list_page(self, screen):
-        '''Requires that self.__pools_list have a selected element.'''
-        ignore = screen
-        pool = self.get_libvirt().get_storage_pool(self.get_selected_pool())
-        if len(pool.listVolumes()) > 0:
-            self.__has_volumes = True
-            self.__volumes_list = snack.Listbox(0)
-            for volname in pool.listVolumes():
-                volume = pool.storageVolLookupByName(volname)
-                self.__volumes_list.append("%s (%0.2f GB)" % (volume.name(), volume.info()[2] / 1024**3), volume.name())
-            result = self.__volumes_list
-        else:
-            self.__has_volumes = False
-            result = snack.Label("There are no storage volumes available.")
-        grid = snack.Grid(1, 1)
-        grid.setField(result, 0, 0)
-        return [snack.Label("Storage Volume List"),
-                grid]
-
-    def get_selected_volume(self):
-        return self.__volumes_list.current()
-
-    def has_selectable_volumes(self):
-        return self.__has_volumes
-
-class HostListConfigScreen(ConfigScreen):
-    '''Provides a base class for working with lists of libvirt hosts.'''
-
-    def __init__(self, title):
-        ConfigScreen.__init__(self, title)
-        self.__has_connections = None
-        self.__connection_list = None
-
-    def get_connection_list_page(self, screen):
-        ignore = screen
-        connections = self.get_virt_manager_config().get_connection_list()
-        result = None
-
-        if len(connections) > 0:
-            self.__has_connections = True
-            self.__connection_list = snack.Listbox(0)
-            for connection in connections:
-                self.__connection_list.append(connection, connection)
-            result = self.__connection_list
-        else:
-            self.__has_connections = False
-            result = snack.Label("There are no defined connections.")
-        grid = snack.Grid(1, 1)
-        grid.setField(result, 0, 0)
-        return [snack.Label("Host List"),
-                grid]
-
-    def get_selected_connection(self):
-        return self.__connection_list.current()
-
-    def has_selectable_connections(self):
-        return self.__has_connections
diff --git a/src/virtManagerTui/menuscreen.py b/src/virtManagerTui/menuscreen.py
deleted file mode 100644
index 84ca607..0000000
--- a/src/virtManagerTui/menuscreen.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# mainmenu.py - Copyright (C) 2009 Red Hat, Inc.
-# Written by Darryl L. Pierce <dpierce redhat com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA  02110-1301, USA.  A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-import snack
-import traceback
-
-import logging
-
-EXIT_MENU = 99
-
-class MenuScreen:
-    def __init__(self, title):
-        self.__title = title
-
-    def get_menu_items(self):
-        raise NotImplementedError()
-
-    def handle_selection(self, item):
-        raise NotImplementedError()
-
-    def start(self):
-        finished = False
-        while finished == False:
-            screen = snack.SnackScreen()
-            menu = snack.Listbox(height = 0, width = 0, returnExit = 1)
-            for menu_item in self.get_menu_items():
-                menu.append(menu_item[0], menu_item[1])
-            menu.append("Exit Menu", EXIT_MENU)
-            gridform = snack.GridForm(screen, self.__title, 1, 4)
-            gridform.add(menu, 0, 0)
-            result = gridform.run()
-            screen.popWindow()
-            screen.finish()
-
-            try:
-                if result.current() == EXIT_MENU:
-                    finished = True
-                else: self.handle_selection(result.current())
-            except Exception, error:
-                screen = snack.SnackScreen()
-                logging.info("An exception occurred: %s" % str(error))
-                snack.ButtonChoiceWindow(screen,
-                                   "An Exception Has Occurred",
-                                   str(error) + "\n" + traceback.format_exc(),
-                                   buttons = ["OK"])
-                screen.popWindow()
-                screen.finish()
-                finished = True
diff --git a/src/virtManagerTui/utils.py b/src/virtManagerTui/utils.py
deleted file mode 100644
index 8eddcaa..0000000
--- a/src/virtManagerTui/utils.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# definedomain.py - Copyright (C) 2009 Red Hat, Inc.
-# Written by Darryl L. Pierce <dpierce redhat com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA  02110-1301, USA.  A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-import re
-
-def string_is_not_blank(value):
-    if len(value) > 0:
-        return True
-    return False
-
-def string_has_no_spaces(value):
-    if re.match("^[a-zA-Z0-9_]*$", value):
-        return True
-    return False
-
-def size_as_mb_or_gb(size):
-    '''Takes a size value in bytes and returns it as either a
-    value in megabytes or gigabytes.'''
-    if size / 1024.0**3 < 1.0:
-        result = "%0.2f MB" % (size / 1024.0**2)
-    else:
-        result = "%0.2f GB" % (size / 1024.0**3)
-    return result
-- 
1.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]