def cb_delete(result):
            self.action_in_progress = False
            self.update_ui_state()
            self.refresh_all_configs(None)

            report_script_result(
                result, "Delete Config File Error", "Could not delete config file {0}:".format(config.display_name)
            )
Exemplo n.º 2
0
        def cb_delete(result):
            self.action_in_progress = False
            self.update_ui_state()
            self.refresh_all_configs(None)

            report_script_result(
                result, 'Delete Config File Error',
                'Could not delete config file {0}:'.format(
                    config.display_name))
Exemplo n.º 3
0
        def cb_change_permissions(result):
            if not report_script_result(
                    result, title + ' Error',
                    'Could change {0} permissions'.format(type_name)):
                return

            name_item.setData(new_permissions, USER_ROLE_PERMISSIONS)
Exemplo n.º 4
0
        def cb_red_brick_time(result):
            if not report_script_result(result, 'Settings | Date/Time', 'Error getting time from RED Brick'):
                return

            try:
                self.time_red_old, tz = map(int, result.stdout.split('\n')[:2])
                if tz < 0:
                    tz_str_red = 'UTC' + str(tz)
                else:
                    tz_str_red = 'UTC+' + str(tz)
                self.time_timezone_red.setText(tz_str_red)

                self.time_local_old = int(time.time())
                tz = self.time_utc_offset()
                if tz < 0:
                    tz_str_local = 'UTC' + str(tz)
                else:
                    tz_str_local = 'UTC+' + str(tz)

                self.time_timezone_local.setText(tz_str_local)
                self.time_update_gui()

                self.time_refresh_timer.start()

                if (self.time_red_old == self.time_local_old) and (tz_str_local == tz_str_red):
                    self.time_sync_button.setEnabled(False)
                else:
                    self.time_sync_button.setEnabled(True)
            except Exception as e:
                QtGui.QMessageBox.critical(get_main_window(),
                                           'Settings | Date/Time',
                                           'Error parsing time from RED Brick:\n\n{0}'.format(e))

            self.time_sync_button.setEnabled(True)
        def cb_import_directory(result):
            script_instance = script_instance_ref[0]

            if script_instance != None:
                aborted = script_instance.abort
            else:
                aborted = False

            script_instance_ref[0] = None

            if aborted:
                return

            if not report_script_result(result, 'Import Error', 'Could not create import directory',
                                        before_message_box=self.progress.close):
                return

            # step 2/4: upload archive to temporary import directory
            import_directory_ref[0] = result.stdout.strip()
            target_path             = posixpath.join(import_directory_ref[0], 'archive.tfrba')
            self.chunked_uploader   = ChunkedUploader(self, extract_archive)

            if not self.chunked_uploader.prepare(source_path):
                return

            try:
                target_file = REDFile(self.session).open(target_path, REDFile.FLAG_WRITE_ONLY | REDFile.FLAG_CREATE | REDFile.FLAG_NON_BLOCKING | REDFile.FLAG_EXCLUSIVE, 0o644, 1000, 1000) # FIXME: async_call
            except (Error, REDError) as e:
                QMessageBox.information(get_main_window(), 'Import Error',
                                        'Could not open target file {0}: {1}'.format(target_path, e))
                return

            self.progress.setLabelText('Step 2 of 4: Uploading archive')
            self.progress.set_progress_text_visible(True)
            self.chunked_uploader.start(target_path, target_file)
            def cb_import_extract(result):
                script_instance = script_instance_ref[0]

                if script_instance != None:
                    aborted = script_instance.abort
                else:
                    aborted = False

                script_instance_ref[0] = None

                if aborted:
                    return

                if not report_script_result(result, 'Import Error', 'Could not extract archive',
                                            before_message_box=self.progress.close):
                    return

                def cb_restart_reboot_shutdown(result):
                    self.progress.close()

                    report_script_result(result, 'Import Error', 'Could not reboot RED Brick to finish program import')

                # step 4/4: reboot
                self.progress.setLabelText('Step 4 of 4: Rebooting RED Brick')
                self.progress.setRange(0, 0)

                self.script_manager.execute_script('restart_reboot_shutdown',
                                                   cb_restart_reboot_shutdown, ['1'])

                def close_progress():
                    # use a closure to capture self and ansure that it's safe
                    # to call this even if the tab was official destroyed already
                    self.progress.close()

                QTimer.singleShot(1500, close_progress)
Exemplo n.º 7
0
    def cb_settings_services_apply(self, result):
        def done():
            get_main_window().setEnabled(True)
            self.chkbox_gpu.setEnabled(True)
            self.chkbox_desktopenv.setEnabled(True)
            self.chkbox_webserver.setEnabled(True)
            self.chkbox_splashscreen.setEnabled(True)
            self.chkbox_ap.setEnabled(True)
            self.chkbox_server_monitoring.setEnabled(True)
            self.chkbox_openhab.setEnabled(True)
            self.chkbox_mobile_internet.setEnabled(True)

            self.pbutton_services_save.setText('Save and Reboot')
            self.pbutton_services_save.setEnabled(True)

        def cb_restart_reboot_shutdown(result):
            if not report_script_result(result, 'Settings | Services',
                                        'Error rebooting RED Brick'):
                done()
                return

        if not report_script_result(result, 'Settings | Services',
                                    'Error saving services status'):
            done()
            return

        get_main_window().setEnabled(True)

        QtGui.QMessageBox.information(
            get_main_window(), 'Settings | Services',
            'Saved configuration successfully, will now reboot RED Brick.')

        self.script_manager.execute_script('restart_reboot_shutdown_systemd',
                                           cb_restart_reboot_shutdown, ['1'])
Exemplo n.º 8
0
        def cb_settings_ap_status(result):
            self.update_button_text_state(BUTTON_STATE_DEFAULT)
            self.label_working_wait.hide()
            self.pbar_working_wait.hide()
            self.sarea_ap.setEnabled(True)

            if not self.is_tab_on_focus:
                return

            if not report_script_result(result, 'Settings | Access Point', 'Error checking access point mode:',
                                        before_message_box=lambda: self.label_ap_status.setText('-')):
                return

            ap_mode_status = json.loads(result.stdout)

            if ap_mode_status is None or \
                ap_mode_status['ap_first_time'] is None or \
                ap_mode_status['ap_incomplete_config'] is None or \
                ap_mode_status['ap_hardware_or_config_problem'] is None:
                self.label_ap_status.setText('-')
                QMessageBox.critical(get_main_window(),
                                        'Settings | Access Point',
                                        'Error checking access point mode.')
            elif not ap_mode_status['ap_incomplete_config'] and \
                    not ap_mode_status['ap_hardware_or_config_problem']:
                self.label_ap_status.setText('Active')
            elif ap_mode_status['ap_first_time']:
                self.label_ap_status.setText('Inactive - Select an interface and click save')
            elif ap_mode_status['ap_incomplete_config']:
                self.label_ap_status.setText('Inactive - Incomplete configuration, check your configuration and click save')
            elif ap_mode_status['ap_hardware_or_config_problem']:
                self.label_ap_status.setText('Inactive - Hardware not supported or wrong configuration')

            self.update_ui_state()
            self.read_config_files()
    def cb_settings_services_apply(self, result):
        def done():
            get_main_window().setEnabled(True)
            self.chkbox_gpu.setEnabled(True)
            self.chkbox_desktopenv.setEnabled(True)
            self.chkbox_webserver.setEnabled(True)
            self.chkbox_splashscreen.setEnabled(True)
            self.chkbox_ap.setEnabled(True)
            self.chkbox_server_monitoring.setEnabled(True)
            self.chkbox_openhab.setEnabled(True)
            self.chkbox_mobile_internet.setEnabled(True)

            self.pbutton_services_save.setText('Save and Reboot')
            self.pbutton_services_save.setEnabled(True)

        def cb_restart_reboot_shutdown(result):
            if not report_script_result(result, 'Settings | Services', 'Error rebooting RED Brick'):
                done()
                return

        if not report_script_result(result, 'Settings | Services', 'Error saving services status'):
            done()
            return

        get_main_window().setEnabled(True)
        
        QtGui.QMessageBox.information(get_main_window(),
                                      'Settings | Services',
                                      'Saved configuration successfully, will now reboot RED Brick.')

        self.script_manager.execute_script('restart_reboot_shutdown',
                                           cb_restart_reboot_shutdown, ['1'])
            def cb_import_extract(result):
                script_instance = script_instance_ref[0]

                if script_instance != None:
                    aborted = script_instance.abort
                else:
                    aborted = False

                script_instance_ref[0] = None

                if aborted:
                    return

                if not report_script_result(result, 'Import Error', 'Could not extract archive',
                                            before_message_box=self.progress.close):
                    return

                def cb_restart_reboot_shutdown(result):
                    self.progress.close()

                    report_script_result(result, 'Import Error', 'Could not reboot RED Brick to finish program import')

                # step 4/4: reboot
                self.progress.setLabelText('Step 4 of 4: Rebooting RED Brick')
                self.progress.setRange(0, 0)

                self.script_manager.execute_script('restart_reboot_shutdown_systemd',
                                                   cb_restart_reboot_shutdown, ['1'])

                def close_progress():
                    # use a closure to capture self and ansure that it's safe
                    # to call this even if the tab was official destroyed already
                    self.progress.close()

                QTimer.singleShot(1500, close_progress)
        def cb_export(result):
            script_instance = script_instance_ref[0]

            if script_instance != None:
                aborted = script_instance.abort
            else:
                aborted = False

            script_instance_ref[0] = None

            if aborted:
                return

            if not report_script_result(result, 'Export Error', 'Could not archive selected programs',
                                        before_message_box=self.progress.close):
                return

            # step 2/2: download created archive
            source_path             = posixpath.join(result.stdout.strip(), 'archive.tfrba')
            self.chunked_downloader = ChunkedDownloader(self)

            if not self.chunked_downloader.prepare(source_path):
                return

            self.progress.setLabelText('Step 2 of 2: Downloading archive')
            self.progress.set_progress_text_visible(True)
            self.chunked_downloader.start(target_path)
Exemplo n.º 12
0
        def cb_export(result):
            script_instance = script_instance_ref[0]

            if script_instance != None:
                aborted = script_instance.abort
            else:
                aborted = False

            script_instance_ref[0] = None

            if aborted:
                return

            if not report_script_result(result, 'Export Error', 'Could not archive selected programs',
                                        before_message_box=self.progress.close):
                return

            # step 2/2: download created archive
            source_path             = posixpath.join(result.stdout.strip(), 'archive.tfrba')
            self.chunked_downloader = ChunkedDownloader(self)

            if not self.chunked_downloader.prepare(source_path):
                return

            self.progress.setLabelText('Step 2 of 2: Downloading archive')
            self.progress.set_progress_text_visible(True)
            self.chunked_downloader.start(target_path)
        def cb_import_directory(result):
            script_instance = script_instance_ref[0]

            if script_instance != None:
                aborted = script_instance.abort
            else:
                aborted = False

            script_instance_ref[0] = None

            if aborted:
                return

            if not report_script_result(result, 'Import Error', 'Could not create import directory',
                                        before_message_box=self.progress.close):
                return

            # step 2/4: upload archive to temporary import directory
            import_directory_ref[0] = result.stdout.strip()
            target_path             = posixpath.join(import_directory_ref[0], 'archive.tfrba')
            self.chunked_uploader   = ChunkedUploader(self, extract_archive)

            if not self.chunked_uploader.prepare(source_path):
                return

            try:
                target_file = REDFile(self.session).open(target_path, REDFile.FLAG_WRITE_ONLY | REDFile.FLAG_CREATE | REDFile.FLAG_NON_BLOCKING | REDFile.FLAG_EXCLUSIVE, 0o644, 1000, 1000) # FIXME: async_call
            except (Error, REDError) as e:
                QMessageBox.information(get_main_window(), 'Import Error',
                                        'Could not open target file {0}: {1}'.format(target_path, e))
                return

            self.progress.setLabelText('Step 2 of 4: Uploading archive')
            self.progress.set_progress_text_visible(True)
            self.chunked_uploader.start(target_path, target_file)
        def cb_red_brick_time(result):
            if not report_script_result(result, 'Settings | Date/Time', 'Error getting time from RED Brick'):
                return

            try:
                self.time_red_old, tz = map(int, result.stdout.split('\n')[:2])
                if tz < 0:
                    tz_str_red = 'UTC' + str(tz)
                else:
                    tz_str_red = 'UTC+' + str(tz)
                self.time_timezone_red.setText(tz_str_red)

                self.time_local_old = int(time.time())
                tz = self.time_utc_offset()
                if tz < 0:
                    tz_str_local = 'UTC' + str(tz)
                else:
                    tz_str_local = 'UTC+' + str(tz)

                self.time_timezone_local.setText(tz_str_local)
                self.time_update_gui()

                self.time_refresh_timer.start()

                if (self.time_red_old == self.time_local_old) and (tz_str_local == tz_str_red):
                    self.time_sync_button.setEnabled(False)
                else:
                    self.time_sync_button.setEnabled(True)
            except Exception as e:
                QtGui.QMessageBox.critical(get_main_window(),
                                           'Settings | Date/Time',
                                           'Error parsing time from RED Brick:\n\n{0}'.format(e))

            self.time_sync_button.setEnabled(True)
Exemplo n.º 15
0
        def cb_rename(result):
            if not report_script_result(result, title + ' Error', 'Could not rename {0}'.format(type_name)):
                return

            name_item.setText(new_name)

            if self.tree_files.header().sortIndicatorSection() == 0:
                self.tree_files.header().setSortIndicator(0, self.tree_files.header().sortIndicatorOrder())
Exemplo n.º 16
0
        def cb_delete(result):
            script_instance = script_instance_ref[0]

            if script_instance != None:
                aborted = script_instance.abort
            else:
                aborted = False

            script_instance_ref[0] = None

            progress.cancel()
            self.refresh_files()

            if aborted:
                QMessageBox.information(get_main_window(), 'Delete Files',
                                        'Delete operation was aborted.')
                return

            report_script_result(result, 'Delete Files Error', 'Could not delete selected files/directories:')
Exemplo n.º 17
0
    def cb_settings_fs_expand_check(self, result):
        if not self.is_tab_on_focus:
            return

        if not report_script_result(result, 'Settings | File System',
                                    'Error getting partition information'):
            self.label_fs_expand_info.hide()
            self.line.hide()
            self.label_pbar_fs_capacity_utilization.hide()
            self.pbar_fs_capacity_utilization.setMinimum(0)
            self.pbar_fs_capacity_utilization.setMaximum(100)
            self.pbar_fs_capacity_utilization.setValue(0)
            self.pbar_fs_capacity_utilization.setFormat('')
            self.pbar_fs_capacity_utilization.setEnabled(False)
            self.pbutton_fs_expand.setEnabled(False)
            return

        try:
            size_dict = json.loads(result.stdout)
            p1_start = float(size_dict['p1_start'])
            p1_size = float(size_dict['p1_size'])
            card_size = float(size_dict['card_size'])
        except:
            p1_start = 0
            p1_size = 100
            card_size = 100

        percentage_utilization_v = min(int(math.ceil((p1_size / (card_size - p1_start)) * 100.0)), 100)
        percentage_utilization = unicode(percentage_utilization_v)

        self.pbar_fs_capacity_utilization.setEnabled(True)

        self.pbar_fs_capacity_utilization.setMinimum(0)
        self.pbar_fs_capacity_utilization.setMaximum(100)

        self.pbar_fs_capacity_utilization.setValue(percentage_utilization_v)

        if percentage_utilization_v >= 95:
            self.pbutton_fs_expand.setEnabled(False)
            self.label_fs_expand_info.hide()
            self.line.hide()
        else:
            self.pbutton_fs_expand.setEnabled(True)
            self.label_fs_expand_info.show()
            self.line.show()

        pbar_fs_capacity_utilization_fmt = "Using {0}% of total capacity".format(percentage_utilization)

        if sys.platform == 'darwin':
            self.label_pbar_fs_capacity_utilization.show()
            self.label_pbar_fs_capacity_utilization.setText(pbar_fs_capacity_utilization_fmt)
        else:
            self.pbar_fs_capacity_utilization.setFormat(pbar_fs_capacity_utilization_fmt)
    def cb_settings_mobile_internet_connect(self, result):
        self.update_gui(EVENT_GUI_CONNECT_RETURNED)

        if result.error is not None:
            QMessageBox.critical(get_main_window(),
                                    MESSAGEBOX_TITLE,
                                    MESSAGE_ERROR_CONNECT_SCRIPT_EXECUTION + ': ' + result.error)
            return

        if result.exit_code == 2:
            QMessageBox.critical(get_main_window(),
                                 MESSAGEBOX_TITLE,
                                 MESSAGE_ERROR_CONNECT_TEST)
            return

        if result.exit_code == 3:
            QMessageBox.critical(get_main_window(),
                                 MESSAGEBOX_TITLE,
                                 MESSAGE_ERROR_CONNECT_SERVICE_CREATION)
            return

        if result.exit_code == 4:
            QMessageBox.critical(get_main_window(),
                                 MESSAGEBOX_TITLE,
                                 MESSAGE_ERROR_CONNECT_SERVICE_EXECUTION)
            return

        if result.exit_code == 7 or result.exit_code == 8:
            QMessageBox.critical(get_main_window(),
                                 MESSAGEBOX_TITLE,
                                 MESSAGE_ERROR_CONNECT_TEST_DEVICE_UNAVAILABLE)
            return

        if result.exit_code == 12:
            QMessageBox.critical(get_main_window(),
                                 MESSAGEBOX_TITLE,
                                 MESSAGE_ERROR_CONNECT_TEST_PIN)
            return

        if result.exit_code == 13 or result.exit_code == 98:
            QMessageBox.critical(get_main_window(),
                                 MESSAGEBOX_TITLE,
                                 MESSAGE_ERROR_CONNECT_TEST_REGISTER_NETWORK)
            return

        if not report_script_result(result, MESSAGEBOX_TITLE, MESSAGE_ERROR_CONNECT):
            return

        QMessageBox.information(get_main_window(),
                                MESSAGEBOX_TITLE,
                                MESSAGE_INFORMATION_CONNECT_OK)

        self.pbutton_mi_refresh_clicked()
