示例#1
0
    def download_logs_to_usb(self):
        self.usb_stick.enable()
        message = self.l.get_str('Downloading logs, please wait') + '...'
        wait_popup = popup_info.PopupWait(self.sm, self.l, description = message)
        count = 0

        def get_logs(count):
            if self.usb_stick.is_usb_mounted_flag == True:
                os.system("journalctl > smartbench_logs.txt && sudo cp --no-preserve=mode,ownership smartbench_logs.txt /media/usb/ && rm smartbench_logs.txt")
                wait_popup.popup.dismiss()
                self.usb_stick.disable()

                message = self.l.get_str('Logs downloaded')
                popup_info.PopupMiniInfo(self.sm, self.l, description = message)

            elif count > 30:
                message = self.l.get_str('No USB found!')
                popup_info.PopupMiniInfo(self.sm, self.l, description = message)
                wait_popup.popup.dismiss()
                if self.usb_stick.is_available(): self.usb_stick.disable()

            else:
                count +=1
                Clock.schedule_once(lambda dt: get_logs(count), 0.2)
                print count


        Clock.schedule_once(lambda dt: get_logs(count), 0.2)
示例#2
0
    def checkout_branch(self):
        if sys.platform != 'win32' and sys.platform != 'darwin':

            message = (
                self.l.get_str('Please wait') + \
                '...\n' + \
                self.l.get_str('Console will reboot to finish update.')
                )
            wait_popup = popup_info.PopupWait(self.systemtools_sm.sm,
                                              self.l,
                                              description=message)

            def nested_branch_update(dt):

                # Update config as for any other SW release
                self.set.update_config()

                # Strip whitespace
                branch_name_formatted = str(self.user_branch.text).translate(
                    None, ' ')

                os.system(
                    "cd /home/pi/easycut-smartbench/ && git fetch origin && git checkout "
                    + branch_name_formatted)
                os.system("git pull")
                self.set.ansible_service_run_without_reboot()
                wait_popup.popup.dismiss()
                self.systemtools_sm.sm.current = 'rebooting'

            Clock.schedule_once(nested_branch_update, 0.5)
    def refresh_available_networks(self):
        wait_popup = popup_info.PopupWait(self.sm, self.l)
        Clock.schedule_once(lambda dt: wait_popup.popup.dismiss(), 0.5)

        def get_networks():
            self.network_name.values = self.get_available_networks()

        Clock.schedule_once(lambda dt: get_networks(), 0.2)        
示例#4
0
    def open_data_consent_app(self):

        wait_popup = popup_info.PopupWait(
            self.systemtools_sm.sm, self.l,
            self.l.get_str("Loading Data and Wi-Fi") + "...")

        def nested_open_data_consent_app(dt):
            self.data_consent_app = screen_manager_data_consent.ScreenManagerDataConsent(
                None, self.systemtools_sm.sm, self.l)
            self.data_consent_app.open_data_consent('build_info', 'build_info')
            wait_popup.popup.dismiss()

        Clock.schedule_once(nested_open_data_consent_app, 0.2)
示例#5
0
        def get_report(count):
            if self.usb_stick.is_usb_mounted_flag == True:
                message = 'Downloading report, please wait...'
                wait_popup = popup_info.PopupWait(self.sm,
                                                  self.l,
                                                  description=message)
                self.write_report_to_file()
                wait_popup.popup.dismiss()
                self.usb_stick.disable()
                message = self.l.get_str('Report downloaded')
                popup_info.PopupMiniInfo(self.sm, self.l, description=message)

            elif count > 30:
                if self.usb_stick.is_available(): self.usb_stick.disable()

            else:
                count += 1
                Clock.schedule_once(lambda dt: get_report(count), 0.2)
    def get_sw_update_over_wifi(self):

        updating_wait_popup = popup_info.PopupWait(self.sm, self.l)

        def do_sw_update():

            outcome = self.set.get_sw_update_via_wifi()

            if outcome == False:
                description = self.l.get_str("There was a problem updating your software.") + \
                " \n\n" + \
                self.l.get_str("We can try to fix the problem, but you MUST have a stable internet connection and power supply.") + \
                "\n\n" + \
                self.l.get_str("Would you like to repair your software now?")
                popup_info.PopupSoftwareRepair(self.sm, self.l, self,
                                               description)

            elif outcome == "Software already up to date!":
                description = self.l.get_str("Software already up to date!")
                popup_info.PopupError(self.sm, self.l, description)

            elif "Could not resolve host: github.com" in outcome:
                description = self.l.get_str(
                    "Could not connect to github. Please check that your connection is stable, or try again later."
                )
                popup_info.PopupError(self.sm, self.l, description)

            else:
                popup_info.PopupSoftwareUpdateSuccess(self.sm, self.l, outcome)
                self.set.ansible_service_run()
                message = (
                    self.l.get_str('Please wait') + \
                    '...\n\n' + \
                    self.l.get_str('Console will reboot to finish update.')
                    )

                Clock.schedule_once(
                    lambda dt: popup_info.PopupMiniInfo(
                        self.sm, self.l, message), 3)

            Clock.schedule_once(lambda dt: updating_wait_popup.popup.dismiss(),
                                0.1)

        Clock.schedule_once(lambda dt: do_sw_update(), 2)
