Created
October 15, 2020 03:57
-
-
Save seanbreckenridge/3b585b09bb2f213755fd6da379cbf941 to your computer and use it in GitHub Desktop.
ghexport httpx patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/ghexport/dal.py b/src/ghexport/dal.py | |
index 200a432..a3c78d6 100755 | |
--- a/src/ghexport/dal.py | |
+++ b/src/ghexport/dal.py | |
@@ -10,7 +10,7 @@ from .exporthelpers import dal_helper, logging_helper | |
from .exporthelpers.dal_helper import PathIsh, Json | |
-logger = logging_helper.logger('ghexport') | |
+logger = logging_helper.logger('ghexport', level='INFO') | |
# TODO move DAL bits from mypkg? | |
@@ -48,7 +48,7 @@ class DAL: | |
after = len(emitted) | |
- logger.info('%s: added %d out of %d events', src, (after - before), len(jj)) | |
+ logger.debug('%s: added %d out of %d events', src, (after - before), len(jj)) | |
# TODO merging by id could be sort of generic | |
diff --git a/src/ghexport/export.py b/src/ghexport/export.py | |
index fb624b8..0f5baa3 100755 | |
--- a/src/ghexport/export.py | |
+++ b/src/ghexport/export.py | |
@@ -3,7 +3,28 @@ import argparse | |
import json | |
from typing import NamedTuple, List, Any | |
-from github import Github | |
+import httpx | |
+import requests | |
+ | |
+from github import Github, GithubException # type: ignore | |
+from github.Requester import RequestsResponse, HTTPSRequestsConnectionClass, Requester | |
+ | |
+class HttpxConnectionClass(HTTPSRequestsConnectionClass): | |
+ | |
+ def getresponse(self): | |
+ verb = getattr(httpx, self.verb.lower()) | |
+ url = "%s://%s:%s%s" % (self.protocol, self.host, self.port, self.url) | |
+ if self.verb.lower() == 'get': | |
+ r = verb(url, headers=self.headers) | |
+ else: # for post requests | |
+ r = verb( | |
+ url, | |
+ headers=self.headers, | |
+ data=self.input, | |
+ ) | |
+ return RequestsResponse(r) | |
+ | |
+Requester._Requester__httpsConnectionClass = HttpxConnectionClass | |
from .exporthelpers.export_helper import Json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think I am having the same issue - I still have problems even with just using the repo scope for the token.