Skip to content

Commit

Permalink
Merge pull request #75 from SAG-iBit/bugfix/connections
Browse files Browse the repository at this point in the history
Close connections opened on cron sync
  • Loading branch information
Jared Murrell authored Apr 12, 2021
2 parents d2b8f0f + a0f2a76 commit 7dadb4a
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,12 @@ def get_app_installations():
:return:
"""
with app.app_context() as ctx:
c = ctx.push()
gh = GitHubApp(c)
installations = gh.app_client.app_installations
try:
c = ctx.push()
gh = GitHubApp(c)
installations = gh.app_client.app_installations
finally:
ctx.pop()
return installations


Expand All @@ -262,24 +265,27 @@ def sync_all_teams():
print("========================================================")
print(f"## Processing Organization: {i.account['login']}")
print("========================================================")
try:
gh = GitHubApp(app.app_context().push())
client = gh.app_installation(installation_id=i.id)
org = client.organization(i.account["login"])
for team in org.teams():
try:
sync_team(
client=client,
owner=org.login,
team_id=team.id,
slug=team.slug,
)
except Exception as e:
print(f"Organization: {org.login}")
print(f"Unable to sync team: {team.slug}")
print(f"DEBUG: {e}")
except Exception as e:
print(f"DEBUG: {e}")
with app.app_context() as ctx:
try:
gh = GitHubApp(ctx.push())
client = gh.app_installation(installation_id=i.id)
org = client.organization(i.account["login"])
for team in org.teams():
try:
sync_team(
client=client,
owner=org.login,
team_id=team.id,
slug=team.slug,
)
except Exception as e:
print(f"Organization: {org.login}")
print(f"Unable to sync team: {team.slug}")
print(f"DEBUG: {e}")
except Exception as e:
print(f"DEBUG: {e}")
finally:
ctx.pop()


sync_all_teams()
Expand Down

0 comments on commit 7dadb4a

Please sign in to comment.