예제 #1
0
파일: conftest.py 프로젝트: bjarkirafn/wand
 def finalize():
     if request.node.rep_call.passed:
         return
     imgur_client_id = request.config.getoption('--imgur-client-id')
     if imgur_client_id:
         longrepr = request.node.rep_call.longrepr
         prints = []
         for line, label, format, blob in images:
             req = urllib2.Request(
                 'https://api.imgur.com/3/image',
                 headers={'Authorization': 'Client-ID ' + imgur_client_id},
                 data=urllib.urlencode({
                     'image': base64.b64encode(blob),
                     'title': '[{0}] {1}'.format(line, label)
                 }).encode('ascii')
             )
             response = urllib2.urlopen(req)
             result = json.loads(response.read().decode('utf-8'))
             prints.append((line, label, result['data']['link']))
             response.close()
         longrepr.addsection(
             'display',
             '\n'.join(map('{0[0]} ({0[1]}) {0[2]}'.format, prints))
         )
     else:
         for _, __, format, blob in images:
             with Image(blob=blob, format=format) as i:
                 display_fn(i)
예제 #2
0
파일: conftest.py 프로젝트: dahlia/wand
 def finalize():
     if request.node.rep_call.passed:
         return
     imgur_client_id = request.config.getoption('--imgur-client-id')
     if imgur_client_id:
         longrepr = request.node.rep_call.longrepr
         prints = []
         for line, label, format, blob in images:
             req = urllib2.Request(
                 'https://api.imgur.com/3/image',
                 headers={'Authorization': 'Client-ID ' + imgur_client_id},
                 data=urllib.urlencode({
                     'image': base64.b64encode(blob),
                     'title': '[{0}] {1}'.format(line, label)
                 }).encode('ascii')
             )
             response = urllib2.urlopen(req)
             result = json.loads(response.read().decode('utf-8'))
             prints.append((line, label, result['data']['link']))
             response.close()
         longrepr.addsection(
             'display',
             '\n'.join(map('{0[0]} ({0[1]}) {0[2]}'.format, prints))
         )
     else:
         for _, __, format, blob in images:
             with Image(blob=blob, format=format) as i:
                 display_fn(i)
예제 #3
0
 def finalize():
     if request.node.rep_call.passed:
         return
     imgur_client_id = request.config.getoption("--imgur-client-id")
     if imgur_client_id:
         longrepr = request.node.rep_call.longrepr
         prints = []
         for line, label, format, blob in images:
             req = urllib2.Request(
                 "https://api.imgur.com/3/image",
                 headers={"Authorization": "Client-ID " + imgur_client_id},
                 data=urllib.urlencode(
                     {"image": base64.b64encode(blob), "title": "[{0}] {1}".format(line, label)}
                 ).encode("ascii"),
             )
             response = urllib2.urlopen(req)
             result = json.loads(response.read().decode("utf-8"))
             prints.append((line, label, result["data"]["link"]))
             response.close()
         longrepr.addsection("display", "\n".join(map("{0[0]} ({0[1]}) {0[2]}".format, prints)))
     else:
         for _, __, format, blob in images:
             with Image(blob=blob, format=format) as i:
                 display_fn(i)