Comments (10)
This is the reply from curl (which seems to automatically decompress):
< HTTP/1.1 200 OK
- Server cloudflare-nginx is not blacklisted
< Server: cloudflare-nginx
< Date: Thu, 23 Apr 2015 14:58:09 GMT
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Set-Cookie: __cfduid=d5c1fb13695ce4338c5c1e5743d0445e51429801088; expires=Fri, 22-Apr-16 14:58:08 GMT; path=/; domain=.digitalocean.com; HttpOnly
< Status: 200 OK
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< RateLimit-Limit: 5000
< RateLimit-Remaining: 4979
< RateLimit-Reset: 1429801676
< Cache-Control: max-age=0, private, must-revalidate
< X-Request-Id: 3b4b9f00-f489-408e-867d-1bf6e4176434
< X-Runtime: 0.029200
< CF-RAY: 1dba6cc2a087081d-SIN
< - Connection #0 to host api.digitalocean.com left intact
{"ssh_keys":[{"id":734303,"fingerprint":"db:35:33:37:61:c5:90:2c:a9:84:dd:21:d1:98:bf:7e","public_key":"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1hJmk++W25dI9D3z6Y9+3OjqnYpoo7/VWoXiUm3Qy63Rr295rV0jaOCbH6XYqkEt9/g8QbdC5cLnDoPZqe7TG2DhaajyGUE6VtAW2yecu1HVdLrjgRG5QzwvcbuN4zJjU7O05vv0mOUV2/d4djKy21ou8SNGuFAXoLl8P49eM4vfA7jYmXKaQ2PuV5GPYBkylc5srYid6H4JYbADnJvE1FgJB1PdKD13LW7+WcDDt3a4S/hpTcGiG/KMDdRuNCcBazNmAQu05RlJwDdHVnyPIpt8clzCYp7OMZeO4JIkYoV8SlhUNQp/xdoxJQabLmjYPyuenAFTfIeOsv8r7wy/Zw== [email protected]","name":"[email protected]"}],"links":{},"meta":{"total":1}}
from python-digitalocean.
Can you show me the error/problem connected with the line of code of python-digitalocean?
from python-digitalocean.
I'm using requests (2.6.1) btw...
import digitalocean
manager = digitalocean.Manager(token=DIGITALOCEAN_TOKEN)
my_droplets = manager.get_all_droplets()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/digitalocean/Manager.py", line 82, in get_all_droplets
data = self.get_data("droplets/")
File "/usr/local/lib/python2.7/site-packages/digitalocean/Manager.py", line 32, in get_data
data = super(Manager, self).get_data(_args, *_kwargs)
File "/usr/local/lib/python2.7/site-packages/digitalocean/baseapi.py", line 108, in get_data
'Read failed from DigitalOcean: %s' % e.message
digitalocean.baseapi.JSONReadError: Read failed from DigitalOcean: Expecting value: line 1 column 1 (char 0)
Same issue with other libraries it seems. Root cause should be requests.
from python-digitalocean.
Can you run the tests with docker? Have you tried with other machines or OSs?
from python-digitalocean.
No. If it works fine on your end it may be a strange local issue with requests.
So I've run the tests. (They all pass.) I've also had a look at them. They are mocking requests, so everything comes back as well-formed JSON.
The case of 'content-encoding': 'gzip' just does not happen.
from python-digitalocean.
Try on another machine: it maybe be a problem with your gzip. It seems not to be a issue related to this Python library! Check that ;-)
Inviato da iPhone
Il giorno 23/apr/2015, alle ore 17:35, Jeremy Chen [email protected] ha scritto:
No. If it works fine on your end it may be a strange local issue with requests.
So I've run the tests. (They all pass.) I've also had a look at them. They are mocking requests, so everything comes back as well-formed JSON.
The case of 'content-encoding': 'gzip' just does not happen.
—
Reply to this email directly or view it on GitHub.
from python-digitalocean.
I've tried it on another machine. The same thing happens on a Mac and Centos Linux.
Anyway, modifying the get_data
method of the BaseAPI
object in baseapi.py
to handle this case quickly fixes the issue at no real cost.
if 'content-encoding' in req.headers and req.headers['content-encoding'] == 'gzip': # deal with case when content remains compressed data = json.loads(zlib.decompress(req.content, 16+zlib.MAX_WBITS)) else: data = req.json()
It's up to you if you'd like to use this.
from python-digitalocean.
Which OS are you using? what is the version? This sounds strange to me but I will check. Probably it is better to notify python requests too! https://github.com/kennethreitz/requests
from python-digitalocean.
CentOS Linux release 7.0.1406 (Core) (Python Python 2.7.5 via yum; requests 2.6.1)
and
OS X Yosemite 10.10.2 (Python 2.7.9 via Brew; requests 2.6.1)
from python-digitalocean.
Closed as fixed by python requests team. See #108
This is not related to python-digitalocean but it is good to share this! 👍
from python-digitalocean.
Related Issues (20)
- Load balancer and certificate APIs are returning digitalocean.NotFoundError
- Unable to import module 'Manager' HOT 1
- the API v2 does not seem to provide account name aka team name aka user name. Can advise?
- droplet shutdown is not working HOT 1
- Delete a domain record HOT 4
- Make droplet.create() return a value - so it can be used with 'await' ? HOT 1
- Getting Credits information HOT 1
- No get_actions() for Volume? HOT 1
- Proposing a PR to fix a few small typos
- New release HOT 3
- RedRocket.pssss HOT 1
- Domain.create_new_domain_record ttl kwarg is ignored HOT 1
- Kuberenetes Support HOT 1
- Floating IP Error - digitalocean.DataReadError: HOT 1
- DigitalOcean Api token HOT 2
- Error (400/500) responses with no body raise JSONReadError
- Monitoring metrics from API
- Apps Support
- Add with_droplet_agent support
- Adding type annotation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-digitalocean.