Exemplo n.º 19
0
        def cb_delete(result):
            script_instance = script_instance_ref[0]

            if script_instance != None:
                aborted = script_instance.abort
            else:
                aborted = False

            script_instance_ref[0] = None

            progress.cancel()
            self.refresh_files()

            if aborted:
                QMessageBox.information(get_main_window(), 'Delete Files',
                                        'Delete operation was aborted.')
                return

            report_script_result(
                result, 'Delete Files Error',
                'Could not delete selected files/directories:')
Exemplo n.º 20
0
        def cb_rename(result):
            if not report_script_result(
                    result, title + ' Error',
                    'Could not rename {0}'.format(type_name)):
                return

            name_item.setText(new_name)

            if self.tree_files.header().sortIndicatorSection() == 0:
                self.tree_files.header().setSortIndicator(
                    0,
                    self.tree_files.header().sortIndicatorOrder())
Exemplo n.º 21
0
        def cb_settings_fs_expand(result):
            def cb_restart_reboot_shutdown(result):
                self.pbutton_fs_expand.setEnabled(False)
                report_script_result(result, 'Settings | File System',
                                     'Error rebooting RED Brick')

            if not report_script_result(result, 'Settings | File System',
                                        'Error expanding file system'):
                self.pbutton_fs_expand.setEnabled(True)
                return

            self.script_manager.execute_script('restart_reboot_shutdown',
                                               cb_restart_reboot_shutdown, ['1'])
Exemplo n.º 22
0
        def gui_after_apply(result):
            self.label_working_wait.hide()
            self.pbar_working_wait.hide()
            self.saving = False
            self.sarea_ap.setEnabled(True)
            self.update_button_text_state(BUTTON_STATE_DEFAULT)

            if not report_script_result(result, 'Settings | Access Point', 'Error saving access point settings:'):
                return

            self.slot_pbutton_ap_refresh_clicked()

            QMessageBox.information(get_main_window(),
                                    'Settings | Access Point',
                                    'Access point settings saved.')
    def cb_settings_mobile_internet_connect(self, result):
        self.update_gui(EVENT_GUI_CONNECT_RETURNED)

        if result.error is not None:
            QMessageBox.critical(
                get_main_window(), MESSAGEBOX_TITLE,
                MESSAGE_ERROR_CONNECT_SCRIPT_EXECUTION + ': ' + result.error)
            return

        if result.exit_code == 2:
            QMessageBox.critical(get_main_window(), MESSAGEBOX_TITLE,
                                 MESSAGE_ERROR_CONNECT_TEST)
            return

        if result.exit_code == 3:
            QMessageBox.critical(get_main_window(), MESSAGEBOX_TITLE,
                                 MESSAGE_ERROR_CONNECT_SERVICE_CREATION)
            return

        if result.exit_code == 4:
            QMessageBox.critical(get_main_window(), MESSAGEBOX_TITLE,
                                 MESSAGE_ERROR_CONNECT_SERVICE_EXECUTION)
            return

        if result.exit_code == 7 or result.exit_code == 8:
            QMessageBox.critical(
                get_main_window(), MESSAGEBOX_TITLE,
                MESSAGE_ERROR_CONNECT_TEST_DEVICE_UNAVAILABLE)
            return

        if result.exit_code == 12:
            QMessageBox.critical(get_main_window(), MESSAGEBOX_TITLE,
                                 MESSAGE_ERROR_CONNECT_TEST_PIN)
            return

        if result.exit_code == 13 or result.exit_code == 98:
            QMessageBox.critical(get_main_window(), MESSAGEBOX_TITLE,
                                 MESSAGE_ERROR_CONNECT_TEST_REGISTER_NETWORK)
            return

        if not report_script_result(result, MESSAGEBOX_TITLE,
                                    MESSAGE_ERROR_CONNECT):
            return

        QMessageBox.information(get_main_window(), MESSAGEBOX_TITLE,
                                MESSAGE_INFORMATION_CONNECT_OK)

        self.pbutton_mi_refresh_clicked()
Exemplo n.º 24
0
        def gui_after_apply(result):
            self.label_working_wait.hide()
            self.pbar_working_wait.hide()
            self.saving = False
            self.sarea_ap.setEnabled(True)
            self.update_button_text_state(BUTTON_STATE_DEFAULT)

            if not report_script_result(result, 'Settings | Access Point',
                                        'Error saving access point settings:'):
                return

            self.slot_pbutton_ap_refresh_clicked()

            QMessageBox.information(get_main_window(),
                                    'Settings | Access Point',
                                    'Access point settings saved.')
Exemplo n.º 25
0
        def cb_settings_fs_expand(result):
            def cb_restart_reboot_shutdown(result):
                report_script_result(result, 'Settings | File System',
                                     'Error rebooting RED Brick')

            get_main_window().setEnabled(True)

            if not report_script_result(result, 'Settings | File System',
                                        'Error expanding file system'):
                return

            QtGui.QMessageBox.information(get_main_window(),
                                          'Settings | Services',
                                          'File system expansion will be complete after reboot, rebooting RED Brick now.')

            self.script_manager.execute_script('restart_reboot_shutdown_systemd',
                                               cb_restart_reboot_shutdown, ['1'])
        def cb_settings_fs_expand(result):
            def cb_restart_reboot_shutdown(result):
                report_script_result(result, 'Settings | File System',
                                     'Error rebooting RED Brick')

            get_main_window().setEnabled(True)

            if not report_script_result(result, 'Settings | File System',
                                        'Error expanding file system'):
                return

            QtGui.QMessageBox.information(get_main_window(),
                                          'Settings | Services',
                                          'File system expansion will be complete after reboot, rebooting RED Brick now.')

            self.script_manager.execute_script('restart_reboot_shutdown',
                                               cb_restart_reboot_shutdown, ['1'])
Exemplo n.º 27
0
        def cb_red_brick_time(result):
            if not report_script_result(result, 'Settings | Date/Time',
                                        'Error getting time from RED Brick'):
                return

            try:
                self.time_local_old = int(time.time())

                self.time_red_old, self.time_iso8601_red, timezone = result.stdout.split(
                    '\n')[:3]
                self.time_red_old = int(self.time_red_old)

                try:
                    self.timezone_red = pytz.timezone(timezone)
                except:
                    self.timezone_red = None

                    timezone = self.convert_from_posix(timezone)

                    timezone = "Unknown ({})".format(
                        timezone) if len(timezone) > 0 else "Unknown"
                    self.red_reconfigure_label.show()
                    self.save_timezone_button.setEnabled(False)

                self.time_timezone_red.setCurrentText(timezone)

                try:
                    tz_str_local = self.convert_from_posix(
                        get_localzone().zone)
                except:
                    tz_str_local = 'Unknown ({})'.format(
                        self.format_time_utc_offset(self.time_utc_offset()))
                self.time_timezone_local.setText(tz_str_local)
                self.time_update_gui()

                self.time_refresh_timer.start()

                self.time_sync_button.setEnabled(True)
            except Exception as e:
                QMessageBox.critical(
                    get_main_window(), 'Settings | Date/Time',
                    'Error parsing time from RED Brick:\n\n{0}'.format(e))

            self.time_sync_button.setEnabled(True)
Exemplo n.º 28
0
        def cb_settings_ap_status(result):
            self.update_button_text_state(BUTTON_STATE_DEFAULT)
            self.label_working_wait.hide()
            self.pbar_working_wait.hide()
            self.sarea_ap.setEnabled(True)

            if not self.is_tab_on_focus:
                return

            if not report_script_result(result,
                                        'Settings | Access Point',
                                        'Error checking access point mode:',
                                        before_message_box=lambda: self.
                                        label_ap_status.setText('-')):
                return

            ap_mode_status = json.loads(result.stdout)

            if ap_mode_status is None or \
                ap_mode_status['ap_first_time'] is None or \
                ap_mode_status['ap_incomplete_config'] is None or \
                ap_mode_status['ap_hardware_or_config_problem'] is None:
                self.label_ap_status.setText('-')
                QMessageBox.critical(get_main_window(),
                                     'Settings | Access Point',
                                     'Error checking access point mode.')
            elif not ap_mode_status['ap_incomplete_config'] and \
                    not ap_mode_status['ap_hardware_or_config_problem']:
                self.label_ap_status.setText('Active')
            elif ap_mode_status['ap_first_time']:
                self.label_ap_status.setText(
                    'Inactive - Select an interface and click save')
            elif ap_mode_status['ap_incomplete_config']:
                self.label_ap_status.setText(
                    'Inactive - Incomplete configuration, check your configuration and click save'
                )
            elif ap_mode_status['ap_hardware_or_config_problem']:
                self.label_ap_status.setText(
                    'Inactive - Hardware not supported or wrong configuration')

            self.update_ui_state()
            self.read_config_files()
Exemplo n.º 29
0
    def cb_settings_services_apply(self, result):
        def done():
            self.chkbox_gpu.setEnabled(True)
            self.chkbox_desktopenv.setEnabled(True)
            self.chkbox_webserver.setEnabled(True)
            self.chkbox_splashscreen.setEnabled(True)
            self.chkbox_ap.setEnabled(True)
            self.chkbox_server_monitoring.setEnabled(True)
            self.chkbox_openhab.setEnabled(True)

            self.pbutton_services_save.setText('Save')
            self.pbutton_services_save.setEnabled(True)

        if not report_script_result(result, 'Settings | Services', 'Error saving services status'):
            done()
            return

        def cb_restart_reboot_shutdown(result):
            if not report_script_result(result, 'Settings | Services', 'Error rebooting RED Brick'):
                done()
                return

        self.script_manager.execute_script('restart_reboot_shutdown',
                                           cb_restart_reboot_shutdown, ['1'])
 def cb_restart_reboot_shutdown(result):
     report_script_result(result, 'Settings | File System',
                          'Error rebooting RED Brick')
Exemplo n.º 31
0
        def cb_change_permissions(result):
            if not report_script_result(result, title + ' Error', 'Could change {0} permissions'.format(type_name)):
                return

            name_item.setData(new_permissions, USER_ROLE_PERMISSIONS)
    def cb_settings_fs_expand_check(self, result):
        if not self.is_tab_on_focus:
            return

        if not report_script_result(result, 'Settings | File System',
                                    'Error getting partition information'):
            self.label_fs_expand_info.hide()
            self.line.hide()
            self.label_pbar_fs_capacity_utilization.hide()
            self.pbar_fs_capacity_utilization.setMinimum(0)
            self.pbar_fs_capacity_utilization.setMaximum(100)
            self.pbar_fs_capacity_utilization.setValue(0)
            self.pbar_fs_capacity_utilization.setFormat('')
            self.pbar_fs_capacity_utilization.setEnabled(False)
            self.pbutton_fs_expand.setEnabled(False)
            return

        try:
            size_dict = json.loads(result.stdout)
            p1_start = float(size_dict['p1_start'])
            p1_size = float(size_dict['p1_size'])
            card_size = float(size_dict['card_size'])
            ext3_size = float(size_dict['ext3_size'])
        except:
            p1_start = 0
            p1_size = 100
            card_size = 100
            ext3_size = 100

        avialable_size = card_size - p1_start
        used_size = min(p1_size, ext3_size)

        percentage_utilization_v = min(int(math.ceil((used_size / avialable_size) * 100.0)), 100)

        # due to common file system overahead 100% will normally never be
        # reached just fake 100% in this case to avoid user confusion
        if percentage_utilization_v >= 95:
            percentage_utilization_v = 100

        percentage_utilization = unicode(percentage_utilization_v)

        self.pbar_fs_capacity_utilization.setEnabled(True)

        self.pbar_fs_capacity_utilization.setMinimum(0)
        self.pbar_fs_capacity_utilization.setMaximum(100)

        self.pbar_fs_capacity_utilization.setValue(percentage_utilization_v)

        if percentage_utilization_v == 100:
            self.pbutton_fs_expand.setEnabled(False)
            self.label_fs_expand_info.hide()
            self.line.hide()
        else:
            self.pbutton_fs_expand.setEnabled(True)
            self.label_fs_expand_info.show()
            self.line.show()

        pbar_fs_capacity_utilization_fmt = "Using {0}% of total capacity".format(percentage_utilization)

        if sys.platform == 'darwin':
            self.label_pbar_fs_capacity_utilization.show()
            self.label_pbar_fs_capacity_utilization.setText(pbar_fs_capacity_utilization_fmt)
        else:
            self.pbar_fs_capacity_utilization.setFormat(pbar_fs_capacity_utilization_fmt)
Exemplo n.º 33
0
 def cb_restart_reboot_shutdown(result):
     report_script_result(result, 'Settings | File System',
                          'Error rebooting RED Brick')
Exemplo n.º 34
0
    def cb_settings_mobile_internet_refresh(self, result):
        self.update_gui(EVENT_GUI_REFRESH_RETURNED)

        if not report_script_result(result, MESSAGEBOX_TITLE,
                                    MESSAGE_ERROR_REFERSH):
            return

        try:
            dict_configuration = json.loads(result.stdout)
        except Exception as e:
            QtGui.QMessageBox.critical(
                get_main_window(), MESSAGEBOX_TITLE,
                MESSAGE_ERROR_REFERSH_DECODE + ':\n\n' + str(e))
            return

        if not dict_configuration['modem_list']:
            self.cbox_mi_modem.clear()
            self.cbox_mi_modem.addItem('No modem available...')
            self.cbox_mi_modem.setEnabled(False)
        else:
            self.cbox_mi_modem.clear()
            self.cbox_mi_modem.setEnabled(True)

            for dict_modem in dict_configuration['modem_list']:
                self.cbox_mi_modem.addItem(dict_modem['name'])

                if self.image_version_lt_1_10:
                    self.cbox_mi_modem.setItemData(
                        self.cbox_mi_modem.count() - 1, dict_modem['vid_pid'])
                else:
                    self.cbox_mi_modem.setItemData(
                        self.cbox_mi_modem.count() - 1, dict_modem['imei'])

        if self.cbox_mi_modem.isEnabled():
            self.pbutton_mi_connect.setEnabled(True)
        else:
            self.pbutton_mi_connect.setEnabled(False)

        if dict_configuration['modem_configured']:
            for i in range(self.cbox_mi_modem.count()):
                if dict_configuration[
                        'modem_configured'] != self.cbox_mi_modem.itemData(i):
                    continue

                self.cbox_mi_modem.setCurrentIndex(i)
                break

        if not dict_configuration['dial']:
            self.ledit_mi_dial.setText('')
        else:
            self.ledit_mi_dial.setText(dict_configuration['dial'])

        if not dict_configuration['apn']:
            self.ledit_mi_apn.setText('')
        else:
            self.ledit_mi_apn.setText(dict_configuration['apn'])

        if not dict_configuration['username']:
            self.ledit_mi_username.setText('')
        else:
            self.ledit_mi_username.setText(dict_configuration['username'])

        if not dict_configuration['password']:
            self.ledit_mi_password.setText('')
        else:
            self.ledit_mi_password.setText(dict_configuration['password'])

        if not dict_configuration['sim_card_pin']:
            self.ledit_mi_sim_card_pin.setText('')
        else:
            self.ledit_mi_sim_card_pin.setText(
                dict_configuration['sim_card_pin'])
Exemplo n.º 35
0
    def cb_settings_fs_expand_check(self, result):
        if not self.is_tab_on_focus:
            return

        if not report_script_result(result, 'Settings | File System',
                                    'Error getting partition information'):
            self.label_fs_expand_info.hide()
            self.line.hide()
            self.label_pbar_fs_capacity_utilization.hide()
            self.pbar_fs_capacity_utilization.setMinimum(0)
            self.pbar_fs_capacity_utilization.setMaximum(100)
            self.pbar_fs_capacity_utilization.setValue(0)
            self.pbar_fs_capacity_utilization.setFormat('')
            self.pbar_fs_capacity_utilization.setEnabled(False)
            self.pbutton_fs_expand.setEnabled(False)
            return

        try:
            size_dict = json.loads(result.stdout)
            p1_start = float(size_dict['p1_start'])
            p1_size = float(size_dict['p1_size'])
            card_size = float(size_dict['card_size'])
            ext3_size = float(size_dict['ext3_size'])
        except:
            p1_start = 0
            p1_size = 100
            card_size = 100
            ext3_size = 100

        avialable_size = card_size - p1_start
        used_size = min(p1_size, ext3_size)

        percentage_utilization_v = min(int(math.ceil((used_size / avialable_size) * 100.0)), 100)

        # due to common file system overahead 100% will normally never be
        # reached just fake 100% in this case to avoid user confusion
        if percentage_utilization_v >= 95:
            percentage_utilization_v = 100

        percentage_utilization = unicode(percentage_utilization_v)

        self.pbar_fs_capacity_utilization.setEnabled(True)

        self.pbar_fs_capacity_utilization.setMinimum(0)
        self.pbar_fs_capacity_utilization.setMaximum(100)

        self.pbar_fs_capacity_utilization.setValue(percentage_utilization_v)

        if percentage_utilization_v == 100:
            self.pbutton_fs_expand.setEnabled(False)
            self.label_fs_expand_info.hide()
            self.line.hide()
        else:
            self.pbutton_fs_expand.setEnabled(True)
            self.label_fs_expand_info.show()
            self.line.show()

        pbar_fs_capacity_utilization_fmt = "Using {0}% of total capacity".format(percentage_utilization)

        if sys.platform == 'darwin':
            self.label_pbar_fs_capacity_utilization.show()
            self.label_pbar_fs_capacity_utilization.setText(pbar_fs_capacity_utilization_fmt)
        else:
            self.pbar_fs_capacity_utilization.setFormat(pbar_fs_capacity_utilization_fmt)
Exemplo n.º 36
0
                def cb_restart_reboot_shutdown(result):
                    self.progress.close()

                    report_script_result(
                        result, 'Import Error',
                        'Could not reboot RED Brick to finish program import')
Exemplo n.º 37
0
 def cb_delete(result):
     self.refresh_logs()
     report_script_result(result, 'Delete Logs Error', 'Could not delete selected logs')
Exemplo n.º 38
0
 def cb_delete(result):
     self.refresh_logs()
     report_script_result(result, 'Delete Logs Error', 'Could not delete selected logs')
Exemplo n.º 39
0
            def cb_settings_ap_get_interfaces(result):
                if not self.is_tab_on_focus:
                    return

                if not report_script_result(result, 'Settings | Access Point', 'Error getting access point interfaces:'):
                    return

                ap_mode_interfaces = json.loads(result.stdout)

                if len(ap_mode_interfaces) <= 0:
                    self.label_ap_status.setText('Inactive - No wireless interface available')
                    self.cbox_ap_interface.clear()
                    self.pbutton_ap_save.setEnabled(False)
                    self.update_ui_state()
                    return

                self.pbutton_ap_save.setEnabled(True)
                self.cbox_ap_interface.clear()

                self.cbox_ap_interface.currentIndexChanged.disconnect()

                for intf in ap_mode_interfaces:
                    self.cbox_ap_interface.addItem(intf)
                    current_item_index = self.cbox_ap_interface.count() - 1

                    if ap_mode_interfaces[intf]['ip']:
                        self.cbox_ap_interface.setItemData(current_item_index,
                                                            ap_mode_interfaces[intf]['ip'],
                                                            AP_INTERFACE_IP_USER_ROLE)
                    else:
                        self.cbox_ap_interface.setItemData(current_item_index,
                                                            '192.168.42.1',
                                                            AP_INTERFACE_IP_USER_ROLE)

                    if ap_mode_interfaces[intf]['mask']:
                        self.cbox_ap_interface.setItemData(current_item_index,
                                                            ap_mode_interfaces[intf]['mask'],
                                                            AP_INTERFACE_MASK_USER_ROLE)

                    else:
                        self.cbox_ap_interface.setItemData(current_item_index,
                                                            '255.255.255.0',
                                                            AP_INTERFACE_MASK_USER_ROLE)
                self.cbox_ap_interface.setCurrentIndex(-1)
                self.cbox_ap_interface.currentIndexChanged.connect(self.slot_cbox_ap_interface_current_index_changed)

                if not interface:
                    self.cbox_ap_interface.setCurrentIndex(0)

                elif not interface and self.cbox_ap_interface.count() > 0:
                    self.cbox_ap_interface.setCurrentIndex(0)

                else:
                    broke = False
                    for i in range(0, self.cbox_ap_interface.count()):
                        if self.cbox_ap_interface.itemText(i) == interface:
                            self.cbox_ap_interface.setCurrentIndex(i)
                            broke = True
                            break

                    if not broke:
                        self.cbox_ap_interface.setCurrentIndex(0)

                self.update_ui_state()
