Code Monkey home page Code Monkey logo

chainclient.py's People

Contributors

slash6475 avatar ssfrr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

slash6475

chainclient.py's Issues

Redirects should update the URL

Looks like Requests tells you if the response is the result of a redirect, so we should check that and update the URL so we don't need to redirect next time we visit the URL.

HALDoc seems to forget auth info in create()

In at least one instance we have a report of chainclient.get() being called with auth information, and then after navigating down a few levels and calling create() with no auth= field, no auth information is transmitted.

This needs more testing, maybe somewhere the auth info isn't being passed down to children.

404 responses should re-resolve the parent

We changed some of the URL structure in ChainAPI, and the plan was to do 301 redirects so clients holding old URLs would still work fine, but it turns out redirects and POSTs don't play nicely, so clients with cached POST URLs were SOL.

ChainClient could automatically keep a reference to where it got each link from, and then if it ever gets a 404 it could re-request that object (and recursively do the same thing if THAT request gave a 404). That would be transparent from the application side.

Templated Links

When a link has a templated field, chainclient should support filling in the fields using keyword args

Potential Authorization Bug v0.4.0

A authorization may have occurred while running the tidpost collector of ChainAPI with ChainClient 0.4.0. After reverting to 0.3.0, the bug disappeared; however, the bug was not reproduceable upon returning to 0.4.0.

The output of the tidpost script which failed was:

vagrant@vagrant-ubuntu-trusty-64:/vagrant/collectors$ ./tidpost http://127.0.0.1/sites/1
('yoda', '123')
2014-10-24 20:58:21 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:21 vagrant-ubuntu-trusty-64 __main__[2143] INFO Connecting to TidSense stream at tcp://127.0.0.1:5556
2014-10-24 20:58:21 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:21 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 __main__[2143] INFO Received: {u'src': u'0x816F', u'via': u'0xFFFF', u'sht_humidity': 38.6, u'bmp_pressure': 1003.27, u'battery_voltage': 4.44, u'illuminance': 0, u'sht_temperature': 23.84, u'bmp_temperature': 23.3}
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 __main__[2143] INFO Posting sht_humidity data: {'timestamp': '2014-10-24T20:58:32.755569+00:00', 'value': 38.6}
2014-10-24 20:58:32 vagrant-ubuntu-revertedtrusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 __main__[2143] INFO Posting bmp_pressure data: {'timestamp': '2014-10-24T20:58:32.755569+00:00', 'value': 1003.27}
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 __main__[2143] INFO Posting battery_voltage data: {'timestamp': '2014-10-24T20:58:32.755569+00:00', 'value': 4.44}
2014-10-24 20:58:32 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:33 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:33 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
2014-10-24 20:58:33 vagrant-ubuntu-trusty-64 __main__[2143] INFO Posting illuminance data: {'timestamp': '2014-10-24T20:58:32.755569+00:00', 'value': 0}
2014-10-24 20:58:33 vagrant-ubuntu-trusty-64 urllib3.connectionpool[2143] INFO Starting new HTTP connection (1): 127.0.0.1
Traceback (most recent call last):
  File "./tidpost", line 173, in <module>
    main()
  File "./tidpost", line 86, in main
    post_sensor_data(dev_json, dev)
  File "./tidpost", line 165, in post_sensor_data
    history.create(sensor_data, cache=False)
  File "build/bdist.linux-x86_64/egg/chainclient.py", line 242, in create
  File "build/bdist.linux-x86_64/egg/chainclient.py", line 37, in _request_with_error
chainclient.ChainException: Unauthorized, please authenticate the request with auth=("user", "pass")

As you can see, multiple successful POST requests were made before the script finally failed. The authorization failure resulted from a 401 sent from Nginx (which handles authorization with the .htpasswd file), so the 401 will not show up in the Django log for ChainAPI. Upon debugging with PDB, we noticed that the value of auth in ChainClient when it fails is None, despite the fact that ('yoda', '123') (the correct username and password for the development server) were being used in the tidpost script.

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.