コード例 #1
0
ファイル: steps.py プロジェクト: benluteijn/conjure-up
    def __init__(self, app, steps, cb=None):
        """ init

        Arguments:
        cb: process step callback
        """
        self.app = app
        self.table = Table()
        self.cb = cb

        self.steps_queue = steps
        for step_model in self.steps_queue:
            step_widget = self.add_step_widget(step_model)
            self.table.addColumns(
                step_model.path,
                [
                    ('fixed', 3, step_widget['icon']),
                    step_widget['description'],
                ]
            )
            # Need to still prompt for the user to submit
            # even though no questions are asked
            if len(step_widget['additional_input']) == 0:
                self.table.addRow(
                    Padding.right_20(
                        Color.button_primary(
                            submit_btn(on_press=self.submit,
                                       user_data=(step_model, step_widget)),
                            focus_map='button_primary focus')), False)
            for i in step_widget['additional_input']:
                self.table.addRow(Padding.line_break(""), False)
                self.table.addColumns(
                    step_model.path,
                    [
                        ('weight', 0.5, Padding.left(i['label'], left=5)),
                        ('weight', 1, Color.string_input(
                            i['input'],
                            focus_map='string_input focus')),
                    ], force=True
                )
                self.table.addRow(
                    Padding.right_20(
                        Color.button_primary(
                            submit_btn(
                                on_press=self.submit,
                                user_data=(step_model, step_widget)),
                            focus_map='button_primary focus')), False)
                self.table.addRow(Padding.line_break(""), False)

        self.table.addRow(Padding.center_20(
                        Color.button_primary(
                            done_btn(on_press=self.done, label="View Summary"),
                            focus_map='button_primary focus')))
        super().__init__(Padding.center_80(self.table.render()))
コード例 #2
0
    def build_widgets(self):
        self.description_w = Text("Description Loading…")
        self.readme_w = Text("README Loading…")
        self.scale_edit = IntegerEditor(default=self.service.num_units)
        connect_signal(self.scale_edit._edit, 'change',
                       self.handle_scale_changed)
        self.skip_rest_button = PlainButton(
            "Deploy all {} Remaining Applications with Bundle Defaults".format(
                self.n_remaining),
            self.do_skip_rest
        )
        col = Columns(
            [
                (6, Text('Units:', align='right')),
                (15,
                 Color.string_input(self.scale_edit,
                                    focus_map='string_input focus'))
            ], dividechars=1
        )

        if self.n_remaining == 0:
            buttons = [Padding.right_50(Color.button_primary(
                PlainButton("Deploy and Continue",
                            self.do_deploy),
                focus_map='button_primary focus'))]
        else:
            buttons = [
                Padding.right_50(Color.button_primary(
                    PlainButton(
                        "Deploy and Configure Next Application",
                        self.do_deploy),
                    focus_map='button_primary focus')),
                Padding.right_50(
                    Color.button_secondary(
                        self.skip_rest_button,
                        focus_map='button_secondary focus'))]

        ws = [Text("{} of {}: {}".format(self.idx+1, self.n_total,
                                         self.service.service_name.upper())),
              Padding.center(HR()),
              Padding.center(self.description_w, left=2),
              Padding.line_break(""),
              Padding.center(self.readme_w, left=2),
              Padding.center(HR())]

        if not self.service.subordinate:
            ws.append(Padding.left(col, left=1))

        ws.append(Padding.line_break(""))
        ws += buttons

        self.pile = Pile(ws)
        return Padding.center_90(Filler(self.pile, valign="top"))
コード例 #3
0
    def build_widgets(self):
        self.description_w = Text("Description Loading…")
        self.readme_w = Text("README Loading…")
        self.scale_edit = IntegerEditor(default=self.service.num_units)
        connect_signal(self.scale_edit._edit, 'change',
                       self.handle_scale_changed)
        self.skip_rest_button = PlainButton(
            "Deploy all {} Remaining Applications with Bundle Defaults".format(
                self.n_remaining), self.do_skip_rest)
        col = Columns([(6, Text('Units:', align='right')),
                       (15,
                        Color.string_input(self.scale_edit,
                                           focus_map='string_input focus'))],
                      dividechars=1)

        if self.n_remaining == 0:
            buttons = [
                Padding.right_50(
                    Color.button_primary(PlainButton("Deploy and Continue",
                                                     self.do_deploy),
                                         focus_map='button_primary focus'))
            ]
        else:
            buttons = [
                Padding.right_50(
                    Color.button_primary(PlainButton(
                        "Deploy and Configure Next Application",
                        self.do_deploy),
                                         focus_map='button_primary focus')),
                Padding.right_50(
                    Color.button_secondary(self.skip_rest_button,
                                           focus_map='button_secondary focus'))
            ]

        ws = [
            Text("{} of {}: {}".format(self.idx + 1, self.n_total,
                                       self.service.service_name.upper())),
            Padding.center(HR()),
            Padding.center(self.description_w, left=2),
            Padding.line_break(""),
            Padding.center(self.readme_w, left=2),
            Padding.center(HR())
        ]

        if not self.service.subordinate:
            ws.append(Padding.left(col, left=1))

        ws.append(Padding.line_break(""))
        ws += buttons

        self.pile = Pile(ws)
        return Padding.center_90(Filler(self.pile, valign="top"))
