Skip to content

Commit

Permalink
Merge pull request #1 from mevinbabuc/reports
Browse files Browse the repository at this point in the history
Reports
  • Loading branch information
mevinbabuc authored Mar 14, 2018
2 parents 4fa343f + e62533b commit 9ae79c0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion appnexus/model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import re
import time

from thingy import Thingy

Expand Down Expand Up @@ -86,9 +87,18 @@ def profile(self):

class Report(Model):

def download(self, **kwargs):
def download(self, retry_count=3, **kwargs):
# Check if the report is ready to download
while self.is_ready() != 'ready' and retry_count > 0:
logger.debug("Report not ready yet; retrying again")
retry_count -= 1
time.sleep(1)

return self.client.get("report-download", id=self.report_id)

def is_ready(self):
return self.client.get('report', id=self.report_id)['execution_status']


def create_models(services_list):
for service in services_list:
Expand Down

0 comments on commit 9ae79c0

Please sign in to comment.