Code Monkey home page Code Monkey logo

devpi-tools's People

Contributors

bcicen avatar favipcj avatar ms-ai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

favipcj ms-ai

devpi-tools's Issues

no versions are returned when meta('log') does not exist

All projects on our devpi server that have versions linking to /root/pypi do not have log meta entry (i.e. no info about when uploaded). The available versions should still return a list, even when additional meta information does not exist.

if .json() fails, error is not captured nicely

Hi, thanks for providing the devpi-tools. I found an issue working with devpi-tool in a network environment, where a firewall is in charge and cannot be deactivated. In __init__.py in class DevpiClient in the get_json method in line 24
res = self.request(method, url, headers=headers, verify=verify_ssl).json()
I get a json parsing error, beacuse our firewall is sending back a blockpage in html in self.request(method, url, headers=headers, verify=verify_ssl).text. This error is captured downstrem in the json parser, but it would be nice to cover it in get_json.

This is my modified version:

class DevpiClient(requests.Session):
    """ A very small client for connecting to devpi web API """
    def __init__(self, base_url, disable_ssl_warning=False):
        super(DevpiClient, self).__init__()
        self.base_url = base_url
        self.disable_ssl_warning = disable_ssl_warning

    def get_json(self, path, method='GET', **params):
        url = self.base_url + path
        headers = {'Accept': 'application/json'}
        verify_ssl = True

        if self.disable_ssl_warning:
            requests.packages.urllib3.disable_warnings()
            verify_ssl = False
        res_raw = self.request(method, url, headers=headers, verify=verify_ssl)
        try:
            res = res_raw.json()
        except:
            raise DevpiApiError(f'Result is not in json format: {res_raw.text}')
        if 'message' in res.keys():
            raise DevpiApiError(res['message'])

        return res['result']

For shure not elegant, but maybe you can implement something like this.

BR,
Johannes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.