diff --git a/downloader.py b/downloader.py index 236b172..b1be0c1 100644 --- a/downloader.py +++ b/downloader.py @@ -29,8 +29,16 @@ class CopernicusDownloader: self.download(self.output_file) self.apply_setreftime(self.output_file,self.prepared_file) self.convert_to_grib2(self.prepared_file,self.output_grib) + self.file_remove(self.output_file) return self.output_grib + def file_remove(self,file): + if os.path.exists(file): + os.remove(file) + print(f"✅ File removed : {file}") + else: + print(f"❌ File {file} does not exist.") + def download(self,outfile): today = datetime.utcnow() start_date = today.strftime("%Y-%m-%dT00:00:00") diff --git a/iface.py b/iface.py index b78729f..8249e6e 100644 --- a/iface.py +++ b/iface.py @@ -7,6 +7,7 @@ import os import platform import subprocess import configparser +import webbrowser from math import log, tan, radians, pi, degrees, atan, sinh from downloader import CopernicusDownloader @@ -16,7 +17,7 @@ CONFIG_FILE = "config.ini" class MapSelector: def __init__(self, root): self.root = root - self.root.title("Copernicus Marine Downloader") + self.root.title("Surface Current Downloader") self.config = configparser.ConfigParser() self.load_config() @@ -26,9 +27,11 @@ class MapSelector: self.frame_download = ttk.Frame(self.notebook) self.frame_config = ttk.Frame(self.notebook) + self.frame_about = ttk.Frame(self.notebook) - self.notebook.add(self.frame_download, text="Téléchargement") + self.notebook.add(self.frame_download, text="Download Manager") self.notebook.add(self.frame_config, text="Configuration") + self.notebook.add(self.frame_about, text="About") self.downloader = CopernicusDownloader( username=self.config.get("AUTH", "username", fallback=""), @@ -108,7 +111,7 @@ class MapSelector: self.duration_var = tk.StringVar(value="3") ttk.Label(params_frame, text="Days").grid(row=0, column=6) - ttk.Combobox(params_frame, textvariable=self.duration_var, values=["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"], width=5).grid(row=1, column=6) + ttk.Combobox(params_frame, textvariable=self.duration_var, values=["1", "2", "3", "4", "5", "6", "7", "8", "9"], width=5).grid(row=1, column=6) btn_frame = ttk.Frame(self.frame_download) btn_frame.pack(pady=5) @@ -182,14 +185,21 @@ class MapSelector: self.redraw_rectangle_from_coords() + def open_link(self, event=None): + webbrowser.open_new("https://data.marine.copernicus.eu/register") + def setup_config_tab(self): frame = self.frame_config - ttk.Label(frame, text="Nom d'utilisateur Copernicus Marine:").pack(pady=5) + ttk.Label(frame, text="Use the credential of your account ").pack(pady=5) + account_link = tk.Label(frame, text="register on https://data.marine.copernicus.eu/register",fg="blue",cursor="hand2") + account_link.pack(pady=5) + account_link.bind("", self.open_link) + ttk.Label(frame, text="Copernicus Marine 'username'").pack(pady=5) self.username_var = tk.StringVar(value=self.config.get("AUTH", "username", fallback="")) ttk.Entry(frame, textvariable=self.username_var, width=30).pack() - ttk.Label(frame, text="Mot de passe:").pack(pady=5) + ttk.Label(frame, text="Copernicus Marine 'password'").pack(pady=5) self.password_var = tk.StringVar(value=self.config.get("AUTH", "password", fallback="")) ttk.Entry(frame, textvariable=self.password_var, show="*", width=30).pack() @@ -309,10 +319,10 @@ class MapSelector: lon_max = float(self.lon2_var.get()) days = int(self.duration_var.get()) except ValueError: - messagebox.showerror("Erreur", "Veuillez entrer des coordonnées et durée valides.") + messagebox.showerror("❌ Erreur", "Veuillez entrer des coordonnées et durée valides.") return self.progress.start(10) - self.status.config(text="Téléchargement en cours...") + self.status.config(text="✅ Téléchargement en cours...") threading.Thread(target=self.download, args=(lat_min, lat_max, lon_min, lon_max, days), daemon=True).start() def download(self, lat_min, lat_max, lon_min, lon_max, days): @@ -321,9 +331,9 @@ class MapSelector: grib_path = self.downloader.retrieve_grib2(lat_min, lat_max, lon_min, lon_max, days) #self.status.config(text="Conversion en GRIB2 en cours...") #grib_path = self.downloader.convert_to_grib2() - self.status.config(text=f"Téléchargement et conversion terminés : {os.path.basename(grib_path)}") + self.status.config(text=f"✅ Téléchargement et conversion terminés : {os.path.basename(grib_path)}") except Exception as e: - self.status.config(text=f"Erreur : {e}") + self.status.config(text=f"❌ Erreur : {e}") finally: self.progress.stop()