1313
1414from murfey .client .context import Context
1515from murfey .client .instance_environment import MurfeyInstanceEnvironment
16- from murfey .util .api import url_path_for
1716from murfey .util .client import capture_post , get_machine_config_client
1817
1918# Create logger object
@@ -353,19 +352,14 @@ def register_lif_file(
353352 register the LIF file in the database correctly as part of the CLEM workflow.
354353 """
355354 try :
356- # Construct URL to post to post the request to
357- url = f"{ environment .url .geturl ()} { url_path_for ('clem.router' , 'register_lif_file' , session_id = environment .murfey_session )} ?lif_file={ quote (str (lif_file ), safe = '' )} "
358- # Validate
359- if not url :
360- logger .error (
361- "URL could not be constructed from the environment and file path"
362- )
363- return False
364-
365- # Send the message
366- capture_post (url )
355+ capture_post (
356+ base_url = str (environment .url .geturl ()),
357+ router_name = "clem.router" ,
358+ function_name = "register_lif_file" ,
359+ session_id = environment .murfey_session ,
360+ data = {"lif_file" : quote (str (lif_file ), safe = "" )},
361+ )
367362 return True
368-
369363 except Exception as e :
370364 logger .error (
371365 f"Error encountered when registering the LIF file in the database: { e } "
@@ -383,19 +377,14 @@ def process_lif_file(
383377 """
384378
385379 try :
386- # Construct the URL to post the request to
387- url = f"{ environment .url .geturl ()} { url_path_for ('clem.router' , 'process_raw_lifs' , session_id = environment .murfey_session )} ?lif_file={ quote (str (lif_file ), safe = '' )} "
388- # Validate
389- if not url :
390- logger .error (
391- "URL could not be constructed from the environment and file path"
392- )
393- return False
394-
395- # Send the message
396- capture_post (url )
380+ capture_post (
381+ base_url = str (environment .url .geturl ()),
382+ router_name = "clem.router" ,
383+ function_name = "process_raw_lifs" ,
384+ session_id = environment .murfey_session ,
385+ data = {"lif_file" : quote (str (lif_file ), safe = "" )},
386+ )
397387 return True
398-
399388 except Exception as e :
400389 logger .error (f"Error encountered processing LIF file: { e } " )
401390 return False
@@ -411,17 +400,14 @@ def register_tiff_file(
411400 """
412401
413402 try :
414- url = f"{ environment .url .geturl ()} { url_path_for ('clem.router' , 'register_tiff_file' , session_id = environment .murfey_session )} ?tiff_file={ quote (str (tiff_file ), safe = '' )} "
415- if not url :
416- logger .error (
417- "URL could not be constructed from the environment and file path"
418- )
419- return False
420-
421- # Send the message
422- capture_post (url )
403+ capture_post (
404+ base_url = str (environment .url .geturl ()),
405+ router_name = "clem.router" ,
406+ function_name = "register_tiff_file" ,
407+ session_id = environment .murfey_session ,
408+ data = {"tiff_file" : quote (str (tiff_file ), safe = "" )},
409+ )
423410 return True
424-
425411 except Exception as e :
426412 logger .error (
427413 f"Error encountered when registering the TIFF file in the database: { e } "
@@ -439,18 +425,14 @@ def process_tiff_series(
439425 """
440426
441427 try :
442- # Construct URL for Murfey server to communicate with
443- url = f"{ environment .url .geturl ()} { url_path_for ('clem.router' , 'process_raw_tiffs' , session_id = environment .murfey_session )} "
444- if not url :
445- logger .error (
446- "URL could not be constructed from the environment and file path"
447- )
448- return False
449-
450- # Send the message
451- capture_post (url , json = tiff_dataset )
428+ capture_post (
429+ base_url = str (environment .url .geturl ()),
430+ router_name = "clem.router" ,
431+ function_name = "process_raw_tiffs" ,
432+ session_id = environment .murfey_session ,
433+ data = tiff_dataset ,
434+ )
452435 return True
453-
454436 except Exception as e :
455437 logger .error (f"Error encountered processing the TIFF series: { e } " )
456438 return False
0 commit comments