Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions facet/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import os
import shutil
import subprocess
Expand Down Expand Up @@ -177,9 +178,11 @@ def fetch(self, options):
else:
include_inactive = options.get('--all')
facets = Facet.get_all(include_inactive)
for facet in facets:
facet.fetch()
print(facet.format())

ioloop = asyncio.get_event_loop()
task = asyncio.wait([facet.fetch() for facet in facets])
ioloop.run_until_complete(task)
ioloop.close()

def follow(self, options):
"""
Expand Down
13 changes: 8 additions & 5 deletions facet/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from os import listdir
from os import path

import requests
import aiohttp
import yaml

from facet import settings
Expand Down Expand Up @@ -76,13 +76,16 @@ def apply_patch(self, patch):
config.update(self.read_config())
self.write_config(config)

def fetch(self):
async def fetch(self):
if not self.jira:
return
resp = requests.get(self.jira_json_url)
resp.raise_for_status()
async with aiohttp.ClientSession() as session:
resp = await session.get(self.jira_json_url)
resp.raise_for_status()
data = await resp.json()
with open(self.jira_data_file, 'w') as fp:
dump_json(resp.json(), fp)
dump_json(data, fp)
print(self.format())

def format(self):
if self.jira:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
],
},
install_requires=[
'aiohttp',
'clint',
'docopt',
'pyyaml',
Expand Down