Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to access github Release Asset API. #525

Merged
merged 10 commits into from
Nov 27, 2017
Prev Previous commit
Next Next commit
Add requestBlobAndCheck to fix python3 result bug reported by @NicoHood
  • Loading branch information
ankona authored and Christopher McBride committed May 17, 2017
commit 6a6d5ca1b6f4e89c974aab594e1ab1e2994eb768
4 changes: 2 additions & 2 deletions github/GitRelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ def upload_asset(self, path, label="", content_type=""):
headers = {}
if len(content_type) > 0:
headers["Content-Type"] = content_type
status, resp_headers, data = self._requester.requestBlob(
_, data = self._requester.requestBlobAndCheck(
"POST",
self.upload_url.split("{?")[0],
parameters=post_parameters,
headers=headers,
input=path
)
return github.GitReleaseAsset.GitReleaseAsset(self._requester, headers, data, completed=True) if status == 201 else None
return github.GitReleaseAsset.GitReleaseAsset(self._requester, headers, data, completed=True)

def get_assets(self):
return github.PaginatedList.PaginatedList(
Expand Down
8 changes: 4 additions & 4 deletions github/Requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ def requestJsonAndCheck(self, verb, url, parameters=None, headers=None, input=No
def requestMultipartAndCheck(self, verb, url, parameters=None, headers=None, input=None):
return self.__check(*self.requestMultipart(verb, url, parameters, headers, input))

def requestBlobAndCheck(self, verb, url, parameters=None, headers=None, input=None):
return self.__check(*self.requestBlob(verb, url, parameters, headers, input))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt we change back the __hostname here? My subsequent api calls failed due to the host name assertion fails in requester..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See fix in #771


def __check(self, status, responseHeaders, output):
output = self.__structuredFromJson(output)
if status >= 400:
Expand Down Expand Up @@ -239,10 +242,7 @@ def encode(local_path):
f = open(local_path)
return mime_type, f

#todo: determine how to add in requestBlobAndCheck feature
status, responseHeaders, output = self.__requestEncode(None, verb, url, parameters, headers, input, encode)

return status, responseHeaders, json.loads(output)
return self.__requestEncode(None, verb, url, parameters, headers, input, encode)

def __requestEncode(self, cnx, verb, url, parameters, requestHeaders, input, encode):
assert verb in ["HEAD", "GET", "POST", "PATCH", "PUT", "DELETE"]
Expand Down