Skip to content

Commit

Permalink
Autoplot namings fixed (#2548)
Browse files Browse the repository at this point in the history
* rename cli_tool back to main

* renamed dock to apd

* refactored session and response names

* improve comment
  • Loading branch information
ReimarBauer authored Oct 4, 2024
1 parent c9d1233 commit d79733b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions mslib/msui/autoplot_dockwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import json
import os
import click
from mslib.utils.mssautoplot import cli_tool
from mslib.utils.mssautoplot import main as cli_tool
from PyQt5.QtWidgets import QWidget, QFileDialog, QTreeWidgetItem, QMessageBox
from PyQt5 import QtCore
from mslib.msui.qt5.ui_mss_autoplot import Ui_AutoplotDockWidget
Expand Down Expand Up @@ -193,7 +193,7 @@ def download_plots_cli(self, config_settings):
'etime': self.etime[:-1]
}

# Invoke the cli_tool method using click
# Invoke the main method using click from the mssautoplot
ctx = click.Context(cli_tool)
ctx.obj = self
ctx.invoke(cli_tool, **args)
Expand Down
6 changes: 3 additions & 3 deletions mslib/msui/linearview.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from mslib.msui.viewwindows import MSUIMplViewWindow
from mslib.msui import wms_control as wms
from mslib.msui.icons import icons
from mslib.msui import autoplot_dockwidget as dock
from mslib.msui import autoplot_dockwidget as apd

# Dock window indices.
WMS = 0
Expand Down Expand Up @@ -157,8 +157,8 @@ def openTool(self, index, parent=None, config_settings=None):
self.mpl.canvas.waypoints_interactor.signal_get_lsec.connect(widget.call_get_lsec)
elif index == AUTOPLOT:
title = "Autoplot (Linear View)"
widget = dock.AutoplotDockWidget(parent=self, parent2=parent,
view="Linear View", config_settings=config_settings)
widget = apd.AutoplotDockWidget(parent=self, parent2=parent,
view="Linear View", config_settings=config_settings)
widget.treewidget_item_selected.connect(
lambda url, layer, style, level: self.tree_item_select(url, layer, style, level))
else:
Expand Down
6 changes: 3 additions & 3 deletions mslib/msui/sideview.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from mslib.utils import thermolib
from mslib.utils.config import config_loader
from mslib.utils.units import units, convert_to
from mslib.msui import autoplot_dockwidget as dock
from mslib.msui import autoplot_dockwidget as apd

# Dock window indices.
WMS = 0
Expand Down Expand Up @@ -331,8 +331,8 @@ def openTool(self, index, parent=None, config_settings=None):
self.mpl.canvas.waypoints_interactor.signal_get_vsec.connect(widget.call_get_vsec)
elif index == AUTOPLOT:
title = "Autoplot (Side View)"
widget = dock.AutoplotDockWidget(parent=self, parent2=parent,
view="Side View", config_settings=config_settings)
widget = apd.AutoplotDockWidget(parent=self, parent2=parent,
view="Side View", config_settings=config_settings)
widget.treewidget_item_selected.connect(
lambda url, layer, style, level: self.tree_item_select(url, layer, style, level))
else:
Expand Down
6 changes: 3 additions & 3 deletions mslib/msui/topview.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from mslib.msui import airdata_dockwidget as ad
from mslib.msui import multiple_flightpath_dockwidget as mf
from mslib.msui import flighttrack as ft
from mslib.msui import autoplot_dockwidget as dock
from mslib.msui import autoplot_dockwidget as apd
from mslib.msui.icons import icons
from mslib.msui.flighttrack import Waypoint

Expand Down Expand Up @@ -404,8 +404,8 @@ def openTool(self, index, parent=None, config_settings=None):
self.signal_activate_operation.emit(self.active_op_id)
elif index == AUTOPLOT:
title = "Autoplot (Top View)"
widget = dock.AutoplotDockWidget(parent=self, parent2=parent,
view="Top View", config_settings=config_settings)
widget = apd.AutoplotDockWidget(parent=self, parent2=parent,
view="Top View", config_settings=config_settings)
widget.treewidget_item_selected.connect(
lambda url, layer, style, level: self.tree_item_select(url, layer, style, level))
widget.autoplot_treewidget_item_selected.connect(
Expand Down
18 changes: 9 additions & 9 deletions mslib/utils/mssautoplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@ def load_from_operation(operation, email, password, mscolab_url):
"email": email,
"password": password
}
s = requests.Session()
session = requests.Session()
auth = config_loader(dataset="MSCOLAB_auth_user_name"), password
s.auth = auth
s.headers.update({'x-test': 'true'})
session.auth = auth
session.headers.update({'x-test': 'true'})
url = urljoin(mscolab_url, "token")
try:
r = s.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")[0]))
if r.status_code == 401:
response = session.post(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")[0]))
if response.status_code == 401:
raise requests.exceptions.ConnectionError
except requests.exceptions.RequestException as ex:
logging.error("unexpected error: %s %s %s", type(ex), url, ex)
return
if r.text != "False":
_json = json.loads(r.text)
if response.text != "False":
_json = json.loads(response.text)
token = _json["token"]
mscolab_server_url = url
op_id = get_op_id(token=token, mscolab_server_url=mscolab_server_url, curr_op=operation)
Expand Down Expand Up @@ -429,7 +429,7 @@ def draw(self):
@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.pass_context
def cli_tool(ctx, cpath, view, ftrack, itime, vtime, intv, stime, etime):
def main(ctx, cpath, view, ftrack, itime, vtime, intv, stime, etime):
if ctx.obj is not None:
pdlg = QProgressDialog("Downloading images", "Cancel", 0, 10, parent=ctx.obj)
pdlg.setMinimumDuration(0)
Expand Down Expand Up @@ -549,4 +549,4 @@ def draw(no_of_plots):


if __name__ == '__main__':
cli_tool()
main()

0 comments on commit d79733b

Please sign in to comment.