コード例 #4
0
ファイル: applicationlist.py プロジェクト: mnama/conjure-up
    def build_widgets(self, maxlen):
        num_str = "{}".format(self.application.num_units)
        col_pad = 6
        self.unit_w = Text('Units: {:4d}'.format(self.application.num_units),
                           align='right')
        cws = [
            (maxlen + col_pad, Text(self.application.service_name)),
            (10 + len(num_str), self.unit_w),
            # placeholder for instance type
            ('weight', 1, Text(" ")),
            # placeholder for configure button
            ('weight', 1, Text(" ")),
            (20,
             Color.button_primary(PlainButton(
                 "Deploy", partial(self.deploy_cb, self.application)),
                                  focus_map='button_primary focus'))
        ]
        if not self.hide_config:
            cws[3] = (20,
                      Color.button_secondary(
                          PlainButton(
                              "Configure",
                              partial(self.controller.do_configure,
                                      self.application)),
                          focus_map='button_secondary focus'))

        self.columns = Columns(cws, dividechars=1)
        return self.columns
コード例 #5
0
    def build_widgets(self, maxlen):
        num_str = "{}".format(self.application.num_units)
        col_pad = 6
        self.unit_w = Text('Units: {:4d}'.format(self.application.num_units),
                           align='right')
        cws = [
            (maxlen + col_pad,
             Text(self.application.service_name)),
            (10 + len(num_str), self.unit_w),
            # placeholder for instance type
            ('weight', 1, Text(" ")),
            # placeholder for configure button
            ('weight', 1, Text(" ")),
            (20, Color.button_primary(
                PlainButton("Deploy",
                            partial(self.deploy_cb,
                                    self.application)),
                focus_map='button_primary focus'))
        ]
        if not self.hide_config:
            cws[3] = (20, Color.button_secondary(
                PlainButton("Configure",
                            partial(self.controller.do_configure,
                                    self.application)),
                focus_map='button_secondary focus'))

        self.columns = Columns(cws, dividechars=1)
        return self.columns
コード例 #6
0
    def build_widgets(self):
        readme_files = glob(os.path.join(app.config['spell-dir'], 'README.*'))
        if len(readme_files) == 0:
            self.readme_w = Text("No README found for bundle.")
        else:
            readme_file = readme_files[0]
            if len(readme_files) != 1:
                utils.warning("Unexpected: {} files matching README.*"
                              "- using {}".format(len(readme_files),
                                                  readme_file))
            with open(readme_file) as rf:
                rlines = [Text(l) for l in rf.readlines()]
                self.readme_w = BoxAdapter(ListBox(rlines),
                                           self.initial_height)

        ws = [Text("About {}:".format(app.config['spell'])),
              Padding.right_50(Color.button_primary(
                  PlainButton("Continue",
                              self.do_continue),
                  focus_map='button_primary focus')),
              Padding.center(HR()),
              Padding.center(self.readme_w, left=2),
              Padding.center(HR()),
              Padding.center(Text("Use arrow keys to scroll text "
                                  "and TAB to select the button."))]

        self.pile = Pile(ws)
        return Padding.center_90(Filler(self.pile, valign="top"))
コード例 #7
0
 def buttons(self):
     buttons = [
         Color.button_primary(done_btn(on_press=self.done,
                                       label="View Summary"),
                              focus_map='button_primary focus')
     ]
     return Pile(buttons)
コード例 #8
0
ファイル: steps.py プロジェクト: battlemidget/conjure-up
 def buttons(self):
     buttons = [
         Color.button_primary(
             done_btn(on_press=self.done, label="View Summary"),
             focus_map='button_primary focus')
     ]
     return Pile(buttons)
コード例 #9
0
    def build_widgets(self):
        readme_files = glob(os.path.join(self.spell_dir, 'README.*'))
        if len(readme_files) == 0:
            self.readme_w = Text("No README found for bundle.")
        else:
            readme_file = readme_files[0]
            if len(readme_files) != 1:
                utils.warning("Unexpected: {} files matching README.*"
                              "- using {}".format(len(readme_files),
                                                  readme_file))
            with open(readme_file) as rf:
                rlines = [Text(l) for l in rf.readlines()]
                self.readme_w = BoxAdapter(ListBox(rlines),
                                           self.initial_height)

        ws = [
            Text("About {}:".format(self.spell_name)),
            Padding.right_50(
                Color.button_primary(PlainButton("Continue", self.do_continue),
                                     focus_map='button_primary focus')),
            Padding.center(HR()),
            Padding.center(self.readme_w, left=2),
            Padding.center(HR()),
            Padding.center(
                Text("Use arrow keys to scroll text "
                     "and TAB to select the button."))
        ]

        self.pile = Pile(ws)
        return Padding.center_90(Filler(self.pile, valign="top"))