示例#7
0
    def reinstall_pika(self):

        message = self.l.get_str('Please wait') + '...'
        wait_popup = popup_info.PopupWait(self.sm, self.l, description = message)

        def do_reinstall():

            try: 
                os.system('python -m pip uninstall pika -y')
                os.system('python -m pip install pika==1.2.0')
                os.system('sudo reboot')
                wait_popup.popup.dismiss()

            except:
                message = self.l.get_str('Issue trying to reinstall pika!')
                popup_info.PopupMiniInfo(self.sm, self.l, description = message)
                wait_popup.popup.dismiss()

        Clock.schedule_once(lambda dt: do_reinstall(), 0.2)
    def prep_for_sw_update_over_usb(self):
        self.set.usb_or_wifi = "USB"
        wait_popup = popup_info.PopupWait(self.sm, self.l)

        def check_connection_and_version():
            if self.usb_image.source != self.usb_on:
                description = self.l.get_str("No USB drive found!")
                popup_info.PopupError(self.sm, self.l, description)
                wait_popup.popup.dismiss()
                return

            if self.set.latest_sw_version.endswith('beta'):
                wait_popup.popup.dismiss()
                popup_update_SW.PopupBetaUpdate(self.sm, 'usb')
                return

            Clock.schedule_once(lambda dt: wait_popup.popup.dismiss(), 0.2)
            self.get_sw_update_over_usb()

        Clock.schedule_once(lambda dt: check_connection_and_version(), 3)
示例#9
0
    def check_git_repository(self):

        message = self.l.get_str("Please wait")
        wait_popup = popup_info.PopupWait(self.sm, self.l, description = message)


        def nested_check_git_repository(dt):

            if self.set.do_git_fsck():
                message = self.l.get_str("No errors found. You're good to go!")
                popup_system.PopupFSCKGood(self.sm, self.l, message, self.set.details_of_fsck)

            else: 
                message =   self.l.get_str("Errors found!") + "\n" + \
                            self.l.get_str("Contact us at https://www.yetitool.com/support")

                popup_system.PopupFSCKErrors(self.sm, self.l, message, self.set.details_of_fsck)

            wait_popup.popup.dismiss()

        Clock.schedule_once(nested_check_git_repository, 0.1)
示例#10
0
    def restore_grbl_settings_from_usb(self):
        self.usb_stick.enable()
        message = self.l.get_str('Restoring grbl settings, please wait') + '...'
        wait_popup = popup_info.PopupWait(self.sm, self.l, description = message)

        def get_grbl_settings_from_usb():
          if self.usb_stick.is_usb_mounted_flag == True:
              filename = '/media/usb/saved_grbl_settings_params.txt'
              success_flag = self.m.restore_grbl_settings_from_file(filename)
              wait_popup.popup.dismiss()
              self.usb_stick.disable()
              if success_flag:
                  message = self.l.get_str('GRBL settings restored!')
                  popup_info.PopupMiniInfo(self.sm, self.l, description = message)
              else:
                  message = self.l.get_str('Could not restore settings, please check file!')
                  popup_info.PopupMiniInfo(self.sm, self.l, description = message)

          else:
              Clock.schedule_once(lambda dt: get_grbl_settings_from_usb(), 0.2)

        Clock.schedule_once(lambda dt: get_grbl_settings_from_usb(), 0.2)
