예제 #1
0
 def _show(self):
     '''Display the static paragraph WELCOME_TEXT and all
        applicable bullet items'''
     sc_options = get_sc_options_from_doc()
     max_width = self.win_size_x - WelcomeScreen.INDENT - 1
     text = convert_paragraph(WelcomeScreen.WELCOME_TEXT, max_width)
     # list configuration groups in a comma-separated list with
     # bullet on first line and indentation on subsequent lines
     grouplist = list()
     if configure_group(SC_GROUP_NETWORK):
         grouplist.append(_("network"))
     elif configure_group(SC_GROUP_IDENTITY):
         grouplist.append(_("system hostname"))
     if configure_group(SC_GROUP_LOCATION):
         grouplist.append(_("time zone"))
     if configure_group(SC_GROUP_DATETIME):
         grouplist.append(_("date and time"))
     if configure_group(SC_GROUP_USERS):
         grouplist.append(_("user and root accounts"))
     if configure_group(SC_GROUP_NS):
         grouplist.append(_("name services"))
     grouplist = ", ".join(grouplist)
     grouplist = convert_paragraph(grouplist,
                                   max_width - len(WelcomeScreen.BULLET))
     for ln in range(len(grouplist)):
         if ln == 0:
             text.append(WelcomeScreen.BULLET + grouplist[ln])
         else:
             text.append(WelcomeScreen.BULLET_INDENT + grouplist[ln])
     # display navigation instructions and profile path
     fmt = {"scprof": sc_options.profile}
     text.extend(convert_paragraph(WelcomeScreen.NAVIPRO_TEXT % fmt,
                                   max_width))
     # indent and align while bulletting
     for bullet in WelcomeScreen.BULLET_ITEMS:
         btext = convert_paragraph(bullet,
                                   max_width - len(WelcomeScreen.BULLET))
         for ln in range(len(btext)):
             if ln == 0:
                 text.append(WelcomeScreen.BULLET + btext[ln])
             else:
                 text.append(WelcomeScreen.BULLET_INDENT + btext[ln])
     # prepare welcome text in entire window for scrolling
     area = WindowArea(x_loc=0, y_loc=1, scrollable_lines=(len(text) + 1))
     area.lines = self.win_size_y - 1
     area.columns = self.win_size_x
     scroll_region = ScrollWindow(area, window=self.center_win)
     scroll_region.add_paragraph(text, start_x=WelcomeScreen.INDENT)
     self.center_win.activate_object(scroll_region)
예제 #2
0
 def _show(self):
     '''Display the static paragraph WELCOME_TEXT and all
        applicable bullet items'''
     sc_options = get_sc_options_from_doc()
     max_width = self.win_size_x - WelcomeScreen.INDENT - 1
     text = convert_paragraph(WelcomeScreen.WELCOME_TEXT, max_width)
     # list configuration groups in a comma-separated list with
     # bullet on first line and indentation on subsequent lines
     grouplist = list()
     if configure_group(SC_GROUP_NETWORK):
         grouplist.append(_("network"))
     elif configure_group(SC_GROUP_IDENTITY):
         grouplist.append(_("system hostname"))
     if configure_group(SC_GROUP_LOCATION):
         grouplist.append(_("time zone"))
     if configure_group(SC_GROUP_DATETIME):
         grouplist.append(_("date and time"))
     if configure_group(SC_GROUP_USERS):
         grouplist.append(_("user and root accounts"))
     if configure_group(SC_GROUP_NS):
         grouplist.append(_("name services"))
     grouplist = ", ".join(grouplist)
     grouplist = convert_paragraph(grouplist,
                                   max_width - len(WelcomeScreen.BULLET))
     for ln in range(len(grouplist)):
         if ln == 0:
             text.append(WelcomeScreen.BULLET + grouplist[ln])
         else:
             text.append(WelcomeScreen.BULLET_INDENT + grouplist[ln])
     # display navigation instructions and profile path
     fmt = {"scprof": sc_options.profile}
     text.extend(convert_paragraph(WelcomeScreen.NAVIPRO_TEXT % fmt,
                                   max_width))
     # indent and align while bulletting
     for bullet in WelcomeScreen.BULLET_ITEMS:
         btext = convert_paragraph(bullet,
                                   max_width - len(WelcomeScreen.BULLET))
         for ln in range(len(btext)):
             if ln == 0:
                 text.append(WelcomeScreen.BULLET + btext[ln])
             else:
                 text.append(WelcomeScreen.BULLET_INDENT + btext[ln])
     # prepare welcome text in entire window for scrolling
     area = WindowArea(x_loc=0, y_loc=1, scrollable_lines=(len(text) + 1))
     area.lines = self.win_size_y - 1
     area.columns = self.win_size_x
     scroll_region = ScrollWindow(area, window=self.center_win)
     scroll_region.add_paragraph(text, start_x=WelcomeScreen.INDENT)
     self.center_win.activate_object(scroll_region)
