4040import tempfile
4141import zipfile
4242
43- ######################################################################################
43+ ################################################################################
4444# Testing/Retry Functions
45- ######################################################################################
45+ ################################################################################
4646
4747def stop_if_result_none (result ):
4848 '''stop if result none will return True if we should not retry
49- when result is none, False otherwise using retrying python package
49+ when result is none, False otherwise using retrying python package
5050 '''
5151 do_retry = result is not None
5252 return do_retry
5353
5454
5555def test_container (image_path ):
5656 '''test_container is a simple function to send a command to a container, and
57- return the status code and any message run for the test. This comes after
58- :param image_path: path to the container image
57+ return the status code and any message run for the test. This comes after
58+
59+ Parameters
60+ ==========
61+ image_path: path to the container image
5962 '''
6063 from singularity .utils import run_command
6164 bot .debug ('Testing container exec with a list command.' )
6265 testing_command = ["singularity" , "exec" , image_path , 'ls' ]
6366 return run_command (testing_command )
6467
6568
66- ######################################################################################
69+ ################################################################################
6770# Build Templates
68- ######################################################################################
71+ ################################################################################
6972
7073def get_build_template (template_name ,params = None ,to_file = None ):
7174 '''get_build template returns a string or file for a particular build template, which is
72- intended to build a version of a Singularity image on a cloud resource.
73- :param template_name: the name of the template to retrieve in build/scripts
74- :param params: (if needed) a dictionary of parameters to substitute in the file
75- :param to_file: if defined, will write to file. Default returns string.
75+ intended to build a version of a Singularity image on a cloud resource.
76+
77+ Parameters
78+ ==========
79+ template_name: the name of the template to retrieve in build/scripts
80+ params: (if needed) a dictionary of parameters to substitute in the file
81+ to_file: if defined, will write to file. Default returns string.
7682 '''
77- base = get_installdir ()
78- template_folder = "%s/build/scripts" % (base )
79- template_file = "%s/%s" % (template_folder ,template_name )
83+ template_file = get_build_template_path (template_name )
8084 if os .path .exists (template_file ):
8185 bot .debug ("Found template %s" % template_file )
8286
@@ -95,7 +99,25 @@ def get_build_template(template_name,params=None,to_file=None):
9599
96100
97101 else :
98- bot .warning ("Template %s not found." % template_file )
102+ bot .warning ("Template %s not found." % template_file )
103+
104+
105+ def get_build_template_path (template_name ):
106+ '''get_build template returns a string or file for a particular build template, which is
107+ intended to build a version of a Singularity image on a cloud resource.
108+
109+ Parameters
110+ ==========
111+ template_name: the name of the template to retrieve in build/scripts
112+ '''
113+ base = get_installdir ()
114+ template_folder = "%s/build/scripts" % base
115+ template_file = "%s/%s" % (template_folder , template_name )
116+ if os .path .exists (template_file ):
117+ bot .debug ("Found template %s" % template_file )
118+ return template_file
119+ else :
120+ bot .warning ("Template %s not found." % template_file )
99121
100122
101123######################################################################################
0 commit comments