示例#11
0
    def download_grbl_settings_to_usb(self): # system tools manager
        self.m.save_grbl_settings()

        self.usb_stick.enable()
        message = self.l.get_str('Downloading grbl settings, please wait') + '...'
        wait_popup = popup_info.PopupWait(self.sm, self.l, description = message)

        def get_grbl_settings_onto_usb():
          if self.usb_stick.is_usb_mounted_flag == True:
              os.system("sudo cp --no-preserve=mode,ownership /home/pi/easycut-smartbench/src/sb_values/saved_grbl_settings_params.txt /media/usb/")
              os.system("rm /home/pi/easycut-smartbench/src/sb_values/saved_grbl_settings_params.txt")

              wait_popup.popup.dismiss()
              self.usb_stick.disable()

              message = self.l.get_str('GRBL settings downloaded')
              popup_info.PopupMiniInfo(self.sm, self.l, description = message)

          else:
              Clock.schedule_once(lambda dt: get_grbl_settings_onto_usb(), 0.2)

        Clock.schedule_once(lambda dt: get_grbl_settings_onto_usb(), 0.2)
示例#12
0
 def do_usb_first_aid(self):
     message = self.l.get_str('Ensuring USB is unmounted, please wait...')
     wait_popup = popup_info.PopupWait(self.sm, self.l, description = message)
     umount_out = (str(os.popen("sudo umount /media/usb/").read())) # using popen for the block
     popup_system.PopupUSBFirstAid(self, self.l)
     wait_popup.popup.dismiss()
    def get_sw_update_over_usb(self):

        popup_info.PopupWait(self.sm, self.l)

        def do_sw_update():
            outcome = self.set.get_sw_update_via_usb()

            if outcome == 2:
                description = (
                    self.l.get_str("More than one folder called easycut-smartbench was found on the USB drive.").replace(
                        self.l.get_str('easycut-smartbench'), "[b]easycut-smartbench[/b]"
                        ) + \
                    "\n\n" + \
                    self.l.get_str("Please make sure that there is only one instance of easycut-smartbench on your USB drive, and try again.").replace(
                        self.l.get_str('easycut-smartbench'), "[b]easycut-smartbench[/b]"
                        )
                    )
                popup_info.PopupError(self.sm, self.l, description)

            elif outcome == 0:
                description = (
                    self.l.get_str("There was no folder or zipped folder called easycut-smartbench found on the USB drive.").replace(
                        self.l.get_str('easycut-smartbench'), "[b]easycut-smartbench[/b]"
                        ) + \
                    "\n\n" + \
                    self.l.get_str("Please make sure that the folder containing the software is called easycut-smartbench, and try again.").replace(
                        self.l.get_str('easycut-smartbench'), "[b]easycut-smartbench[/b]"
                        )
                    )
                popup_info.PopupError(self.sm, self.l, description)

            elif outcome == "update failed":

                description = (
                    self.l.get_str("It was not possible to update your software from the USB drive.") + \
                    "\n\n" + \
                    self.l.get_str("Please check your easycut-smartbench folder or try again later.").replace(
                        self.l.get_str('easycut-smartbench'), "[b]easycut-smartbench[/b]"
                        ) + \
                    " " + \
                    self.l.get_str("If this problem persists you may need to connect to the internet to update your software, and repair it if necessary.")
                    )

                popup_info.PopupError(self.sm, self.l, description)

            else:
                self.usb_stick.disable()
                update_success = outcome
                popup_info.PopupSoftwareUpdateSuccess(self.sm, self.l,
                                                      update_success)
                self.set.ansible_service_run()
                message = (
                    self.l.get_str('Please wait') + \
                    '...\n\n' + \
                    self.l.get_str('Console will reboot to finish update.')
                    )

                Clock.schedule_once(
                    lambda dt: popup_info.PopupMiniInfo(
                        self.sm, self.l, message), 3)

        Clock.schedule_once(lambda dt: do_sw_update(), 2)