예제 #3
0
    def _show(self):
        '''Prepare a text summary and display it to the user in a ScrollWindow
        
        '''

        global LOGGER
        LOGGER = logging.getLogger(INSTALL_LOGGER_NAME)

        self.sysconfig = solaris_install.sysconfig.profile.from_engine()

        y_loc = 1
        y_loc += self.center_win.add_paragraph(SummaryScreen.PARAGRAPH, y_loc)

        y_loc += 1
        summary_text = self.build_summary()

        LOGGER.info(
            "The following configuration is used for "
            "installation: %s\n", summary_text)
        # Wrap the summary text, accounting for the INDENT (used below in
        # the call to add_paragraph)
        max_chars = self.win_size_x - SummaryScreen.INDENT - 1
        summary_text = convert_paragraph(summary_text, max_chars)
        area = WindowArea(x_loc=0,
                          y_loc=y_loc,
                          scrollable_lines=(len(summary_text) + 1))
        area.lines = self.win_size_y - y_loc
        area.columns = self.win_size_x
        scroll_region = ScrollWindow(area, window=self.center_win)
        scroll_region.add_paragraph(summary_text, start_x=SummaryScreen.INDENT)

        self.center_win.activate_object(scroll_region)
예제 #4
0
    def display_help(self):
        '''Display the single file help screen'''
        # customize header
        help_header = "%s: %s"
        terminalui.LOGGER.debug("self.screen is =%s", self.screen)
        if self.screen in self.help_dict:
            help_header = help_header % (_("Help"),
                                         self.help_dict[self.screen][1])
            help_text = self.get_help_text(self.help_dict[self.screen][0])
        else:
            help_header = help_header % (_("Help"), _("Not Available"))
            help_text = _("Help for this screen is not available")

        self.main_win.set_header_text(help_header)

        help_text = convert_paragraph(help_text, self.win_size_x - 5)
        terminalui.LOGGER.debug("help_text #lines=%d, text is \n%s",
                                len(help_text), help_text)
        area = WindowArea(x_loc=0,
                          y_loc=1,
                          scrollable_lines=(len(help_text) + 1))
        area.lines = self.win_size_y - 1
        area.columns = self.win_size_x
        self.scroll_region = ScrollWindow(area, window=self.center_win)
        self.scroll_region.add_paragraph(help_text, start_x=(area.x_loc + 3))
        self.center_win.activate_object(self.scroll_region)
예제 #5
0
    def _show(self):
        '''Prepare a text summary and display it to the user in a ScrollWindow
        
        '''

        global LOGGER
        LOGGER = logging.getLogger(INSTALL_LOGGER_NAME)
        
        self.sysconfig = solaris_install.sysconfig.profile.from_engine()
        
        y_loc = 1
        y_loc += self.center_win.add_paragraph(SummaryScreen.PARAGRAPH, y_loc)
        
        y_loc += 1
        summary_text = self.build_summary()

        LOGGER.info("The following configuration is used for "
                    "installation: %s\n", summary_text)
        # Wrap the summary text, accounting for the INDENT (used below in
        # the call to add_paragraph)
        max_chars = self.win_size_x - SummaryScreen.INDENT - 1
        summary_text = convert_paragraph(summary_text, max_chars)
        area = WindowArea(x_loc=0, y_loc=y_loc,
                          scrollable_lines=(len(summary_text) + 1))
        area.lines = self.win_size_y - y_loc
        area.columns = self.win_size_x
        scroll_region = ScrollWindow(area, window=self.center_win)
        scroll_region.add_paragraph(summary_text, start_x=SummaryScreen.INDENT)
        
        self.center_win.activate_object(scroll_region)
예제 #6
0
 def get_log_data(self):
     '''Attempt to read in the install log file. If an error occurs,
     the log_data is set to a string explaining the cause, if possible.
     
     '''
     if self.log_data is None:
         try:
             with open(self.install_data.log_location) as log_file:
                 log_data = log_file.read()
         except (OSError, IOError) as error:
             self.log_data = _("Could not read log file:\n\t%s") % \
                               error.strerror
         max_chars = self.win_size_x - 4
         self.log_data = convert_paragraph(log_data, max_chars)
     return self.log_data
예제 #7
0
    def add_paragraph(self, text, start_y=0, start_x=0, max_y=None,
                      max_x=None):
        '''Add a block of text to the window

        Add a paragraph to the screen. If a string is passed in, it is
        converted using convert_paragraph. If a list of strings is passed in,
        each string will fit in the space alloted (long lines will be
        truncated). Any lines that would be printed past max_y will not be
        printed.

        The number of lines used is returned.

        '''
        terminalui.LOGGER.log(LOG_LEVEL_INPUT, "add_paragraph: start_y=%d, "
                              "start_x=%d, max_y=%s, max_x=%s",
                              start_y, start_x, max_y, max_x)
        win_size_y, win_size_x = self.window.getmaxyx()
        start_y += self.border_size[0]
        if max_y is None:
            max_y = win_size_y - start_y - self.border_size[0]
        if max_x is None:
            max_x = win_size_x
        max_chars = max_x - start_x - self.border_size[1] * 2
        y_index = start_y
        if isinstance(text, basestring):
            text = convert_paragraph(text, max_chars)
        for line in text:
            terminalui.LOGGER.log(LOG_LEVEL_INPUT,
                                  "add_paragraph:add_text: y_index=%d, "
                                  "line=%s\n", y_index, line)
            self.add_text(line, y_index, start_x, max_chars)
            y_index += 1
            if y_index > max_y + start_y:
                terminalui.LOGGER.warn("Could not fit all text in space "
                                       "for the paragraph. Last line:\n%s",
                                       line)
                break
        return y_index - start_y
