Tobias Henkel | 38f4ea3 | 2017-12-20 16:43:46 +0100 | [diff] [blame^] | 1 | import github3 |
| 2 | import logging |
| 3 | import time |
| 4 | |
| 5 | # This is a template with boilerplate code for debugging github issues |
| 6 | |
| 7 | # TODO: for real use override the following variables |
| 8 | url = 'https://example.com' |
| 9 | api_token = 'xxxx' |
| 10 | org = 'org' |
| 11 | project = 'project' |
| 12 | pull_nr = 3 |
| 13 | |
| 14 | |
| 15 | # Send the logs to stderr as well |
| 16 | stream_handler = logging.StreamHandler() |
| 17 | |
| 18 | |
| 19 | logger_urllib3 = logging.getLogger('requests.packages.logger_urllib3') |
| 20 | # logger_urllib3.addHandler(stream_handler) |
| 21 | logger_urllib3.setLevel(logging.DEBUG) |
| 22 | |
| 23 | logger = logging.getLogger('github3') |
| 24 | # logger.addHandler(stream_handler) |
| 25 | logger.setLevel(logging.DEBUG) |
| 26 | |
| 27 | |
| 28 | github = github3.GitHubEnterprise(url) |
| 29 | |
| 30 | |
| 31 | # This is the currently broken cache adapter, enable or replace it to debug |
| 32 | # caching |
| 33 | |
| 34 | # import cachecontrol |
| 35 | # from cachecontrol.cache import DictCache |
| 36 | # cache_adapter = cachecontrol.CacheControlAdapter( |
| 37 | # DictCache(), |
| 38 | # cache_etags=True) |
| 39 | # |
| 40 | # github.session.mount('http://', cache_adapter) |
| 41 | # github.session.mount('https://', cache_adapter) |
| 42 | |
| 43 | |
| 44 | github.login(token=api_token) |
| 45 | |
| 46 | i = 0 |
| 47 | while True: |
| 48 | pr = github.pull_request(org, project, pull_nr) |
| 49 | prdict = pr.as_dict() |
| 50 | issue = pr.issue() |
| 51 | labels = list(issue.labels()) |
| 52 | print(labels) |
| 53 | i += 1 |
| 54 | print(i) |
| 55 | time.sleep(1) |