99from caltechdata_api import customize_schema
1010
1111
12- def write_files_rdm (files , file_link , headers , f_headers , verify , s3 = None ):
12+ def write_files_rdm (files , file_link , headers , f_headers , s3 = None ):
1313 f_json = []
1414 f_list = {}
1515 for f in files :
1616 filename = f .split ("/" )[- 1 ]
1717 f_json .append ({"key" : filename })
1818 f_list [filename ] = f
19- result = requests .post (file_link , headers = headers , json = f_json , verify = verify )
19+ result = requests .post (file_link , headers = headers , json = f_json )
2020 if result .status_code != 201 :
2121 raise Exception (result .text )
2222 # Now we have the upload links
@@ -30,10 +30,10 @@ def write_files_rdm(files, file_link, headers, f_headers, verify, s3=None):
3030 infile = open (f_list [name ], "rb" )
3131 # size = infile.seek(0, 2)
3232 # infile.seek(0, 0) # reset at beginning
33- result = requests .put (link , headers = f_headers , verify = verify , data = infile )
33+ result = requests .put (link , headers = f_headers , data = infile )
3434 if result .status_code != 200 :
3535 raise Exception (result .text )
36- result = requests .post (commit , headers = headers , verify = verify )
36+ result = requests .post (commit , headers = headers )
3737 if result .status_code != 200 :
3838 raise Exception (result .text )
3939
@@ -64,13 +64,13 @@ def add_file_links(metadata, file_links):
6464 return metadata
6565
6666
67- def send_to_community (review_link , data , headers , verify , publish , community ):
67+ def send_to_community (review_link , data , headers , publish , community ):
6868
6969 data = {
7070 "receiver" : {"community" : community },
7171 "type" : "community-submission" ,
7272 }
73- result = requests .put (review_link , json = data , headers = headers , verify = verify )
73+ result = requests .put (review_link , json = data , headers = headers )
7474 if result .status_code != 200 :
7575 raise Exception (result .text )
7676 submit_link = result .json ()["links" ]["actions" ]["submit" ]
@@ -80,7 +80,7 @@ def send_to_community(review_link, data, headers, verify, publish, community):
8080 "format" : "html" ,
8181 }
8282 }
83- result = requests .post (submit_link , json = data , headers = headers , verify = verify )
83+ result = requests .post (submit_link , json = data , headers = headers )
8484 if result .status_code != 200 :
8585 raise Exception (result .text )
8686 if publish :
@@ -91,7 +91,7 @@ def send_to_community(review_link, data, headers, verify, publish, community):
9191 "format" : "html" ,
9292 }
9393 }
94- result = requests .post (accept_link , json = data , headers = headers , verify = verify )
94+ result = requests .post (accept_link , json = data , headers = headers )
9595 if result .status_code != 200 :
9696 raise Exception (result .text )
9797 return result
@@ -128,10 +128,8 @@ def caltechdata_write(
128128 data = customize_schema .customize_schema (copy .deepcopy (metadata ), schema = schema )
129129 if production == True :
130130 url = "https://data.caltech.edu/"
131- verify = True
132131 else :
133132 url = "https://data.caltechlibrary.dev/"
134- verify = False
135133
136134 headers = {
137135 "Authorization" : "Bearer %s" % token ,
@@ -150,7 +148,7 @@ def caltechdata_write(
150148
151149 # Make draft and publish
152150 result = requests .post (
153- url + "/api/records" , headers = headers , json = data , verify = verify
151+ url + "/api/records" , headers = headers , json = data
154152 )
155153 if result .status_code != 201 :
156154 raise Exception (result .text )
@@ -159,15 +157,15 @@ def caltechdata_write(
159157
160158 if files :
161159 file_link = result .json ()["links" ]["files" ]
162- write_files_rdm (files , file_link , headers , f_headers , verify , s3 )
160+ write_files_rdm (files , file_link , headers , f_headers , s3 )
163161
164162 if community :
165163 review_link = result .json ()["links" ]["review" ]
166- send_to_community (review_link , data , headers , verify , publish , community )
164+ send_to_community (review_link , data , headers , publish , community )
167165
168166 else :
169167 if publish :
170- result = requests .post (publish_link , headers = headers , verify = verify )
168+ result = requests .post (publish_link , headers = headers )
171169 if result .status_code != 202 :
172170 raise Exception (result .text )
173171 return idv
0 commit comments