Skip to content

Instantly share code, notes, and snippets.

@seanbreckenridge
Created October 15, 2020 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanbreckenridge/3b585b09bb2f213755fd6da379cbf941 to your computer and use it in GitHub Desktop.
Save seanbreckenridge/3b585b09bb2f213755fd6da379cbf941 to your computer and use it in GitHub Desktop.
ghexport httpx patch
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
@vijmeister
Copy link

Hi, how / where would I apply the patch? I am not yet too familiar with gists

@seanbreckenridge
Copy link
Author

seanbreckenridge commented May 3, 2021

@vijmeister you can use my fork here for now

like

pip3 install --user git+https://github.com/seanbreckenridge/ghexport

@seanbreckenridge
Copy link
Author

Also am curious, are you doing this because you have the same issue as described in the issue?

I was under the impression it was just me having that issue

@vijmeister
Copy link

I think I am having the same issue - I still have problems even with just using the repo scope for the token.

@seanbreckenridge
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment