Exemplo n.º 1
0
 def __init__(self, state):
     ok_button = wdg.FixedButton(wdg.format_hotkey('_OK'))
     cancel_button = wdg.FixedButton(wdg.format_hotkey('_Cancel'))
     choices = []
     self.state = state
     self.actions = {
         wdg.RadioButton(choices,
                         wdg.format_hotkey(action.title),
                         on_state_change=self.action_picked,
                         user_data=action): action
         for action in self.actions
     }
     self.help_text = wdg.Text('')
     super().__init__(title=self.title,
                      body=wdg.Columns([(20, wdg.Pile(choices)),
                                        self.help_text]),
                      buttons=[ok_button, cancel_button])
     self.result = None
     for radio, action in self.actions.items():
         if radio.state:
             self.help_text.set_text(action.help)
     wdg.connect_signal(ok_button, 'click', self.ok)
     wdg.connect_signal(cancel_button, 'click', self.cancel)
     self.width = 50
     self.min_width = 20
     self.height = 12
Exemplo n.º 2
0
 def __init__(self):
     ok_button = wdg.FixedButton(wdg.format_hotkey('_OK'))
     body = wdg.Text([
         "Welcome to the ",
         ('bold', "piwheels"),
         " monitor "
         "application. When run on the same node as the "
         "master, this should automatically connect and "
         "display its status, along with the state of any "
         "connected build slaves.\n"
         "\n",
         "The following keys can be used within the monitor:\n"
         "\n",
         ('bold', "j / down"),
         " - Move down the list of machines\n",
         ('bold', "k / up"),
         "   - Move up the list of machines\n",
         ('bold', "enter"),
         "    - Perform an action on the selected machine\n",
         ('bold', "h"),
         "        - Display this help\n",
         ('bold', "q"),
         "        - Quit the application",
     ])
     super().__init__(title='Help', body=body, buttons=[ok_button])
     wdg.connect_signal(ok_button, 'click', lambda btn: self._emit('close'))
     self.width = ('relative', 50)
     self.min_width = 60
     self.height = ('relative', 20)
     self.min_height = 16
Exemplo n.º 3
0
    def build_ui(self):
        """
        Constructs the monitor's UI from urwid widgets. Returns the root widget
        and the application's palette, for passing to the selected urwid event
        loop constructor.
        """
        self.list_header = widgets.AttrMap(
            widgets.Columns([
                (len(caption) + 1,
                 widgets.Text(caption)) if index < 7 else widgets.Text(caption)
                for index, caption in enumerate(('S', '', '#', 'Label^',
                                                 'ABI^', 'Up Time',
                                                 'Task Time', 'Task'))
            ]), 'header')
        self.slave_box = statsbox.SlaveStatsBox()
        self.master_box = statsbox.MasterStatsBox()
        self.status_box = widgets.Text('Waiting for connection')
        self.slave_list = states.SlaveListWalker(
            header=self.list_header.original_widget,
            get_box=lambda: self.get_box()[0])
        list_box = widgets.ListBox(self.slave_list)
        # Make the list-box navigation vim-friendly
        list_box._command_map = list_box._command_map.copy()
        list_box._command_map['j'] = list_box._command_map['down']
        list_box._command_map['k'] = list_box._command_map['up']
        self.frame = widgets.Frame(list_box,
                                   header=self.list_header,
                                   footer=None)  # to be set by list_modified

        status_line = widgets.AttrMap(widgets.Filler(self.status_box),
                                      'footer')

        return widgets.DialogMaster(
            widgets.Pile([
                self.frame,
                (1, status_line),
            ]))
Exemplo n.º 4
0
 def __init__(self):
     self.board_label = wdg.Text('-')
     self.serial_label = wdg.Text('-')
     self.os_label = wdg.Text('-')
     self.load_bar = wdg.GraphBar(minimum=0.0,
                                  maximum=4.0,
                                  format=' {max:.1f}')
     self.temperature_bar = wdg.GraphBar(minimum=40,
                                         maximum=80,
                                         format=' {min}-{max}°C')
     self.disk_bar = wdg.GraphBar(
         minimum=0, format=lambda min, max: ' ' + format_size(max))
     self.swap_bar = wdg.GraphBar(
         minimum=0, format=lambda min, max: ' ' + format_size(max))
     self.memory_bar = wdg.GraphBar(
         minimum=0, format=lambda min, max: ' ' + format_size(max))
     self.builds_bar = wdg.RatioBar()
     self.queue_bar = wdg.RatioBar()
     self.downloads_bar = wdg.GraphBar(format=' {max}')
     self.builds_size_label = wdg.Text('-')
     self.builds_time_label = wdg.Text('-')
     self.files_count_label = wdg.Text('-')
     super().__init__(
         wdg.AttrMap(
             wdg.LineBox(
                 wdg.Columns([
                     (12,
                      wdg.Pile([
                          wdg.Text('Board'),
                          wdg.Text('Serial #'),
                          wdg.Text('OS'),
                          wdg.Text('Build Size'),
                          wdg.Text('Build Time'),
                          wdg.Text('File Count'),
                          wdg.Text('Queue'),
                      ])),
                     wdg.Pile([
                         self.board_label,
                         self.serial_label,
                         self.os_label,
                         self.builds_size_label,
                         self.builds_time_label,
                         self.files_count_label,
                         self.queue_bar,
                     ]),
                     (12,
                      wdg.Pile([
                          wdg.Text('Builds/hr'),
                          wdg.Text('Downloads/hr'),
                          wdg.Text('Temperature'),
                          wdg.Text('Load Avg'),
                          wdg.Text('Disk'),
                          wdg.Text('Swap'),
                          wdg.Text('Memory'),
                      ])),
                     wdg.Pile([
                         self.builds_bar,
                         self.downloads_bar,
                         self.temperature_bar,
                         self.load_bar,
                         self.disk_bar,
                         self.swap_bar,
                         self.memory_bar,
                     ]),
                 ],
                             dividechars=1), ),
             'dialog',
         ))
Exemplo n.º 5
0
 def __init__(self):
     self.board_label = wdg.Text('-')
     self.serial_label = wdg.Text('-')
     self.python_label = wdg.Text('-')
     self.os_label = wdg.Text('-')
     self.clock_label = wdg.Text('-')
     self.load_bar = wdg.GraphBar(minimum=0.0,
                                  maximum=4.0,
                                  delta=timedelta(seconds=15),
                                  format=' {max:.1f}')
     self.temperature_bar = wdg.GraphBar(minimum=40,
                                         maximum=80,
                                         delta=timedelta(seconds=15),
                                         format=' {min}-{max}°C')
     self.disk_bar = wdg.GraphBar(
         format=lambda min, max: ' ' + format_size(max),
         minimum=0,
         delta=timedelta(seconds=15))
     self.swap_bar = wdg.GraphBar(
         format=lambda min, max: ' ' + format_size(max),
         minimum=0,
         delta=timedelta(seconds=15))
     self.memory_bar = wdg.GraphBar(
         format=lambda min, max: ' ' + format_size(max),
         minimum=0,
         delta=timedelta(seconds=15))
     super().__init__(
         wdg.AttrMap(
             wdg.LineBox(
                 wdg.Columns([
                     (11,
                      wdg.Pile([
                          wdg.Text('Board'),
                          wdg.Text('Serial #'),
                          wdg.Text('OS'),
                          wdg.Text('Python'),
                          wdg.Text('Clock Delta'),
                      ])),
                     wdg.Pile([
                         self.board_label,
                         self.serial_label,
                         self.os_label,
                         self.python_label,
                         self.clock_label,
                     ]),
                     (11,
                      wdg.Pile([
                          wdg.Text('Temperature'),
                          wdg.Text('Load Avg'),
                          wdg.Text('Disk'),
                          wdg.Text('Swap'),
                          wdg.Text('Memory'),
                      ])),
                     wdg.Pile([
                         self.temperature_bar,
                         self.load_bar,
                         self.disk_bar,
                         self.swap_bar,
                         self.memory_bar,
                     ]),
                 ],
                             dividechars=1)), 'dialog'))