688 def update_routine(self):
689 """Main update routine with hardware version check."""
690 branch = self.config['branch']
691 venv_pip = self.base_path / "venv" / "bin" / "pip"
692 self.log(f"\n{Fore.CYAN}--- {self.t('update_fetching')} ---")
693
694
695 subprocess.run(["git", "fetch", "origin", branch], cwd=self.base_path)
696
697
698 self.check_and_update_hardware_tools()
699
700
701 local_hash = subprocess.run(
702 ["git", "rev-parse", "HEAD"],
703 cwd=self.base_path, capture_output=True, text=True).stdout.strip()
704 remote_hash = subprocess.run(
705 ["git", "rev-parse", f"origin/{branch}"],
706 cwd=self.base_path, capture_output=True, text=True).stdout.strip()
707 current_branch = subprocess.run(
708 ["git", "rev-parse", "--abbrev-ref", "HEAD"],
709 cwd=self.base_path, capture_output=True, text=True).stdout.strip()
710
711
712 if local_hash == remote_hash and current_branch == branch:
713 self.log(f"{Fore.GREEN}✔ {self.t('update_not_needed')} "
714 f"(Hash: {local_hash[:7]})")
715 return
716
717
718 self.log(f"{Fore.YELLOW}★ {self.t('update_found')} "
719 f"({local_hash[:7]} -> {remote_hash[:7]})")
720
721
722 confirm = input(Fore.RED + Style.BRIGHT + self.t('update_warning_changes')).lower()
723 if confirm != 'y':
724 self.log(Fore.YELLOW + self.t('update_cancel_changes'))
725 return
726
727
728
729 self.log(Fore.YELLOW + self.t('update_clean_local'))
730 subprocess.run(["git", "reset", "--hard", "HEAD"],
731 cwd=self.base_path, capture_output=True)
732
733
734 if current_branch != branch:
735 self.log(Fore.CYAN + f" → {self.t('update_branch_switch').format(branch)}")
736
737 subprocess.run(["git", "checkout", "-B", branch, f"origin/{branch}"],
738 cwd=self.base_path, capture_output=True)
739
740
741 self.log(Fore.YELLOW + f" → {self.t('update_resetting')}")
742 res = subprocess.run(["git", "reset", "--hard", f"origin/{branch}"],
743 cwd=self.base_path, capture_output=True)
744
745 if res.returncode != 0:
746 self.log(Fore.RED + self.t('update_error_git'))
747 return
748
749
750 diff = subprocess.run(
751 ["git", "diff", "--name-only", local_hash, remote_hash],
752 cwd=self.base_path, capture_output=True, text=True).stdout.splitlines()
753
754
755 self.safe_venv_cleanup()
756 self._sync_core_requirements()
757 self._update_pip_tracking()
758
759
760 if "requirements.txt" in diff:
761 self.run_with_progress([f"{venv_pip} install -r requirements.txt"], self.t('prog_pip_dev'))
762
763
764 if any('config/' in f for f in diff):
765 self.log(f"\n{Fore.CYAN}{self.t('menu_deps')}")
766 self.sync_dependencies()
767
768 self.log(f"\n{Fore.GREEN}{self.t('dep_success')}")
769
770
771 self.setup_example_configs()
772
773
774 self.save_config()
775 self.restart_active_services()
776 self.log(f"\n{Fore.GREEN}{Style.BRIGHT}{self.t('update_success')}")
777
778
779 self.ask_for_reboot()
780