← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] lp:~cjwatson/launchpad/treq into lp:launchpad

 

Review: Approve code



Diff comments:

> 
> === modified file 'lib/lp/snappy/model/snapbuildbehaviour.py'
> --- lib/lp/snappy/model/snapbuildbehaviour.py	2018-05-02 12:45:12 +0000
> +++ lib/lp/snappy/model/snapbuildbehaviour.py	2018-07-02 00:28:14 +0000
> @@ -152,18 +152,14 @@
>              build_id=self.build.build_cookie,
>              timestamp=timestamp)
>          auth_string = '{}:{}'.format(admin_username, secret).strip()
> -        auth_header = 'Basic ' + base64.b64encode(auth_string)
> -        data = json.dumps({'username': proxy_username})
> +        auth_header = b'Basic ' + base64.b64encode(auth_string)
>  
> -        result = yield getPage(
> -            url,
> -            method='POST',
> -            postdata=data,
> -            headers={
> -                'Authorization': auth_header,
> -                'Content-Type': 'application/json'}
> -            )
> -        token = json.loads(result)
> +        response = yield treq.post(
> +            url, headers={'Authorization': auth_header},
> +            json={'username': proxy_username},
> +            reactor=self._slave.reactor,
> +            pool=self._slave.pool).addCallback(check_status)
> +        token = yield treq.json_content(response)

It's slightly weird that you use addCallback for check_status but chain json_content manually with yield.

>          defer.returnValue(token)
>  
>      def verifySuccessfulBuild(self):


-- 
https://code.launchpad.net/~cjwatson/launchpad/treq/+merge/348808
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.


References