Skip to content

Commit

Permalink
Merge pull request #55 from bc-org/master close #54
Browse files Browse the repository at this point in the history
Added requests.content to error messages in order to get more informa…
  • Loading branch information
iamtekson authored Aug 13, 2021
2 parents c089247 + 85b5dcd commit fce9152
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions geo/Geoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def publish_time_dimension_to_coveragestore(
self.username, self.password), headers=headers)

if r.status_code not in [200, 201]:
return '{}: The coveragestore can not have time dimension!'.format(r.status_code)
return '{}: The coveragestore can not have time dimension! {}'.format(r.status_code, r.content)

except Exception as e:
return "Error: {}".format(e)
Expand Down Expand Up @@ -620,13 +620,13 @@ def create_featurestore(
self.username, self.password), headers=headers)

if r.status_code not in [200, 201]:
return '{}: Datastore can not be updated'.format(r.status_code)
return '{}: Datastore can not be updated. {}'.format(r.status_code, r.content)
else:
r = requests.post(url, data=database_connection, auth=(
self.username, self.password), headers=headers)

if r.status_code not in [200, 201]:
return '{}: Data store can not be created!'.format(r.status_code)
return '{}: Data store can not be created! {}'.format(r.status_code, r.content)

except Exception as e:
return "Error: {}".format(e)
Expand Down Expand Up @@ -694,7 +694,7 @@ def create_datastore(
return "Data store created/updated successfully"

else:
raise Exception("datastore can not be created")
raise Exception("datastore can not be created. Status code: {}, {}".format(r.status_code, r.content))

except Exception as e:
return "Error create_datastore: {}".format(e)
Expand Down Expand Up @@ -760,8 +760,8 @@ def create_shp_datastore(
return "The shapefile datastore created successfully!"

else:
return "{}: The shapefile datastore can not be created!".format(
r.status_code
return "{}: The shapefile datastore can not be created! {}".format(
r.status_code, r.content
)

except Exception as e:
Expand Down Expand Up @@ -797,7 +797,7 @@ def publish_featurestore(self, store_name: str, pg_table: str, workspace: Option
r = requests.post(url, data=layer_xml, auth=(
self.username, self.password), headers=headers)
if r.status_code not in [200, 201]:
return '{}: Data can not be published!'.format(r.status_code)
return '{}: Data can not be published! {}'.format(r.status_code, r.content)

except Exception as e:
return "Error: {}".format(e)
Expand Down Expand Up @@ -862,7 +862,7 @@ def publish_featurestore_sqlview(
r = requests.post(url, data=layer_xml, auth=(
self.username, self.password), headers=headers)
if r.status_code not in [200, 201]:
return '{}: Data can not be published!'.format(r.status_code)
return '{}: Data can not be published! {}'.format(r.status_code, r.content)

except Exception as e:
return "Error: {}".format(e)
Expand Down Expand Up @@ -923,7 +923,7 @@ def upload_style(
r_sld = requests.put(url + '/' + name, data=f.read(), auth=(
self.username, self.password), headers=header_sld)
if r_sld.status_code not in [200, 201]:
return '{}: Style file can not be uploaded!'.format(r.status_code)
return '{}: Style file can not be uploaded! {}'.format(r.status_code, r.content)

return r_sld.status_code

Expand Down Expand Up @@ -1061,7 +1061,7 @@ def create_coveragestyle(
r_sld = requests.put(url + '/' + style_name, data=f.read(), auth=(
self.username, self.password), headers=header_sld)
if r_sld.status_code not in [200, 201]:
return '{}: Style file can not be uploaded!'.format(r.status_code)
return '{}: Style file can not be uploaded! {}'.format(r.status_code, r.content)

os.remove('style.sld')

Expand Down Expand Up @@ -1123,7 +1123,7 @@ def create_catagorized_featurestyle(
r_sld = requests.put(url + '/' + style_name, data=f.read(), auth=(
self.username, self.password), headers=header_sld)
if r_sld.status_code not in [200, 201]:
return '{}: Style file can not be uploaded!'.format(r.status_code)
return '{}: Style file can not be uploaded! {}'.format(r.status_code, r.content)

os.remove('style.sld')

Expand Down Expand Up @@ -1180,7 +1180,7 @@ def create_outline_featurestyle(
r_sld = requests.put(url + '/' + style_name, data=f.read(), auth=(
self.username, self.password), headers=header_sld)
if r_sld.status_code not in [200, 201]:
return '{}: Style file can not be uploaded!'.format(r.status_code)
return '{}: Style file can not be uploaded! {}'.format(r.status_code, r.content)

os.remove('style.sld')

Expand Down Expand Up @@ -1245,7 +1245,7 @@ def create_classified_featurestyle(
r_sld = requests.put(url + '/' + style_name, data=f.read(), auth=(
self.username, self.password), headers=header_sld)
if r_sld.status_code not in [200, 201]:
return '{}: Style file can not be uploaded!'.format(r.status_code)
return '{}: Style file can not be uploaded! {}'.format(r.status_code, r.content)

os.remove('style.sld')

Expand Down
2 changes: 1 addition & 1 deletion geo/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

__author__ = "Tek Kshetri"
__email__ = "[email protected]"
__version__ = "2.0.0"
__version__ = "2.0.1.dev0"

0 comments on commit fce9152

Please sign in to comment.