From 514a6c78b593107ad45e188c7ea7573b65f05a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 14 Jul 2026 19:13:05 +0200 Subject: [PATCH] =?UTF-8?q?Ordnerstruktur=20f=C3=BCr=20Mesa=20und=20Astrom?= =?UTF-8?q?etry=20aufr=C3=A4umen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AstroMac.json => astrometry/AstroMac.json | 0 .../astrometry_gui.py | 88 +++++++++++++++---- .../profiles}/HU 0815.json | 10 +-- .../ssh-zugangsdaten.txt | 0 .../ssh_zugangsdaten.json | 0 astrometry_gui.bat | 2 +- .../mesa_gui_einstellungen_beteigeuze.json | 0 .../mesa_gui_einstellungen_sonne.json | 0 mesa_star_gui.py => mesa/mesa_star_gui.py | 0 mesa_star_gui.bat | 2 +- profiles/Test.json | 60 ------------- 11 files changed, 76 insertions(+), 86 deletions(-) rename AstroMac.json => astrometry/AstroMac.json (100%) rename astrometry_gui.py => astrometry/astrometry_gui.py (95%) rename {profiles => astrometry/profiles}/HU 0815.json (89%) rename ssh-zugangsdaten.txt => astrometry/ssh-zugangsdaten.txt (100%) rename ssh_zugangsdaten.json => astrometry/ssh_zugangsdaten.json (100%) rename mesa_gui_einstellungen_beteigeuze.json => mesa/mesa_gui_einstellungen_beteigeuze.json (100%) rename mesa_gui_einstellungen_sonne.json => mesa/mesa_gui_einstellungen_sonne.json (100%) rename mesa_star_gui.py => mesa/mesa_star_gui.py (100%) delete mode 100644 profiles/Test.json diff --git a/AstroMac.json b/astrometry/AstroMac.json similarity index 100% rename from AstroMac.json rename to astrometry/AstroMac.json diff --git a/astrometry_gui.py b/astrometry/astrometry_gui.py similarity index 95% rename from astrometry_gui.py rename to astrometry/astrometry_gui.py index 43aadcf..74a0ca9 100644 --- a/astrometry_gui.py +++ b/astrometry/astrometry_gui.py @@ -27,7 +27,9 @@ except ImportError: HAS_ASYNCSSH = False -SSH_CREDENTIALS_JSON = "ssh_zugangsdaten.json" +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) +SSH_CREDENTIALS_JSON = os.path.join(SCRIPT_DIR, "ssh_zugangsdaten.json") +PROFILE_DIR = os.path.join(SCRIPT_DIR, "profiles") # --------------------------------------------------------------------------- @@ -219,6 +221,8 @@ class AstrometryGUI: self.v_port = tk.IntVar(value=22) self.v_user = tk.StringVar(value="eskimue") self.v_pass = tk.StringVar(value="Preside") + self.v_profile_name = tk.StringVar() + self._profile_names: list[str] = [] self._load_startup_credentials() self.v_local_file = tk.StringVar() @@ -281,11 +285,10 @@ class AstrometryGUI: self.results_files: dict[str, dict] = {} def _load_startup_credentials(self): - path = os.path.join(os.getcwd(), SSH_CREDENTIALS_JSON) - if not os.path.isfile(path): + if not os.path.isfile(SSH_CREDENTIALS_JSON): return try: - self._load_credentials_from_file(path) + self._load_credentials_from_file(SSH_CREDENTIALS_JSON) except Exception: pass @@ -311,6 +314,7 @@ class AstrometryGUI: top = ttk.Frame(self.root, padding=4) top.pack(fill=tk.X) self._build_conn_bar(top) + self._refresh_profile_list() self.nb = ttk.Notebook(self.root) self.nb.pack(fill=tk.BOTH, expand=True, padx=6, pady=(0, 4)) @@ -406,8 +410,23 @@ class AstrometryGUI: "Öffnet eine asynchrone SSH-Verbindung und prüft ob solve-field verfügbar ist." ).grid(row=0, column=8, padx=4) + ttk.Label(lf, text="Profil:").grid(row=0, column=9, padx=(12, 2), sticky=tk.W) + self.profile_combo = ttk.Combobox( + lf, + textvariable=self.v_profile_name, + state="readonly", + width=24, + ) + self.profile_combo.grid(row=0, column=10, padx=(0, 4)) + self.profile_combo.bind("<>", self._on_profile_selected) + tip(self.profile_combo, "Lädt ein gespeichertes Profil direkt aus dem profiles-Ordner.") + + tip(ttk.Button(lf, text="Liste aktualisieren", command=self._refresh_profile_list), + "Liest den profiles-Ordner neu ein und aktualisiert die Dropdown-Liste." + ).grid(row=0, column=11, padx=4) + self.conn_label = ttk.Label(lf, text="● nicht verbunden", foreground="gray") - self.conn_label.grid(row=0, column=9, padx=6) + self.conn_label.grid(row=0, column=12, padx=6) # ----------------------------------------------------------------------- # Tab: Input / Output @@ -1381,7 +1400,7 @@ class AstrometryGUI: def _collect_profile_data(self) -> dict: vars_data = {} for name, value in self.__dict__.items(): - if name.startswith("v_") and hasattr(value, "get"): + if name.startswith("v_") and name != "v_profile_name" and hasattr(value, "get"): vars_data[name] = value.get() if "v_pass" in vars_data: vars_data["v_pass"] = "" @@ -1416,12 +1435,52 @@ class AstrometryGUI: self._refresh_cmd() + def _list_profile_names(self) -> list[str]: + if not os.path.isdir(PROFILE_DIR): + return [] + return sorted( + entry.name + for entry in os.scandir(PROFILE_DIR) + if entry.is_file() and entry.name.lower().endswith(".json") + ) + + def _refresh_profile_list(self, selected_name: str | None = None): + self._profile_names = self._list_profile_names() + if hasattr(self, "profile_combo"): + self.profile_combo["values"] = self._profile_names + + if selected_name in self._profile_names: + self.v_profile_name.set(selected_name) + elif self.v_profile_name.get() not in self._profile_names: + self.v_profile_name.set("") + + def _load_profile_from_path(self, path: str): + with open(path, "r", encoding="utf-8") as f: + data = json.load(f) + self._apply_profile_data(data) + + if os.path.dirname(os.path.abspath(path)) == os.path.abspath(PROFILE_DIR): + self._refresh_profile_list(os.path.basename(path)) + else: + self._refresh_profile_list() + + self._log(f"[OK] Profil geladen: {path}\n", "ok") + + def _on_profile_selected(self, _event=None): + profile_name = self.v_profile_name.get().strip() + if not profile_name: + return + path = os.path.join(PROFILE_DIR, profile_name) + try: + self._load_profile_from_path(path) + except Exception as exc: + messagebox.showerror("Profil laden", f"Laden fehlgeschlagen:\n{exc}") + def _save_profile(self): - profile_dir = os.path.join(os.getcwd(), "profiles") - os.makedirs(profile_dir, exist_ok=True) + os.makedirs(PROFILE_DIR, exist_ok=True) path = filedialog.asksaveasfilename( title="Profil speichern", - initialdir=profile_dir, + initialdir=PROFILE_DIR, defaultextension=".json", filetypes=[("JSON-Dateien", "*.json"), ("Alle Dateien", "*.*")], ) @@ -1431,31 +1490,28 @@ class AstrometryGUI: try: with open(path, "w", encoding="utf-8") as f: json.dump(data, f, ensure_ascii=False, indent=2) + self._refresh_profile_list(os.path.basename(path)) self._log(f"[OK] Profil gespeichert: {path}\n", "ok") except Exception as exc: messagebox.showerror("Profil speichern", f"Speichern fehlgeschlagen:\n{exc}") def _load_profile(self): - profile_dir = os.path.join(os.getcwd(), "profiles") path = filedialog.askopenfilename( title="Profil laden", - initialdir=profile_dir if os.path.isdir(profile_dir) else os.getcwd(), + initialdir=PROFILE_DIR if os.path.isdir(PROFILE_DIR) else SCRIPT_DIR, filetypes=[("JSON-Dateien", "*.json"), ("Alle Dateien", "*.*")], ) if not path: return try: - with open(path, "r", encoding="utf-8") as f: - data = json.load(f) - self._apply_profile_data(data) - self._log(f"[OK] Profil geladen: {path}\n", "ok") + self._load_profile_from_path(path) except Exception as exc: messagebox.showerror("Profil laden", f"Laden fehlgeschlagen:\n{exc}") def _menu_load_credentials(self): path = filedialog.askopenfilename( title="Zugangsdaten laden", - initialdir=os.getcwd(), + initialdir=SCRIPT_DIR, filetypes=[("JSON-Dateien", "*.json"), ("Alle Dateien", "*.*")], ) if not path: diff --git a/profiles/HU 0815.json b/astrometry/profiles/HU 0815.json similarity index 89% rename from profiles/HU 0815.json rename to astrometry/profiles/HU 0815.json index 0f1da39..6e61f3e 100644 --- a/profiles/HU 0815.json +++ b/astrometry/profiles/HU 0815.json @@ -1,10 +1,6 @@ { "format": 2, "variables": { - "v_host": "10.42.44.25", - "v_port": 22, - "v_user": "eskimue", - "v_pass": "", "v_local_file": "", "v_remote_dir": "/tmp/astrometry", "v_input_file": "", @@ -53,8 +49,6 @@ "v_invert": true, "v_extra": "" }, - "secrets": { - "v_pass_enc": "EQERAQYJAA==" - }, + "secrets": {}, "idx_text": "" -} \ No newline at end of file +} diff --git a/ssh-zugangsdaten.txt b/astrometry/ssh-zugangsdaten.txt similarity index 100% rename from ssh-zugangsdaten.txt rename to astrometry/ssh-zugangsdaten.txt diff --git a/ssh_zugangsdaten.json b/astrometry/ssh_zugangsdaten.json similarity index 100% rename from ssh_zugangsdaten.json rename to astrometry/ssh_zugangsdaten.json diff --git a/astrometry_gui.bat b/astrometry_gui.bat index 9a69753..feed633 100644 --- a/astrometry_gui.bat +++ b/astrometry_gui.bat @@ -14,4 +14,4 @@ if errorlevel 1 ( pip install paramiko ) -python astrometry_gui.py +python astrometry\astrometry_gui.py diff --git a/mesa_gui_einstellungen_beteigeuze.json b/mesa/mesa_gui_einstellungen_beteigeuze.json similarity index 100% rename from mesa_gui_einstellungen_beteigeuze.json rename to mesa/mesa_gui_einstellungen_beteigeuze.json diff --git a/mesa_gui_einstellungen_sonne.json b/mesa/mesa_gui_einstellungen_sonne.json similarity index 100% rename from mesa_gui_einstellungen_sonne.json rename to mesa/mesa_gui_einstellungen_sonne.json diff --git a/mesa_star_gui.py b/mesa/mesa_star_gui.py similarity index 100% rename from mesa_star_gui.py rename to mesa/mesa_star_gui.py diff --git a/mesa_star_gui.bat b/mesa_star_gui.bat index 0370a3a..2f80632 100644 --- a/mesa_star_gui.bat +++ b/mesa_star_gui.bat @@ -14,4 +14,4 @@ if errorlevel 1 ( pip install asyncssh ) -python mesa_star_gui.py +python mesa\mesa_star_gui.py diff --git a/profiles/Test.json b/profiles/Test.json deleted file mode 100644 index 10b0bb5..0000000 --- a/profiles/Test.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "format": 2, - "variables": { - "v_host": "10.42.44.25", - "v_port": 22, - "v_user": "eskimue", - "v_pass": "", - "v_local_file": "C:/Users/ich/Cloud__Museum/Museumsentwicklung/Shop/Faksimile/2026/Heinlein Dieter/IMG_410328-1956_08_30-20000+2000-Te3-26-50.png", - "v_remote_dir": "/tmp/astrometry", - "v_input_file": "/tmp/astrometry/IMG_410328-1956_08_30-20000+2000-Te3-26-50.png", - "v_out_prefix": "", - "v_out_dir": "/tmp/astrometry", - "v_new_fits": "/tmp/astrometry/IMG_410328-1956_08_30-20000+2000-Te3-26-50.fits", - "v_wcs": "", - "v_corr": "", - "v_rdls": "", - "v_axy": "", - "v_solved": "", - "v_match": "", - "v_scale_units": "degwidth", - "v_scale_low": "20", - "v_scale_high": "30", - "v_scale_est": "", - "v_scale_err": "", - "v_ra": "", - "v_dec": "", - "v_radius": "1.0", - "v_depth": "", - "v_cpulimit": "300", - "v_plot_scale": "0.15", - "v_plot_scale_auto": true, - "v_plot_target_long_edge": "900", - "v_downsample": "6", - "v_tweak_order": "2", - "v_odds_solve": "", - "v_odds_reject": "", - "v_odds_tune": "", - "v_objs": "", - "v_pixel_error": "", - "v_parity": "both", - "v_overwrite": true, - "v_no_plots": false, - "v_no_tweak": false, - "v_resort": false, - "v_verbose": false, - "v_timestamp": true, - "v_no_del_temp": false, - "v_continue": false, - "v_sextractor": false, - "v_fits_image": false, - "v_no_verify": false, - "v_just_augment": false, - "v_invert": true, - "v_extra": "" - }, - "secrets": { - "v_pass_enc": "EQERAQYJAA==" - }, - "idx_text": "" -} \ No newline at end of file