예제 #8
0
    def _show(self):
        '''Prepare a text summary from the DOC and display it
        to the user in a ScrollWindow

        '''
        y_loc = 1
        y_loc += self.center_win.add_paragraph(SummaryScreen.PARAGRAPH, y_loc)

        y_loc += 1
        self.sysconfig = solaris_install.sysconfig.profile.from_engine()
        summary_text = self.build_summary()
        # Wrap the summary text, accounting for the INDENT (used below in
        # the call to add_paragraph)
        max_chars = self.win_size_x - SummaryScreen.INDENT - 1
        summary_text = convert_paragraph(summary_text, max_chars)
        area = WindowArea(x_loc=0, y_loc=y_loc,
                          scrollable_lines=(len(summary_text) + 1))
        area.lines = self.win_size_y - y_loc
        area.columns = self.win_size_x
        scroll_region = ScrollWindow(area, window=self.center_win)
        scroll_region.add_paragraph(summary_text, start_x=SummaryScreen.INDENT)

        self.center_win.activate_object(scroll_region)
예제 #9
0
    def _show(self):
        '''Prepare a text summary from the DOC and display it
        to the user in a ScrollWindow

        '''
        y_loc = 1
        y_loc += self.center_win.add_paragraph(SummaryScreen.PARAGRAPH, y_loc)

        y_loc += 1
        self.sysconfig = solaris_install.sysconfig.profile.from_engine()
        summary_text = self.build_summary()
        # Wrap the summary text, accounting for the INDENT (used below in
        # the call to add_paragraph)
        max_chars = self.win_size_x - SummaryScreen.INDENT - 1
        summary_text = convert_paragraph(summary_text, max_chars)
        area = WindowArea(x_loc=0, y_loc=y_loc,
                          scrollable_lines=(len(summary_text) + 1))
        area.lines = self.win_size_y - y_loc
        area.columns = self.win_size_x
        scroll_region = ScrollWindow(area, window=self.center_win)
        scroll_region.add_paragraph(summary_text, start_x=SummaryScreen.INDENT)

        self.center_win.activate_object(scroll_region)
예제 #10
0
    def test_convert_paragraph(self):
        ''' test convert_paragraph() '''
        c0 = u'\u3042'  # 2 columns
        c1 = u'\u3044'  # 2 columns
        c2 = u' '  # 1 column (white space)
        c3 = u'\u3046'  # 2 columns
        c4 = u'\u3048'  # 2 columns
        s = c0 + c1 + c2 + c3 + c4

        if if_wrap_on_whitespace():
            self.assertEqual(convert_paragraph(s, 10), [s])
            self.assertEqual(convert_paragraph(s, 9), [s])
            self.assertEqual(convert_paragraph(s, 8), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 7), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 6), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 5), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 4), [s[:2], s[2:].lstrip()])
        else:
            self.assertEqual(convert_paragraph(s, 10), [s])
            self.assertEqual(convert_paragraph(s, 9), [s])
            self.assertEqual(convert_paragraph(s, 8), [s[:4], s[4:].lstrip()])
            self.assertEqual(convert_paragraph(s, 7), [s[:4], s[4:].lstrip()])
            self.assertEqual(convert_paragraph(s, 6), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 5), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 4), [s[:2], s[2:].lstrip()])
    def test_convert_paragraph(self):
        ''' test convert_paragraph() '''
        c0 = u'\u3042' # 2 columns
        c1 = u'\u3044' # 2 columns
        c2 = u' ' # 1 column (white space)
        c3 = u'\u3046' # 2 columns
        c4 = u'\u3048' # 2 columns
        s = c0 + c1 + c2 + c3 + c4

        if if_wrap_on_whitespace():
            self.assertEqual(convert_paragraph(s, 10), [s])
            self.assertEqual(convert_paragraph(s, 9), [s])
            self.assertEqual(convert_paragraph(s, 8), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 7), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 6), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 5), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 4), [s[:2], s[2:].lstrip()])
        else:
            self.assertEqual(convert_paragraph(s, 10), [s])
            self.assertEqual(convert_paragraph(s, 9), [s])
            self.assertEqual(convert_paragraph(s, 8), [s[:4], s[4:].lstrip()])
            self.assertEqual(convert_paragraph(s, 7), [s[:4], s[4:].lstrip()])
            self.assertEqual(convert_paragraph(s, 6), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 5), [s[:3], s[3:].lstrip()])
            self.assertEqual(convert_paragraph(s, 4), [s[:2], s[2:].lstrip()])