From 128e456e8c6ec4cfb314bbf90b5e6eb6b5a13368 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Tue, 20 Feb 2024 16:33:37 -0800 Subject: [PATCH] Simplify the /files documentation Remove most of the documentation in favor of a link to a new page on rsp.lsst.io. Display the WebDAV file server timeout in a more human-readable form. --- changelog.d/20240220_163206_rra_DM_42930.md | 7 ++ controller/src/controller/templates.py | 19 ++-- .../templates/fileserver.html.jinja | 88 ++++++------------- .../data/fileserver/output/fileserver.html | 88 ++++++------------- 4 files changed, 71 insertions(+), 131 deletions(-) create mode 100644 changelog.d/20240220_163206_rra_DM_42930.md diff --git a/changelog.d/20240220_163206_rra_DM_42930.md b/changelog.d/20240220_163206_rra_DM_42930.md new file mode 100644 index 000000000..c86aeb8b5 --- /dev/null +++ b/changelog.d/20240220_163206_rra_DM_42930.md @@ -0,0 +1,7 @@ +### Bug fixes + +- Display the timeout in the `/files` documentation in a more human-readable format. + +### Other changes + +- Remove most of the `/files` documentation in favor of a link to [rsp.lsst.io](https://rsp.lsst.io/guides/notebooks/extfileaccess/webdav/). diff --git a/controller/src/controller/templates.py b/controller/src/controller/templates.py index 7206d2817..ec4088ce7 100644 --- a/controller/src/controller/templates.py +++ b/controller/src/controller/templates.py @@ -33,9 +33,8 @@ def _format_timedelta(delta: timedelta) -> str: Returns ------- str - Human-readable equivalent using ``d`` for days, ``h`` for hours, ``m`` - for minutes, and ``s`` for seconds. Daylight saving time transitions - are not taken into account. + Human-readable equivalent. Daylight saving time transitions are not + taken into account. """ seconds = int(delta.total_seconds()) days, seconds = divmod(seconds, 86400) @@ -43,13 +42,19 @@ def _format_timedelta(delta: timedelta) -> str: minutes, seconds = divmod(seconds, 60) string = "" if days: - string = f"{days}d" + string = f"{days} " + ("day" if days == 1 else "days") if hours: - string += f"{hours}h" + if string: + string += " " + string += f"{hours} " + ("hour" if hours == 1 else "hours") if minutes: - string += f"{minutes}m" + if string: + string += " " + string += f"{minutes} " + ("minute" if minutes == 1 else "minutes") if seconds: - string += f"{seconds}s" + if string: + string += " " + string += f"{seconds} " + ("second" if seconds == 1 else "seconds") return string diff --git a/controller/src/controller/templates/fileserver.html.jinja b/controller/src/controller/templates/fileserver.html.jinja index 27a037efe..a9acd4600 100644 --- a/controller/src/controller/templates/fileserver.html.jinja +++ b/controller/src/controller/templates/fileserver.html.jinja @@ -1,64 +1,28 @@ - - -User Fileserver Created - - - -

-Your fileserver is ready. -

- -

-Access Token -

- -

If you do not have an access token, go to the Gafaelfawr tokens page and press -the "Create Token" button.

- -

-Give that token a name, such as "fileserver", the "exec:notebook" scope, -and a reasonable expiration duration, such as 1 month. -

- -

-Press "Create". -

- -

-Your token will be displayed. Copy this token and save it somewhere -safe; you will never be able to view it from the tokens page again. -

- -

-Using the Fileserver -

- -

-To use the fileserver, you will need a WebDAV client of your choice. -Mac and Windows have built-in WebDAV clients (this is "Connect to -Server..." or "Map Network Drive..."), as do Gnome Nautilus and -Konqueror for Linux. The open-source command-line client -cadaver should build on -almost any Unix-like system and will work. -

- -

-Connect to -{{ base_url }}{{ path_prefix }}/{{ username }} -with your WebDAV client (for Konqueror, use "webdav" or "webdavs" rather -than "http" or "https" as the protocol). Use the token you acquired -earlier as the password. You can use any string for your username -(since the token belongs to you, it identifies you), but "{{ username }}" -would be both accurate and traditional. -

- -

-If you make no requests in {{ timeout | format_timedelta }}, the fileserver will shut -down. If that occurs, simply go back to -{{ base_url }}{{ path_prefix }} -and a new fileserver will be created for you. -

- + + File server is running + + +

File server is running

+ +

+ Your WebDAV file server for username {{ username }} is running. The + URL to enter into a WebDAV client is: +

+ +
{{ base_url }}{{ path_prefix }}/{{ username }}
+ +

+ For instructions on how to use the file server, see + the + rsp.lsst.io documentation. +

+ +

+ If you make no requests for {{ timeout | format_timedelta }}, the + file server will shut down and you will need to return to + this page to start it + again. +

+ diff --git a/controller/tests/data/fileserver/output/fileserver.html b/controller/tests/data/fileserver/output/fileserver.html index f27067b47..7308e0ee4 100644 --- a/controller/tests/data/fileserver/output/fileserver.html +++ b/controller/tests/data/fileserver/output/fileserver.html @@ -1,64 +1,28 @@ - - -User Fileserver Created - - - -

-Your fileserver is ready. -

- -

-Access Token -

- -

If you do not have an access token, go to the Gafaelfawr tokens page and press -the "Create Token" button.

- -

-Give that token a name, such as "fileserver", the "exec:notebook" scope, -and a reasonable expiration duration, such as 1 month. -

- -

-Press "Create". -

- -

-Your token will be displayed. Copy this token and save it somewhere -safe; you will never be able to view it from the tokens page again. -

- -

-Using the Fileserver -

- -

-To use the fileserver, you will need a WebDAV client of your choice. -Mac and Windows have built-in WebDAV clients (this is "Connect to -Server..." or "Map Network Drive..."), as do Gnome Nautilus and -Konqueror for Linux. The open-source command-line client -cadaver should build on -almost any Unix-like system and will work. -

- -

-Connect to -http://127.0.0.1:8080/files/rachel -with your WebDAV client (for Konqueror, use "webdav" or "webdavs" rather -than "http" or "https" as the protocol). Use the token you acquired -earlier as the password. You can use any string for your username -(since the token belongs to you, it identifies you), but "rachel" -would be both accurate and traditional. -

- -

-If you make no requests in 1h, the fileserver will shut -down. If that occurs, simply go back to -http://127.0.0.1:8080/files -and a new fileserver will be created for you. -

- + + File server is running + + +

File server is running

+ +

+ Your WebDAV file server for username rachel is running. The + URL to enter into a WebDAV client is: +

+ +
http://127.0.0.1:8080/files/rachel
+ +

+ For instructions on how to use the file server, see + the + rsp.lsst.io documentation. +

+ +

+ If you make no requests for 1 hour, the + file server will shut down and you will need to return to + this page to start it + again. +

+