Commit 67cd4cca authored by abuddenberg's avatar abuddenberg
Browse files

Eliminated another extraneous print. Added http_resp handling to a few methods.

parent e6666d7f
......@@ -16,9 +16,9 @@ gcis = GcisClient('http://data-stage.globalchange.gov', 'andrew.buddenberg@noaa.
def main():
hitlist_file = '../hitlist.pk1'
create_problem_list('nca3', hitlist_file)
print_problem_list(hitlist_file)
# solve_problems(hitlist_file, 'nca3')
# create_problem_list('nca3', hitlist_file)
# print_problem_list(hitlist_file)
solve_problems(hitlist_file, 'nca3')
# print_ready_list(hitlist_file)
def solve_problems(path, report_id):
......@@ -44,7 +44,7 @@ def solve_problems(path, report_id):
for image_id in assocs:
print 'Associating image: {i} with figure: {f}'.format(i=image_id, f=gcis_id)
print gcis.associate_image_with_figure(image_id, report_id, gcis_id)
gcis.associate_image_with_figure(image_id, report_id, gcis_id)
def create_problem_list(report_id, path):
......
......@@ -134,14 +134,17 @@ class GcisClient(object):
return requests.post(update_url, data=image.as_json(), headers=self.headers, verify=False)
@check_image
@http_resp
def delete_image(self, image):
delete_url = '{b}/image/{img}'.format(b=self.base_url, img=image.identifier)
return requests.delete(delete_url, headers=self.headers, verify=False)
@http_resp
def associate_image_with_figure(self, image_id, report_id, figure_id):
url = '{b}/report/{rpt}/figure/rel/{fig}'.format(b=self.base_url, rpt=report_id, fig=figure_id)
return requests.post(url, data=json.dumps({'add_image_identifier': image_id}), headers=self.headers, verify=False)
@http_resp
def upload_image_file(self, image_id, local_path):
url = '{b}/image/files/{id}/{fn}'.format(b=self.base_url, id=image_id, fn=basename(local_path))
# For future multi-part encoding support
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment