Commits

Akeem Wells authored a42591315be
Add Error Handling if Data file cannot be found
No tags

casatestutils/casatestutils/sparse_check.py

Modified
118 118 bashFile.close()
119 119
120 120 cmd = ("{} checkout_unit_dir.sh".format(os.environ['SHELL'])).split()
121 121 subprocess.call(cmd, stdout = subprocess.DEVNULL, stderr=subprocess.STDOUT)
122 122 os.remove(sh_filename)
123 123
124 124 datafile = open("datafile_list.txt","r")
125 125 gitpaths = datafile.readlines()
126 126
127 127 fetch_path = []
128 + failedfind = []
128 129 for testfile in testfiles:
130 + startlen = len( fetch_path)
129 131 datapaths = [gitpaths[x] for x in [i for i, x in enumerate(gitpaths) if testfile in x]]
130 132 datapaths = [x.rstrip() for x in datapaths if not x.startswith("unittest")]
131 133 datapaths = list(set(["/".join(x.split("/")[:-2]) if not x.startswith(tuple(["text","fits"])) else x for x in datapaths]))
134 + #print(datapaths)
135 + # Check For Path explicitly 1st
132 136 for datapath in datapaths:
133 137 if datapath.endswith(testfile):
134 138 val = datapath
135 139 fetch_path.append(val)
136 140 break
137 - elif testfile in datapath:
138 - val = datapath
139 - fetch_path.append(val)
140 - break
141 + # Check For Path implicitly if not found initially
142 + if len(fetch_path) == 0:
143 + for datapath in datapaths:
144 + if testfile in datapath:
145 + val = datapath
146 + fetch_path.append(val)
147 + break
148 + if len(fetch_path) == startlen:
149 + failedfind.append(testfile)
141 150 datafile.close()
142 151
152 + if len(failedfind) > 0:
153 + print("Cannot Find Requested Data File(s) {}:.\nPlease Check File Names or contact Verification Team".format(",".join(failedfind)))
154 + return
155 +
143 156 sh_filename = "checkout_unit_dir.sh"
144 157 bashFile = open(sh_filename, 'w')
145 158 print("git clone --depth 1 --no-checkout https://open-bitbucket.nrao.edu/scm/casa/casatestdata.git",file = bashFile)
146 159 print("cd casatestdata",file = bashFile)
147 160 print("git config core.sparseCheckout true",file = bashFile)
148 161 print("git config --global filter.lfs.required true",file = bashFile)
149 162 print('git config --global filter.lfs.clean "git-lfs clean -- %f"',file = bashFile)
150 163 print('git config --global filter.lfs.smudge "git-lfs smudge -- %f"',file = bashFile)
151 164 print('git config --global filter.lfs.process "git-lfs filter-process"',file = bashFile)
152 165
166 +
153 167 for path in fetch_path:
154 168 substring = ''
155 169 if path.endswith("/"):
156 170 path = path.rstrip(path[-1])
157 171 if path.startswith(tuple(["text","fits"])): # If in text section of casatestdata
158 172 if path.endswith("jyperk_web_api_response"):
159 173 substring = substring + "{}/*".format(path)
160 174 else:
161 175 substring = substring + "{}".format(path)
162 176 else:

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut