Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/murfey/cli/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
from rich.prompt import Confirm

from murfey.client import read_config
from murfey.util.config import MachineConfig

Check warning on line 13 in src/murfey/cli/transfer.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/transfer.py#L13

Added line #L13 was not covered by tests


def run():
config = read_config()
known_server = config["Murfey"].get("server")
known_server = config["Murfey"].get("server", "")
instrument_name = config["Murfey"].get("instrument_name", "")

Check warning on line 19 in src/murfey/cli/transfer.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/transfer.py#L18-L19

Added lines #L18 - L19 were not covered by tests

parser = argparse.ArgumentParser(description="Transfer using a remote rsync daemon")

Expand All @@ -35,7 +37,11 @@
console = Console()
murfey_url = urlparse(args.server, allow_fragments=False)

machine_data = requests.get(f"{murfey_url.geturl()}/machine").json()
machine_data = MachineConfig(

Check warning on line 40 in src/murfey/cli/transfer.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/cli/transfer.py#L40

Added line #L40 was not covered by tests
requests.get(
f"{murfey_url.geturl()}/instruments/{instrument_name}/machine"
).json()
)
if Path(args.source or ".").resolve() in machine_data.data_directories:
console.print("[red]Source directory is the base directory, exiting")
return
Expand Down
4 changes: 4 additions & 0 deletions src/murfey/client/rsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,16 @@
self._local = local
self._server_url = server_url
self._notify = notify

# Set rsync destination
if local:
self._remote = str(basepath_remote)
else:
self._remote = (
f"{server_url.hostname}::{self._rsync_module}/{basepath_remote}/"
)
logger.debug(f"rsync destination path set to {self._remote}")

Check warning on line 86 in src/murfey/client/rsync.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/rsync.py#L86

Added line #L86 was not covered by tests

# For local tests you can use something along the lines of
# self._remote = f"wra62962@ws133:/dls/tmp/wra62962/junk/{basepath_remote}"
# to avoid having to set up an rsync daemon
Expand Down
5 changes: 4 additions & 1 deletion src/murfey/client/tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
ReactiveType = TypeVar("ReactiveType")

token = read_config()["Murfey"].get("token", "")
instrument_name = read_config()["Murfey"].get("instrument_name", "")

requests.get = partial(requests.get, headers={"Authorization": f"Bearer {token}"})
requests.post = partial(requests.post, headers={"Authorization": f"Bearer {token}"})
Expand Down Expand Up @@ -154,7 +155,9 @@
):
log.info(f"starting multigrid rsyncer: {source}")
destination_overrides = destination_overrides or {}
machine_data = requests.get(f"{self._environment.url.geturl()}/machine").json()
machine_data = requests.get(

Check warning on line 158 in src/murfey/client/tui/app.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/tui/app.py#L158

Added line #L158 was not covered by tests
f"{self._environment.url.geturl()}/instruments/{instrument_name}/machine"
).json()
if destination_overrides.get(source):
destination = destination_overrides[source] + f"/{extra_directory}"
else:
Expand Down
22 changes: 12 additions & 10 deletions src/murfey/client/tui/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
ReactiveType = TypeVar("ReactiveType")

token = read_config()["Murfey"].get("token", "")
instrument_name = read_config()["Murfey"].get("instrument_name", "")

requests.get = partial(requests.get, headers={"Authorization": f"Bearer {token}"})
requests.post = partial(requests.post, headers={"Authorization": f"Bearer {token}"})
Expand Down Expand Up @@ -264,8 +265,9 @@
self._context = SPAModularContext

def compose(self):

machine_data = requests.get(
f"{self.app._environment.url.geturl()}/machine"
f"{self.app._environment.url.geturl()}/instruments/{instrument_name}/machine"
).json()
self._dir_tree = _DirectoryTree(
str(self._selected_dir),
Expand Down Expand Up @@ -699,7 +701,7 @@
)
log.info(f"Posted visit registration: {response.status_code}")
machine_data = requests.get(
f"{self.app._environment.url.geturl()}/machine"
f"{self.app._environment.url.geturl()}/instruments/{instrument_name}/machine"
).json()

if self._switch_status:
Expand Down Expand Up @@ -766,12 +768,16 @@
)
log.info(f"Posted visit registration: {response.status_code}")
machine_data = requests.get(
f"{self.app._environment.url.geturl()}/machine"
f"{self.app._environment.url.geturl()}/instruments/{instrument_name}/machine"
).json()

self.app.install_screen(
DirectorySelection(
[p for p in machine_data.get("data_directories", []) if p.exists()]
[
p
for p in machine_data.get("data_directories", [])
if Path(p).exists()
]
),
"directory-select",
)
Expand All @@ -787,11 +793,7 @@
)
self.app.push_screen("gain-ref-select")
else:
if self._switch_status:
self.app.push_screen("directory-select")
else:
self.app.install_screen(LaunchScreen(basepath=Path("./")), "launcher")
self.app.push_screen("launcher")
self.app.push_screen("directory-select")

Check warning on line 796 in src/murfey/client/tui/screens.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/tui/screens.py#L796

Added line #L796 was not covered by tests

if machine_data.get("upstream_data_directories"):
upstream_downloads = requests.get(
Expand All @@ -817,7 +819,7 @@

def on_button_pressed(self, event: Button.Pressed):
machine_data = requests.get(
f"{self.app._environment.url.geturl()}/machine"
f"{self.app._environment.url.geturl()}/instruments/{instrument_name}/machine"
).json()
if machine_data.get("upstream_data_download_directory"):
# Create the directory locally to save files to
Expand Down