コード例 #10
0
    def generate_additional_input(self):
        """ Generates additional input fields, useful for doing it after
        a previous step is run
        """
        self.set_description(self.model.description, 'body')
        self.icon.set_text(('pending_icon', self.icon.get_text()[0]))
        for i in self.additional_input:
            self.app.log.debug(i)
            self.step_pile.contents.append(
                (Padding.line_break(""), self.step_pile.options()))
            column_input = [('weight', 0.5, Padding.left(i['label'], left=5))]
            if i['input']:
                column_input.append(
                    ('weight', 1,
                     Color.string_input(i['input'],
                                        focus_map='string_input focus')))
            self.step_pile.contents.append(
                (Columns(column_input,
                         dividechars=3), self.step_pile.options()))

            self.button = submit_btn(on_press=self.submit)
            self.step_pile.contents.append((Padding.right_20(
                Color.button_primary(self.button,
                                     focus_map='button_primary focus')),
                                            self.step_pile.options()))
            self.step_pile.contents.append((HR(), self.step_pile.options()))
        self.step_pile.focus_position = self.current_button_index
コード例 #11
0
ファイル: step.py プロジェクト: conjure-up/conjure-up
    def generate_additional_input(self):
        """ Generates additional input fields, useful for doing it after
        a previous step is run
        """
        self.set_description(self.model.description, 'body')
        self.icon.set_text((
            'pending_icon',
            self.icon.get_text()[0]
        ))
        for i in self.additional_input:
            self.app.log.debug(i)
            self.step_pile.contents.append((Padding.line_break(""),
                                            self.step_pile.options()))
            column_input = [
                ('weight', 0.5, Padding.left(i['label'], left=5))
            ]
            if i['input']:
                column_input.append(
                    ('weight', 1, Color.string_input(
                        i['input'],
                        focus_map='string_input focus')))
            self.step_pile.contents.append(
                (Columns(column_input, dividechars=3),
                 self.step_pile.options()))

        self.button = submit_btn(label="Run", on_press=self.submit)
        self.step_pile.contents.append(
            (Padding.right_20(
                Color.button_primary(self.button,
                                     focus_map='button_primary focus')),
             self.step_pile.options()))
        self.step_pile.contents.append((HR(), self.step_pile.options()))
        self.step_pile.focus_position = self.current_button_index
コード例 #12
0
 def _build_buttons(self):
     buttons = [
         Color.button_primary(Button("Confirm", self.submit),
                              focus_map='button_primary focus'),
         Color.button_secondary(Button("Cancel", self.cancel),
                                focus_map='button_secondary focus')
     ]
     return Pile(buttons)
コード例 #13
0
    def buttons(self):
        confirm = confirm_btn(on_press=self.submit)
        cancel = cancel_btn(on_press=self.cancel)

        buttons = [
            Color.button_primary(confirm, focus_map='button_primary focus'),
            Color.button_secondary(cancel, focus_map='button_secondary focus')
        ]
        return Pile(buttons)
コード例 #14
0
ファイル: newcloud.py プロジェクト: sincereuk/conjure-up
    def buttons(self):
        confirm = confirm_btn(on_press=self.submit, label="Add credential")
        cancel = back_btn(on_press=self.cancel)

        buttons = [
            Color.button_primary(confirm, focus_map='button_primary focus'),
            Color.button_secondary(cancel, focus_map='button_secondary focus')
        ]
        return Pile(buttons)
コード例 #15
0
ファイル: lxdsetup.py プロジェクト: benluteijn/conjure-up
    def buttons(self):
        confirm = confirm_btn(on_press=self.submit)
        cancel = cancel_btn(on_press=self.cancel)

        buttons = [
            Color.button_primary(confirm, focus_map='button_primary focus'),
            Color.button_secondary(cancel, focus_map='button_secondary focus')
        ]
        return Pile(buttons)
 def _build_buttons(self):
     buttons = [
         Color.button_primary(
             Button("Confirm", self.submit),
             focus_map='button_primary focus'),
         Color.button_secondary(
             Button("Cancel", self.cancel),
             focus_map='button_secondary focus')
     ]
     return Pile(buttons)
コード例 #17
0
 def show_button(self):
     self.step_pile.contents[self.current_button_index] = (Padding.right_20(
         Color.button_primary(
             self.button,
             focus_map='button_primary focus')), self.step_pile.options())
コード例 #18
0
 def buttons(self):
     self.button = Color.button_primary(
         done_btn(on_press=self.done, label="View Summary"),
         focus_map='button_primary focus')
     return Padding.center_20(self.button)