Exemplo n.º 40
0
 def cb_restart_reboot_shutdown(result):
     self.pbutton_fs_expand.setEnabled(False)
     report_script_result(result, 'Settings | File System',
                          'Error rebooting RED Brick')
    def cb_settings_mobile_internet_refresh(self, result):
        self.update_gui(EVENT_GUI_REFRESH_RETURNED)

        if not report_script_result(result, MESSAGEBOX_TITLE, MESSAGE_ERROR_REFERSH):
            return

        try:
            dict_configuration = json.loads(result.stdout)
        except Exception as e:
            QtGui.QMessageBox.critical(get_main_window(),
                                       MESSAGEBOX_TITLE,
                                       MESSAGE_ERROR_REFERSH_DECODE + ':\n\n' +str(e))
            return

        if not dict_configuration['modem_list']:
            self.cbox_mi_modem.clear()
            self.cbox_mi_modem.addItem('No modem available...')
            self.cbox_mi_modem.setEnabled(False)
        else:
            self.cbox_mi_modem.clear()
            self.cbox_mi_modem.setEnabled(True)

            for dict_modem in dict_configuration['modem_list']:
                self.cbox_mi_modem.addItem(dict_modem['name'])
                self.cbox_mi_modem.setItemData(self.cbox_mi_modem.count() - 1, dict_modem['vid_pid'])

        if self.cbox_mi_modem.isEnabled():
            self.pbutton_mi_connect.setEnabled(True)
        else:
            self.pbutton_mi_connect.setEnabled(False)

        if dict_configuration['modem_configured']:
            for i in range(self.cbox_mi_modem.count()):
                if dict_configuration['modem_configured'] != self.cbox_mi_modem.itemData(i):
                    continue
                
                self.cbox_mi_modem.setCurrentIndex(i)
                break

        if not dict_configuration['dial']:
            self.ledit_mi_dial.setText('')
        else:
            self.ledit_mi_dial.setText(dict_configuration['dial'])

        if not dict_configuration['apn']:
            self.ledit_mi_apn.setText('')
        else:
            self.ledit_mi_apn.setText(dict_configuration['apn'])
        
        if not dict_configuration['username']:
            self.ledit_mi_username.setText('')
        else:
            self.ledit_mi_username.setText(dict_configuration['username'])
        
        if not dict_configuration['password']:
            self.ledit_mi_password.setText('')
        else:
            self.ledit_mi_password.setText(dict_configuration['password'])

        if not dict_configuration['sim_card_pin']:
            self.ledit_mi_sim_card_pin.setText('')
        else:
            self.ledit_mi_sim_card_pin.setText(dict_configuration['sim_card_pin'])
                def cb_restart_reboot_shutdown(result):
                    self.progress.close()

                    report_script_result(result, 'Import Error', 'Could not reboot RED Brick to finish program import')
Exemplo n.º 43
0
 def cb_restart_reboot_shutdown(result):
     if not report_script_result(result, 'Settings | Services',
                                 'Error rebooting RED Brick'):
         done()
         return
Exemplo n.º 44
0
            def cb_settings_ap_get_interfaces(result):
                if not self.is_tab_on_focus:
                    return

                if not report_script_result(
                        result, 'Settings | Access Point',
                        'Error getting access point interfaces:'):
                    return

                ap_mode_interfaces = json.loads(result.stdout)

                if len(ap_mode_interfaces) <= 0:
                    self.label_ap_status.setText(
                        'Inactive - No wireless interface available')
                    self.cbox_ap_interface.clear()
                    self.pbutton_ap_save.setEnabled(False)
                    self.update_ui_state()
                    return

                self.pbutton_ap_save.setEnabled(True)
                self.cbox_ap_interface.clear()

                self.cbox_ap_interface.currentIndexChanged.disconnect()

                for intf in ap_mode_interfaces:
                    self.cbox_ap_interface.addItem(intf)
                    current_item_index = self.cbox_ap_interface.count() - 1

                    if ap_mode_interfaces[intf]['ip']:
                        self.cbox_ap_interface.setItemData(
                            current_item_index, ap_mode_interfaces[intf]['ip'],
                            AP_INTERFACE_IP_USER_ROLE)
                    else:
                        self.cbox_ap_interface.setItemData(
                            current_item_index, '192.168.42.1',
                            AP_INTERFACE_IP_USER_ROLE)

                    if ap_mode_interfaces[intf]['mask']:
                        self.cbox_ap_interface.setItemData(
                            current_item_index,
                            ap_mode_interfaces[intf]['mask'],
                            AP_INTERFACE_MASK_USER_ROLE)

                    else:
                        self.cbox_ap_interface.setItemData(
                            current_item_index, '255.255.255.0',
                            AP_INTERFACE_MASK_USER_ROLE)
                self.cbox_ap_interface.setCurrentIndex(-1)
                self.cbox_ap_interface.currentIndexChanged.connect(
                    self.slot_cbox_ap_interface_current_index_changed)

                if not interface:
                    self.cbox_ap_interface.setCurrentIndex(0)

                elif not interface and self.cbox_ap_interface.count() > 0:
                    self.cbox_ap_interface.setCurrentIndex(0)

                else:
                    broke = False
                    for i in range(0, self.cbox_ap_interface.count()):
                        if self.cbox_ap_interface.itemText(i) == interface:
                            self.cbox_ap_interface.setCurrentIndex(i)
                            broke = True
                            break

                    if not broke:
                        self.cbox_ap_interface.setCurrentIndex(0)

                self.update_ui_state()
 def cb_restart_reboot_shutdown(result):
     if not report_script_result(result, 'Settings | Services', 'Error rebooting RED Brick'):
         done()
         return