From aa48b21ad3658ed14c328471bcd5884f6105d1a7 Mon Sep 17 00:00:00 2001 From: annapurna-gupta Date: Tue, 6 May 2025 22:32:37 +0530 Subject: [PATCH 1/4] added path and option to overwite --- mslib/msui/constants.py | 1 + mslib/utils/mssautoplot.py | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mslib/msui/constants.py b/mslib/msui/constants.py index b4590b6c5..25b0799f4 100644 --- a/mslib/msui/constants.py +++ b/mslib/msui/constants.py @@ -67,6 +67,7 @@ # ToDo refactor to a function MSS_AUTOPLOT = os.getenv('MSS_AUTOPLOT', os.path.join(MSUI_CONFIG_PATH, "mssautoplot.json")) +DEFAULT_FTML_PATH = os.getenv('MSS_FTML_PATH', os.path.join(MSUI_CONFIG_PATH, "example_flight.ftml")) # We try to create an empty MSUI_SETTINGS file if not existing # but there can be a permission problem diff --git a/mslib/utils/mssautoplot.py b/mslib/utils/mssautoplot.py index 3220eae88..e29227ce8 100644 --- a/mslib/utils/mssautoplot.py +++ b/mslib/utils/mssautoplot.py @@ -62,6 +62,7 @@ from mslib.utils.auth import get_auth_from_url_and_name from mslib.utils.loggerdef import configure_mpl_logger from mslib.utils.verify_user_token import verify_user_token +from mslib.msui.constants import DEFAULT_FTML_PATH TEXT_CONFIG = { @@ -234,15 +235,14 @@ def __init__(self, cpath, msc_url=None, msc_auth_password=None, username=None, p if filename != "" and filename == flight: self.read_operation(flight, msc_url, msc_auth_password, username, password) elif filename != "": - # Todo add the dir to the file in the mssautoplot.json - dirpath = "./" - file_path = os.path.join(dirpath, filename) + file_path = DEFAULT_FTML_PATH exists = os.path.exists(file_path) if not exists: print("Filename {} doesn't exist".format(filename)) - self.pdlg.close() + if self.pdlg: + self.pdlg.close() raise SystemExit("Filename {} doesn't exist".format(filename)) - self.read_ftml(filename) + self.read_ftml(DEFAULT_FTML_PATH) def setup(self): pass @@ -260,7 +260,7 @@ def update_path(self, filename=None): """ # plot path and label if filename != "": - self.read_ftml(filename) + self.read_ftml(DEFAULT_FTML_PATH) self.fig.canvas.draw() self.plotter.update_from_waypoints(self.wp_model_data) self.plotter.redraw_path(waypoints_model_data=self.wp_model_data) @@ -275,6 +275,8 @@ def update_path_ops(self, filename=None): self.plotter.redraw_path(waypoints_model_data=self.wp_model_data) def read_ftml(self, filename): + if filename is None: + filename = DEFAULT_FTML_PATH self.wps, self.wp_model_data = load_from_ftml(filename) self.wp_lats, self.wp_lons, self.wp_locs = [[x[i] for x in self.wps] for i in [0, 1, 3]] self.wp_press = [mslib.utils.thermolib.flightlevel2pressure(wp[2] * units.hft).to("Pa").m for wp in self.wps] @@ -411,7 +413,7 @@ def update_path(self, filename=None): """ # plot path and label if filename != "": - self.read_ftml(filename) + self.read_ftml(DEFAULT_FTML_PATH) self.fig.canvas.draw() self.plotter.update_from_waypoints(self.wp_model_data) indices = list(zip(self.intermediate_indexes, self.wp_press)) @@ -509,7 +511,7 @@ def setup(self): def update_path(self, filename=None): self.setup() if filename != "": - self.read_ftml(filename) + self.read_ftml(DEFAULT_FTML_PATH) highlight = [[wp[0], wp[1]] for wp in self.wps] self.myfig.draw_vertical_lines(highlight, self.lats, self.lons) @@ -582,7 +584,7 @@ def draw(self, flight, section, vertical, filename, init_time, time, url, layer, @click.command() @click.option('--cpath', default=constants.MSS_AUTOPLOT, help='Path of the configuration file.') @click.option('--view', default="top", help='View of the plot (top/side/linear).') -@click.option('--ftrack', default="", help='Flight track.') +@click.option('--ftrack', type=click.Path(exists=True), help='Path to the .ftml file') @click.option('--itime', default="", help='Initial time.') @click.option('--vtime', default="", help='Valid time.') @click.option('--intv', default=0, help='Time interval.') From 798483c6425adbfed39a20145596788acea20e50 Mon Sep 17 00:00:00 2001 From: annapurna-gupta Date: Fri, 23 May 2025 01:42:10 +0530 Subject: [PATCH 2/4] update changes --- mslib/msui/constants.py | 1 - mslib/utils/mssautoplot.py | 34 ++++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/mslib/msui/constants.py b/mslib/msui/constants.py index 25b0799f4..b4590b6c5 100644 --- a/mslib/msui/constants.py +++ b/mslib/msui/constants.py @@ -67,7 +67,6 @@ # ToDo refactor to a function MSS_AUTOPLOT = os.getenv('MSS_AUTOPLOT', os.path.join(MSUI_CONFIG_PATH, "mssautoplot.json")) -DEFAULT_FTML_PATH = os.getenv('MSS_FTML_PATH', os.path.join(MSUI_CONFIG_PATH, "example_flight.ftml")) # We try to create an empty MSUI_SETTINGS file if not existing # but there can be a permission problem diff --git a/mslib/utils/mssautoplot.py b/mslib/utils/mssautoplot.py index e29227ce8..b75c3d95f 100644 --- a/mslib/utils/mssautoplot.py +++ b/mslib/utils/mssautoplot.py @@ -62,7 +62,6 @@ from mslib.utils.auth import get_auth_from_url_and_name from mslib.utils.loggerdef import configure_mpl_logger from mslib.utils.verify_user_token import verify_user_token -from mslib.msui.constants import DEFAULT_FTML_PATH TEXT_CONFIG = { @@ -235,14 +234,19 @@ def __init__(self, cpath, msc_url=None, msc_auth_password=None, username=None, p if filename != "" and filename == flight: self.read_operation(flight, msc_url, msc_auth_password, username, password) elif filename != "": - file_path = DEFAULT_FTML_PATH + default_dir = os.path.join(os.path.expanduser("~"), ".config", "msui") + if not os.path.isabs(filename): + file_path = os.path.join(default_dir, filename) + else: + file_path = filename exists = os.path.exists(file_path) if not exists: print("Filename {} doesn't exist".format(filename)) if self.pdlg: self.pdlg.close() raise SystemExit("Filename {} doesn't exist".format(filename)) - self.read_ftml(DEFAULT_FTML_PATH) + self.read_ftml(file_path) + def setup(self): pass @@ -260,7 +264,9 @@ def update_path(self, filename=None): """ # plot path and label if filename != "": - self.read_ftml(DEFAULT_FTML_PATH) + default_dir = os.path.join(os.path.expanduser("~"), ".config", "msui") + file_path = os.path.join(default_dir, "example_flight.ftml") + self.read_ftml(file_path) self.fig.canvas.draw() self.plotter.update_from_waypoints(self.wp_model_data) self.plotter.redraw_path(waypoints_model_data=self.wp_model_data) @@ -276,7 +282,12 @@ def update_path_ops(self, filename=None): def read_ftml(self, filename): if filename is None: - filename = DEFAULT_FTML_PATH + default_dir = os.path.join(os.path.expanduser("~"), ".config", "msui") + if os.path.isdir(default_dir): + filename = os.path.join(default_dir, "example_flight.ftml") + else: + filename = default_dir + self.wps, self.wp_model_data = load_from_ftml(filename) self.wp_lats, self.wp_lons, self.wp_locs = [[x[i] for x in self.wps] for i in [0, 1, 3]] self.wp_press = [mslib.utils.thermolib.flightlevel2pressure(wp[2] * units.hft).to("Pa").m for wp in self.wps] @@ -412,8 +423,10 @@ def update_path(self, filename=None): None """ # plot path and label - if filename != "": - self.read_ftml(DEFAULT_FTML_PATH) + if filename is None or filename == "": + default_dir = os.path.join(os.path.expanduser("~"), ".config", "msui") + filename = os.path.join(default_dir, "example_flight.ftml") + self.read_ftml(filename) self.fig.canvas.draw() self.plotter.update_from_waypoints(self.wp_model_data) indices = list(zip(self.intermediate_indexes, self.wp_press)) @@ -510,9 +523,10 @@ def setup(self): def update_path(self, filename=None): self.setup() - if filename != "": - self.read_ftml(DEFAULT_FTML_PATH) - + if filename is None or filename == "": + default_dir = os.path.join(os.path.expanduser("~"), ".config", "msui") + filename = os.path.join(default_dir, "example_flight.ftml") + self.read_ftml(filename) highlight = [[wp[0], wp[1]] for wp in self.wps] self.myfig.draw_vertical_lines(highlight, self.lats, self.lons) From 6ebace2a02be27bf65ea20c3eeedf8fbffe9bf20 Mon Sep 17 00:00:00 2001 From: annapurna-gupta Date: Tue, 27 May 2025 17:22:39 +0530 Subject: [PATCH 3/4] Added path for .ftml --- mslib/msui/autoplot_dockwidget.py | 12 ++-- mslib/utils/mssautoplot.py | 97 +++++++++++++++---------------- 2 files changed, 55 insertions(+), 54 deletions(-) diff --git a/mslib/msui/autoplot_dockwidget.py b/mslib/msui/autoplot_dockwidget.py index 0e8edf28b..c14dad2ea 100644 --- a/mslib/msui/autoplot_dockwidget.py +++ b/mslib/msui/autoplot_dockwidget.py @@ -288,7 +288,7 @@ def configure_from_path(self, parent, config_settings): self.resize_treewidgets() def add_to_treewidget(self, parent, parent2, config_settings, treewidget, flight, sections, vertical, filename, - itime, vtime, url, layer, styles, level): + itime, vtime, url, layer, styles, level): if treewidget.objectName() == "autoplotTreeWidget": if self.autoplotSecsTreeWidget.topLevelItemCount() == 0: QMessageBox.information( @@ -302,7 +302,9 @@ def add_to_treewidget(self, parent, parent2, config_settings, treewidget, flight flight = "" else: if filename != parent2.mscolab.active_operation_name: - filename += ".ftml" + filename = os.path.join(const.MSUI_CONFIG_PATH, filename + ".ftml") + else: + filename = os.path.join(const.MSUI_CONFIG_PATH, filename + ".ftml") item = QTreeWidgetItem([flight, sections, vertical, filename, itime, vtime]) self.autoplotTreeWidget.addTopLevelItem(item) self.autoplotTreeWidget.setCurrentItem(item) @@ -330,13 +332,15 @@ def add_to_treewidget(self, parent, parent2, config_settings, treewidget, flight self.resize_treewidgets() def update_treewidget(self, parent, parent2, config_settings, treewidget, flight, sections, vertical, filename, - itime, vtime, url, layer, styles, level): + itime, vtime, url, layer, styles, level): if flight.startswith("new flight track"): filename = "" flight = "" else: if filename != parent2.mscolab.active_operation_name: - filename += ".ftml" + filename = os.path.join(const.MSUI_CONFIG_PATH, filename + ".ftml") + else: + filename = os.path.join(const.MSUI_CONFIG_PATH, filename + ".ftml") if treewidget.objectName() == "autoplotTreeWidget": selected_item = self.autoplotTreeWidget.currentItem() selected_item.setText(0, flight) diff --git a/mslib/utils/mssautoplot.py b/mslib/utils/mssautoplot.py index b75c3d95f..301f20bc7 100644 --- a/mslib/utils/mssautoplot.py +++ b/mslib/utils/mssautoplot.py @@ -108,8 +108,7 @@ def load_from_operation(op_name, msc_url, msc_auth_password, username, password) msc_auth = ("mscolab", msc_auth_password) session.auth = msc_auth session.headers.update({'x-test': 'true'}) - # ToDp fix config_loader it gets a list of two times the entry - response = session.get(urljoin(msc_url, 'status'), timeout=tuple(config_loader(dataset="MSCOLAB_timeout")[0])) + response = session.get(urljoin(msc_url, 'status'), timeout=tuple(config_loader(dataset="MSCOLAB_timeout"))) session.close() if response.status_code == 401: logging.error("Error", 'Server authentication data were incorrect.') @@ -119,8 +118,7 @@ def load_from_operation(op_name, msc_url, msc_auth_password, username, password) session.headers.update({'x-test': 'true'}) url = urljoin(msc_url, "token") try: - # ToDp fix config_loader it gets a list of two times the entry - response = session.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")[0])) + response = session.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout"))) response.raise_for_status() except requests.exceptions.RequestException as ex: logging.error("unexpected error: %s %s %s", type(ex), url, ex) @@ -158,7 +156,7 @@ def get_xml_data(msc_url, token, op_id): "op_id": op_id } url = urljoin(msc_url, "get_operation_by_id") - r = requests.get(url, data=data) + r = requests.get(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout"))) if r.text != "False": xml_content = json.loads(r.text)["content"] return xml_content @@ -187,7 +185,7 @@ def get_op_id(msc_url, token, op_name): "skip_archived": skip_archived } url = urljoin(msc_url, "operations") - r = requests.get(url, data=data) + r = requests.get(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout"))) if r.text != "False": _json = json.loads(r.text) operations = _json["operations"] @@ -218,6 +216,10 @@ def __init__(self, cpath, msc_url=None, msc_auth_password=None, username=None, p flight = self.config["automated_plotting_flights"][0][0] section = self.config["automated_plotting_flights"][0][1] filename = self.config["automated_plotting_flights"][0][3] + config_dir = os.path.dirname(os.path.expanduser(cpath)) + if filename and not os.path.isabs(filename): + filename = os.path.join(config_dir, filename) + logging.debug("Resolved filename: %s", filename) if self.__class__.__name__ == "TopViewPlotting": try: self.params = get_projection_params(self.config["predefined_map_sections"][section]["CRS"].lower()) @@ -234,19 +236,13 @@ def __init__(self, cpath, msc_url=None, msc_auth_password=None, username=None, p if filename != "" and filename == flight: self.read_operation(flight, msc_url, msc_auth_password, username, password) elif filename != "": - default_dir = os.path.join(os.path.expanduser("~"), ".config", "msui") - if not os.path.isabs(filename): - file_path = os.path.join(default_dir, filename) - else: - file_path = filename - exists = os.path.exists(file_path) - if not exists: - print("Filename {} doesn't exist".format(filename)) + if not os.path.exists(filename): + print(f"FTML file {filename} does not exist") if self.pdlg: self.pdlg.close() - raise SystemExit("Filename {} doesn't exist".format(filename)) - self.read_ftml(file_path) - + raise SystemExit(f"FTML file {filename} does not exist") + self.read_ftml(filename) + print(filename) def setup(self): pass @@ -264,9 +260,7 @@ def update_path(self, filename=None): """ # plot path and label if filename != "": - default_dir = os.path.join(os.path.expanduser("~"), ".config", "msui") - file_path = os.path.join(default_dir, "example_flight.ftml") - self.read_ftml(file_path) + self.read_ftml(filename) self.fig.canvas.draw() self.plotter.update_from_waypoints(self.wp_model_data) self.plotter.redraw_path(waypoints_model_data=self.wp_model_data) @@ -281,13 +275,6 @@ def update_path_ops(self, filename=None): self.plotter.redraw_path(waypoints_model_data=self.wp_model_data) def read_ftml(self, filename): - if filename is None: - default_dir = os.path.join(os.path.expanduser("~"), ".config", "msui") - if os.path.isdir(default_dir): - filename = os.path.join(default_dir, "example_flight.ftml") - else: - filename = default_dir - self.wps, self.wp_model_data = load_from_ftml(filename) self.wp_lats, self.wp_lons, self.wp_locs = [[x[i] for x in self.wps] for i in [0, 1, 3]] self.wp_press = [mslib.utils.thermolib.flightlevel2pressure(wp[2] * units.hft).to("Pa").m for wp in self.wps] @@ -423,10 +410,8 @@ def update_path(self, filename=None): None """ # plot path and label - if filename is None or filename == "": - default_dir = os.path.join(os.path.expanduser("~"), ".config", "msui") - filename = os.path.join(default_dir, "example_flight.ftml") - self.read_ftml(filename) + if filename != "": + self.read_ftml(filename) self.fig.canvas.draw() self.plotter.update_from_waypoints(self.wp_model_data) indices = list(zip(self.intermediate_indexes, self.wp_press)) @@ -523,10 +508,9 @@ def setup(self): def update_path(self, filename=None): self.setup() - if filename is None or filename == "": - default_dir = os.path.join(os.path.expanduser("~"), ".config", "msui") - filename = os.path.join(default_dir, "example_flight.ftml") - self.read_ftml(filename) + if filename != "": + self.read_ftml(filename) + highlight = [[wp[0], wp[1]] for wp in self.wps] self.myfig.draw_vertical_lines(highlight, self.lats, self.lons) @@ -598,49 +582,62 @@ def draw(self, flight, section, vertical, filename, init_time, time, url, layer, @click.command() @click.option('--cpath', default=constants.MSS_AUTOPLOT, help='Path of the configuration file.') @click.option('--view', default="top", help='View of the plot (top/side/linear).') -@click.option('--ftrack', type=click.Path(exists=True), help='Path to the .ftml file') +@click.option('--ftrack', default="", help='Flight track.') @click.option('--itime', default="", help='Initial time.') @click.option('--vtime', default="", help='Valid time.') @click.option('--intv', default=0, help='Time interval.') @click.option('--stime', default="", help='Starting time for downloading multiple plots with a fixed interval.') @click.option('--etime', default="", help='Ending time for downloading multiple plots with a fixed interval.') @click.option('--raw', default=False, help='Saves the raw image with its projection in topview') +@click.option('--ftml-path', default="", help='Override the FTML file path from the configuration.') @click.pass_context -def main(ctx, cpath, view, ftrack, itime, vtime, intv, stime, etime, raw): +def main(ctx, cpath, view, ftrack, itime, vtime, intv, stime, etime, raw, ftml_path): pdlg = None def close_process_dialog(pdlg): pdlg.close() if ctx.obj is not None: - # ToDo find a simpler solution, on a split of the package, QT is expensive for such a progressbar pdlg = QProgressDialog("Downloading images", "Cancel", 0, 10, parent=ctx.obj) pdlg.setMinimumDuration(0) pdlg.repaint() pdlg.canceled.connect(lambda: close_process_dialog(pdlg)) pdlg.setWindowModality(Qt.WindowModal) - pdlg.setAutoReset(True) # Close dialog automatically when reaching max value - pdlg.setAutoClose(True) # Automatically close when value reaches maximum - pdlg.setValue(0) # Initial progress value - - # Set window flags to ensure visibility and modality + pdlg.setAutoReset(True) + pdlg.setAutoClose(True) + pdlg.setValue(0) pdlg.setWindowFlags(pdlg.windowFlags() | Qt.CustomizeWindowHint | Qt.WindowTitleHint) - pdlg.setValue(0) conf.read_config_file(path=cpath) config = conf.config_loader() - # flight_name = config["automated_plotting_flights"][0][0] - # file = config["automated_plotting_flights"][0][3] + if ftml_path: + # Override the FTML file path in the configuration + if not os.path.exists(ftml_path): + print(f"Provided FTML file path {ftml_path} does not exist") + if ctx.obj is not None: + pdlg.close() + raise SystemExit(f"Provided FTML file path {ftml_path} does not exist") + config["automated_plotting_flights"][0][3] = ftml_path + if ctx.obj is not None: pdlg.setValue(1) msc_url = config["mscolab_server_url"] - msc_auth_password = mslib.utils.auth.get_password_from_keyring(service_name=f"MSCOLAB_AUTH_{msc_url}", - username="mscolab") - msc_username = config["MSS_auth"][msc_url] - msc_password = mslib.utils.auth.get_password_from_keyring(service_name=msc_url, username=msc_username) + try: + msc_auth_password = mslib.utils.auth.get_password_from_keyring(service_name=f"MSCOLAB_AUTH_{msc_url}", + username="mscolab") + except KeyError: + msc_auth_password = None + + try: + msc_username = config["MSS_auth"][msc_url] + except KeyError: + msc_username = None + msc_password = None + if msc_username is not None: + msc_password = mslib.utils.auth.get_password_from_keyring(service_name=msc_url, username=msc_username) # Choose view (top or side) if view == "top": From 47a86e2584f20f1e2e24264ee30404e24263c74f Mon Sep 17 00:00:00 2001 From: annapurna-gupta Date: Mon, 23 Jun 2025 13:20:30 +0530 Subject: [PATCH 4/4] improve path handeling --- mslib/msui/autoplot_dockwidget.py | 17 +++++++++-------- mslib/msui/msui_mainwindow.py | 3 ++- mslib/msui/topview.py | 6 ++++-- mslib/utils/mssautoplot.py | 4 +--- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/mslib/msui/autoplot_dockwidget.py b/mslib/msui/autoplot_dockwidget.py index c14dad2ea..fd348e222 100644 --- a/mslib/msui/autoplot_dockwidget.py +++ b/mslib/msui/autoplot_dockwidget.py @@ -47,7 +47,7 @@ class AutoplotDockWidget(QWidget, Ui_AutoplotDockWidget): autoplot_treewidget_item_selected = QtCore.pyqtSignal(str, str) update_op_flight_treewidget = QtCore.pyqtSignal(str, str) - def __init__(self, parent=None, parent2=None, view=None, config_settings=None): + def __init__(self, parent=None, parent2=None, view=None, config_settings=None, last_save_directory=None): super().__init__() self.setupUi(self) @@ -70,6 +70,7 @@ def __init__(self, parent=None, parent2=None, view=None, config_settings=None): self.intv = "" self.refresh_sig(config_settings) + self.last_save_directory = last_save_directory or os.path.expanduser("~") parent.refresh_signal_send.connect(lambda: self.refresh_sig(config_settings)) @@ -178,7 +179,7 @@ def download_plots_cli(self, config_settings): view = "linear" # Create the configuration path - config_path = os.path.join(const.MSUI_CONFIG_PATH, "mssautoplot.json") + config_path = os.path.join(self.last_save_directory, "mssautoplot.json") # Save the config settings to the file if config_path: @@ -268,7 +269,7 @@ def configure_from_path(self, parent, config_settings): options |= QFileDialog.DontUseNativeDialog fileName, _ = QFileDialog.getOpenFileName( - self, "Select .json Config File", const.MSUI_CONFIG_PATH, "JSON Files (*.json)", options=options) + self, "Select .json Config File", self.last_save_directory, "JSON Files (*.json)", options=options) if fileName != "": self.cpath = fileName @@ -302,9 +303,9 @@ def add_to_treewidget(self, parent, parent2, config_settings, treewidget, flight flight = "" else: if filename != parent2.mscolab.active_operation_name: - filename = os.path.join(const.MSUI_CONFIG_PATH, filename + ".ftml") + filename = os.path.join(self.last_save_directory, filename + ".ftml") else: - filename = os.path.join(const.MSUI_CONFIG_PATH, filename + ".ftml") + filename = os.path.join(self.last_save_directory, filename + ".ftml") item = QTreeWidgetItem([flight, sections, vertical, filename, itime, vtime]) self.autoplotTreeWidget.addTopLevelItem(item) self.autoplotTreeWidget.setCurrentItem(item) @@ -338,9 +339,9 @@ def update_treewidget(self, parent, parent2, config_settings, treewidget, flight flight = "" else: if filename != parent2.mscolab.active_operation_name: - filename = os.path.join(const.MSUI_CONFIG_PATH, filename + ".ftml") + filename = os.path.join(self.last_save_directory, filename + ".ftml") else: - filename = os.path.join(const.MSUI_CONFIG_PATH, filename + ".ftml") + filename = os.path.join(self.last_save_directory, filename + ".ftml") if treewidget.objectName() == "autoplotTreeWidget": selected_item = self.autoplotTreeWidget.currentItem() selected_item.setText(0, flight) @@ -505,7 +506,7 @@ def update_config_file(self, config_settings): file_path, _ = QFileDialog.getSaveFileName( self, "Save JSON File", - const.MSUI_CONFIG_PATH, + self.last_save_directory, "JSON Files (*.json);;All Files (*)", options=options ) diff --git a/mslib/msui/msui_mainwindow.py b/mslib/msui/msui_mainwindow.py index b1a8ba9f6..f705ea7d8 100644 --- a/mslib/msui/msui_mainwindow.py +++ b/mslib/msui/msui_mainwindow.py @@ -939,7 +939,8 @@ def create_view(self, _type, model): active_flighttrack=self.active_flight_track, mscolab_server_url=self.mscolab.mscolab_server_url, token=self.mscolab.token, tutorial_mode=self.tutorial_mode, - config_settings=self.config_for_gui) + config_settings=self.config_for_gui, + last_save_directory=self.last_save_directory) view_window.refresh_signal_emit.connect(self.refresh_signal_connect.emit) view_window.mpl.resize(layout['topview'][0], layout['topview'][1]) if layout["immutable"]: diff --git a/mslib/msui/topview.py b/mslib/msui/topview.py index f892da606..d9e30b3c1 100644 --- a/mslib/msui/topview.py +++ b/mslib/msui/topview.py @@ -228,7 +228,7 @@ class MSUITopViewWindow(MSUIMplViewWindow, ui.Ui_TopViewWindow): def __init__(self, parent=None, mainwindow=None, model=None, _id=None, active_flighttrack=None, mscolab_server_url=None, token=None, config_settings=None, - tutorial_mode=False): + tutorial_mode=False, last_save_directory=None): """ Set up user interface, connect signal/slots. """ @@ -262,6 +262,7 @@ def __init__(self, parent=None, mainwindow=None, model=None, _id=None, # Store active flighttrack waypoint model self.active_flighttrack = active_flighttrack + self.last_save_directory = last_save_directory # Stores active mscolab operation id self.active_op_id = mainwindow.mscolab.active_op_id @@ -439,7 +440,8 @@ def openTool(self, index, parent=None, config_settings=None): elif index == AUTOPLOT: title = "Autoplot (Top View)" widget = apd.AutoplotDockWidget(parent=self, parent2=parent, - view="Top View", config_settings=config_settings) + view="Top View", config_settings=config_settings, + last_save_directory=self.last_save_directory) widget.treewidget_item_selected.connect( lambda url, layer, style, level: self.tree_item_select(url, layer, style, level)) widget.autoplot_treewidget_item_selected.connect( diff --git a/mslib/utils/mssautoplot.py b/mslib/utils/mssautoplot.py index 301f20bc7..73eea79dd 100644 --- a/mslib/utils/mssautoplot.py +++ b/mslib/utils/mssautoplot.py @@ -216,10 +216,9 @@ def __init__(self, cpath, msc_url=None, msc_auth_password=None, username=None, p flight = self.config["automated_plotting_flights"][0][0] section = self.config["automated_plotting_flights"][0][1] filename = self.config["automated_plotting_flights"][0][3] - config_dir = os.path.dirname(os.path.expanduser(cpath)) + config_dir = os.path.dirname(os.path.expanduser(cpath)) if filename and not os.path.isabs(filename): filename = os.path.join(config_dir, filename) - logging.debug("Resolved filename: %s", filename) if self.__class__.__name__ == "TopViewPlotting": try: self.params = get_projection_params(self.config["predefined_map_sections"][section]["CRS"].lower()) @@ -242,7 +241,6 @@ def __init__(self, cpath, msc_url=None, msc_auth_password=None, username=None, p self.pdlg.close() raise SystemExit(f"FTML file {filename} does not exist") self.read_ftml(filename) - print(filename) def setup(self): pass