more linting

This commit is contained in:
Joe Steele
2024-06-05 08:32:55 -04:00
parent 4def1bc002
commit 6aa64288c5
+6 -3
View File
@@ -1056,7 +1056,8 @@ def post_to_wp(title, content, headers,date, rating,address, picslist):
"description": description "description": description
} }
try: try:
image_response = requests.post(env.wpAPI + "/media", headers=headers, files=image,timeout=30) image_response = requests.post(env.wpAPI + "/media", headers=headers, \
files=image,timeout=30)
except Exception as error: except Exception as error:
print(" An error uploading picture ' + picname+ ' occurred:", \ print(" An error uploading picture ' + picname+ ' occurred:", \
type(error).__name__) type(error).__name__)
@@ -1067,7 +1068,8 @@ def post_to_wp(title, content, headers,date, rating,address, picslist):
pic_dic=image_response.json() pic_dic=image_response.json()
file_id= pic_dic.get('id') file_id= pic_dic.get('id')
link = pic_dic.get('guid').get("rendered") link = pic_dic.get('guid').get("rendered")
print (' ',picname,' was successfully uploaded to website with ID: ',file_id, link) print (' ',picname,' was successfully uploaded to website with ID: ',\
file_id, link)
try: try:
linksDict = {'file_id' : file_id , 'link' : link} linksDict = {'file_id' : file_id , 'link' : link}
linkslist.append(linksDict) linkslist.append(linksDict)
@@ -1084,7 +1086,8 @@ def post_to_wp(title, content, headers,date, rating,address, picslist):
print (' Error- Image ',picname,' was not attached to post. response: ',\ print (' Error- Image ',picname,' was not attached to post. response: ',\
image_response+' '+error) image_response+' '+error)
try: try:
post_response = requests.post(env.wpAPI + "/posts/" + str(post_id), headers=headers,timeout=30) post_response = requests.post(env.wpAPI + "/posts/" + str(post_id),\
headers=headers,timeout=30)
if link in str(post_response.text): if link in str(post_response.text):
print (' Image link for ', picname, 'already in content of post: ' \ print (' Image link for ', picname, 'already in content of post: ' \
,post_id, post_response.text, link) ,post_id, post_response.text, link)