Skip to content

Instantly share code, notes, and snippets.

@kgonzago
Last active January 26, 2018 22:43
Show Gist options
  • Save kgonzago/8ee438dd3f7259a25284de1926b04cb4 to your computer and use it in GitHub Desktop.
Save kgonzago/8ee438dd3f7259a25284de1926b04cb4 to your computer and use it in GitHub Desktop.
Collects issues from defense repos and output them to a CSV
#-------------------------------------------------------------------------------
# Name: gh-issues
# Purpose: Write issues from a repo to a csv file
# Created: 1/23/2018
#
# Note:
# Original script came from https://gist.github.com/unbracketed/3380407.
# Modified to fit our needs
#-------------------------------------------------------------------------------
import csv
import requests
GITHUB_USER = '' #supply username
GITHUB_PASSWORD = '' #supply password
#List of Repos
REPOS = ['Esri/distance-direction-addin-dotnet',
'ArcGIS/defense-solutions-jenkins',
'Esri/coordinate-conversion-addin-dotnet',
'Esri/military-features-data',
'Esri/military-symbol-editor-addin-wpf',
'Esri/military-tools-desktop-addins',
'Esri/military-tools-geoprocessing-toolbox',
'ArcGIS/national-security-development-portal',
'ArcGIS/solutions-defense',
'ArcGIS/solutions-defense-test-catalog',
'Esri/solutions-erg-widget',
'Esri/solutions-geoprocessing-toolbox',
'Esri/solutions-grg-widget',
'Esri/visibility-addin-dotnet']
AUTH = (GITHUB_USER, GITHUB_PASSWORD)
CSV_FILE = 'gh-issues.csv' #CSV File
def write_issues(response, csvout):
"output a list of issues to csv"
if not response.status_code == 200:
return False
for issue in response.json():
csvout.writerow(["", issue['number'], issue['url'], issue['title'].encode('utf-8'), issue['body'].encode('utf-8')])
return True
def main():
with open(CSV_FILE, 'wb') as csvFile:
csvout = csv.writer(csvFile)
csvout.writerow(('Priority', 'Issue Number', 'Issue URL', 'Title', 'Notes'))
for REPO in REPOS:
repoIssues = 'https://api.github.com/repos/%s/issues?page=1&per_page=100' % REPO
r = requests.get(repoIssues, auth=AUTH)
if write_issues(r, csvout) == False:
csvout.writerow(["Could not access %s" % REPO, "", "", "", ""])
csvout.writerow("")
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment