From 2b0a13e7c474826b571d0b0dc01c049031fa1535 Mon Sep 17 00:00:00 2001 From: dcastr5x Date: Mon, 5 Nov 2018 10:35:11 -0600 Subject: [PATCH] Download stat info for class accessor Recursive Example --- artifactory.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/artifactory.py b/artifactory.py index ba44a89..4e0a96a 100755 --- a/artifactory.py +++ b/artifactory.py @@ -474,6 +474,24 @@ def get_stat_json(self, pathobj): return json.loads(text) + def get_downloads_stat_json(self, pathobj): + """ + Request remote file/directory download info only + Returns a json object as specified by Artifactory REST API + """ + url = '/'.join([pathobj.drive, + 'api/storage', + str(pathobj.relative_to(pathobj.drive)).strip('/'), '?stats']) + + text, code = self.rest_get(url, auth=pathobj.auth, verify=pathobj.verify, + cert=pathobj.cert) + if code == 404 and "Unable to find item" in text: + raise OSError(2, "No such file or directory: '%s'" % url) + if code != 200: + raise RuntimeError(text) + + return json.loads(text) + def stat(self, pathobj): """ Request remote file/directory status info