Comments (6)
@vifrrg thanks for letting me know, I see the issue. I'll integrate the fix.
from dxf.
@vifrrg I don't think we need to check len(rjson['access_token'])
if we've already checked rjson['access_token']
. What do you think?
from dxf.
I was thinking of:
diff --git a/dxf/__init__.py b/dxf/__init__.py
index 9b48aae..304daa0 100644
--- a/dxf/__init__.py
+++ b/dxf/__init__.py
@@ -305,7 +305,8 @@ class DXFBase(object):
r = self._sessions[0].get(auth_url, headers=headers, verify=self._tlsverify)
_raise_for_status(r)
rjson = r.json()
- self.token = rjson['access_token'] if 'access_token' in rjson else rjson['token']
+ # Use 'access_token' value if present and not empty, else 'token' value.
+ self.token = rjson.get('access_token') or rjson['token']
return self._token
self._headers = headers
from dxf.
-
As to checking length: it was my bad habbit from one of previous python version where empty string was treated as 'True' in 'if'. So the code like
if(""): print("blahblahblah")
was printing that "blahblahblah". This behaviour was changed long time ago and I'm still forgetting it every time. :)
In recent python interpreters it is not really needed. You right. -
As to Your fix suggestion:
Yes, it looks more compact and readable then mine. Let me check it in my environment. If it works by the right way - let`s integrate it.
I'll let You know the result in a few hours.
from dxf.
@davedoesdev, Your fix works fine in both cases (old registry without "auth_token" and new one with empty value in it)
May be applied to next release.
Thank You.
from dxf.
@vifrrg released in version 7.5.3
Appreciate the fix!
from dxf.
Related Issues (20)
- Add tag for 7.2.0 HOT 1
- Authentication fails for Azure Container Registry HOT 5
- Authentication fails with key error HOT 1
- del-alias: 405 Client Error: Method Not Allowed HOT 19
- Support for gcr.io HOT 5
- Adds extra '/v2/...' in url for certain repositories HOT 10
- registry-1.docker.io HOT 8
- Mention of get-blob in README HOT 2
- docker pull fails when using set-alias to create or move tag HOT 2
- List tags for specific images HOT 3
- Can I add a note about my project in dxf's readme? HOT 3
- Add a function to do "Cross Repository Blob Mount" HOT 12
- Org-less repos not supported HOT 4
- Resolve a tag to its digest HOT 15
- Back to normal HOT 1
- "dxf get-digest" doesn't work with multi-arch images HOT 12
- get_manifest is unreliable in its return type HOT 2
- Request for head manifest api HOT 4
- Cannot auth on registry that return 200 and empty _catalog for anonymous users HOT 2
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 dxf.