Skip to content
Snippets Groups Projects

WS-640: all wiring is in place to launch CARTA and notify user with HTML page...

Closed Janet Goldstein requested to merge WS-640-make-carta-frame-html into main
6 unresolved threads

All tests pass. Once this code has been pushed to dev, we can exercise new functionality.

Edited by Janet Goldstein

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
175 206 self.logger.warning("WARNING: CARTA not running.")
207
208
209 @staticmethod
210 def create_frame_html(carta_url: str, html_dir: Path) -> Path:
211 """
212 Generate the HTML page containing the CARTA URL in a frame.
213
214 :param carta_url: URL of CARTA session
215 :param html_dir: where HTML will be written
216 :return: HTML file we just created
217 """
218 original_content = CartaLauncher.read_carta_url_template()
219 new_content = original_content.replace(CARTA_URL_REPLACE_TEXT, carta_url)
220 html_file = html_dir / CARTA_HTML_FILENAME
221 with open(html_file, "w") as out:
  • 220 html_file = html_dir / CARTA_HTML_FILENAME
    221 with open(html_file, "w") as out:
    222 out.write(new_content)
    223
    224 return html_file
    225
    226 @staticmethod
    227 def read_carta_url_template() -> str:
    228 """
    229 Get contents of carta_url_template.html
    230
    231 :return:
    232 """
    233 paths = [file for file in Path("../../..").rglob(CARTA_HTML_TEMPLATE_FILENAME)]
    234 if paths and len(paths) > 0:
    235 with open(paths[0], "r") as template:
  • 37
    38 def test_writes_html(tmpdir):
    39 """
    40 Can we grab the template, insert the URL, and write the file to someplace new?
    41
    42 :param tmpdir: where to write the HTML
    43 :return:
    44 """
    45
    46 original_content = CartaLauncher.read_carta_url_template()
    47 new_content = original_content.replace(CARTA_URL_REPLACE_TEXT, TEST_URL)
    48 assert len(new_content) == len(original_content) + 5
    49 assert TEST_URL in new_content
    50
    51 html_file = Path(tmpdir) / CARTA_HTML_FILENAME
    52 with open(html_file, "w") as out:
  • Thank you for taking the time to flesh out the pydoc comments! It makes it much easier to follow what's going on in this codebase! 👍

  • 213 254 f"{self.url}/notify/carta_ready/send",
    214 255 json={
    215 256 "destination_email": self.settings["user_email"],
    216 "carta_url": carta_url,
    257 "carta_html": str(carta_html),
  • 125 147 sys.exit(f"ERROR: Failed to launch CARTA: {err}")
    126 148 else:
    127 149 # CARTA is running and accessible, so send CARTA URL to AAT system or notify user
    128 self.notify_ready(carta_url=carta_url)
    150 self.notify_ready(carta_url=carta_url, carta_html=carta_html)
    129 151
    130 152 # Activate timeout handler
    131 153 signal.signal(signal.SIGALRM, self.signal)
    132 154 signal.alarm(60 * timeout_minutes)
    133 self.logger.info(f"To access CARTA, enter this URL into a web browser: {carta_url}")
    155 self.logger.info(f"To access CARTA, load this file into a web browser: {carta_html}")
  • added 1 commit

    Compare with previous version

  • 167 """
    168 Sends URL notification to user and request handler
    169
    170 :param carta_url: URL to CARTA session
    171 :param carta_html: HTML page with CARTA URL in frame
    172
    173 :return:
    174 """
    144 175 self.logger.info("SENDING URL NOTIFICATION TO: ")
    145 176 if self.settings["send_ready"] == "true":
    146 177 self.logger.info("User Email")
    147 self.notification.send_session_ready(carta_url)
    178 self.notification.send_session_ready(carta_html)
    148 179 elif self.settings["send_ready"] == "false":
    149 180 self.logger.info("AAT Request Handler")
    150 181 self.archive_connect.send_carta_url_to_rh(carta_url)
  • Please register or sign in to reply
    Loading