Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_status() doesn't return json #86

Closed
gtitov opened this issue Aug 2, 2022 · 8 comments
Closed

get_status() doesn't return json #86

gtitov opened this issue Aug 2, 2022 · 8 comments

Comments

@gtitov
Copy link

gtitov commented Aug 2, 2022

Hey! Thanks for a great product!

Description

geoserver-rest==2.3.4
requests==2.28.1

Geoserver API doesn't return a JSON-response to a request in the get_status() method of the Geoserver class. So return of the method doesn't produce a valid output. I'm not sure if it is only my specific problem because the get_system_status() method works just fine with a similar request.

Code to reproduce

from geo.Geoserver import Geoserver
geo = Geoserver('http://127.0.0.1:9090', username='admin', password='geoserver')
status = geo.get_status()
system_status = geo.get_system_status()
print(status)
print(system_status)

Output (truncated)

('get_status error: ', JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))
{'metrics': {'metric': [{'available': False, 'description': 'Operating system', 'name': 'OPERATING_SYSTEM', 'unit': '', 'category': 'SYSTEM', 'identifier': 'OPERATING_SYSTEM', 'priority': 1, 'value': 'NOT AVAILABLE'}, ...

Possible solution

Add a header to ensure json return.

def get_status(self):
        """
        Returns the status of the geoserver. It shows the status details of all installed and configured modules.
        """
        try:
            url = "{}/rest/about/status.json".format(self.service_url)
            r = requests.get(url, auth=(self.username, self.password), headers={"Accept": "application/json"})
            return r.json()
@jeafreezy jeafreezy mentioned this issue Oct 2, 2022
@Kilometerfresserin
Copy link
Contributor

Kilometerfresserin commented Jan 11, 2023

Hi, thanks for the cool package.

I encountered the same problem @gtitov mentioned, but with the create_coveragestore function.

requests==2.28.1
geoserver-rest==2.4.0

I'd be happy to help fixing, but I've never contributed on any github project, so I'm not quite sure how to start.

@iamtekson
Copy link
Collaborator

Hi @Kilometerfresserin and @gtitov, could you please use the latest version v2.4.0. I think this issue was solved with the latest release.

@Kilometerfresserin
Copy link
Contributor

Kilometerfresserin commented Jan 12, 2023

Hi @iamtekson. Thanks for the quick reply.

I have double-checked my version and I'm sure I'm already running on 2.4.0.

I believe it has been solved for the get_status method that @gtitov mentioned (at least that one works fine for me), but it still occurs with create_coveragestore method.

Again, I'd be happy to provide the bugfix myself, if that is okay with you.

@iamtekson
Copy link
Collaborator

Hi @Kilometerfresserin, Please go ahead and fix the bug. I will merge it. But before doing that, could you please provide the error message on this issue or create new issue?

@JamesSample
Copy link

I've just encountered the same problem with geoserver-rest==2.4.0:

import os
from geo.Geoserver import Geoserver
from config import SETTINGS

geo = Geoserver(
    "https://my/geoserver/url",
    username=SETTINGS.GEOSERVER_USER,
    password=SETTINGS.GEOSERVER_PASSWORD,
)

fpath = r"/path/to/my_file.tif"
fname = os.path.basename(fpath)
layer_name = os.path.splitext(fname)[0]
status = geo.create_coveragestore(
    layer_name=layer_name, path=fpath, workspace="my_workspace"
)
print(status)

Gives the following error:

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

If I downgrade to version 2.3.4, everything works OK.

@iamtekson
Copy link
Collaborator

Thank you for reporting it. I will have a look and fix the things soon. After that, we can close this issue.

@Kilometerfresserin
Copy link
Contributor

Hi @Kilometerfresserin, Please go ahead and fix the bug. I will merge it. But before doing that, could you please provide the error message on this issue or create new issue?

Hi @iamtekson I've checked out main branch, branched from it it and fixed the issue, but I seem to lack permission to publish the new branch:

jw@MacBook-Pro geoserver-rest % git push -u origin issue_86_missing_application_json
remote: Permission to gicait/geoserver-rest.git denied to Kilometerfresserin.
fatal: unable to access 'https://github.com/gicait/geoserver-rest.git/': The requested URL returned error: 403

Maybe I haven't understood github (I've only worked with self-hosted gitlab instances so far) - could someone please explain how to do this correctly around here?

@JamesSample
Copy link

@Kilometerfresserin It is likely that only "core" project contributors have permissions to create and publish branches on the original repository. Instead, you should first "fork" the repository, which creates a copy of the original linked to your own GitHub profile. You can then create a branch on your fork, make changes and commit them to your branch. Finally, make a pull request from the original repository by comparing with changes on your branch. See e.g. here and here.

Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants