- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
# returns yesterday reports
def get_yesterday_reports(self):
pass
def get_waterfall_sources(self, wf_id, active_only=False):
# TODO: check if meta property is equal to the number of items in the array
# return test.mock_waterfall_sources.get_sources()
status = '1' if active_only else urllib.quote('0,1') # '0%2C1&'
self.get_auth_token()
encoded = urllib.urlencode({'authorization': self.token})
url = BASE_URL + "/waterfall-ad-sources?advertiser=&itemsPerPage=9999&name=&page=1&sortAsc=true&sortBy=tier&status={}&tier=&waterfall={}&{}" \
.format(status, wf_id, encoded)
retries = 1
while retries <= 3:
response = requests.get(url)
if response.status_code == 200:
break
else:
logging.error('Failed GET request to StreamRail, status code {}, {} retries'
.format(response.status_code, retries))
retries += 1
assert response.status_code == 200
try:
data = simplejson.loads(response.content)
waterfall_sources = data['waterfallAdSources']
assert int(data['meta']['total']) == len(waterfall_sources)
return waterfall_sources
except:
logging.exception("Could not load ad sources for waterfall {} from StreamRail:\n"
"{}".format(wf_id, response.headers))
raise
Хотя, с другой стороны, все эти рекламораспространители так выглядят. Но тут просто кучно так получилось.
syoma 26.12.2017 04:28 # 0