[Buildbot-devel] Obtain build times from the json API

Ian Bell ian.h.bell at gmail.com
Tue Nov 25 19:48:46 UTC 2014


Vasily,

Here is a complete solution - thanks for your help!  It works great!

import urllib, json
filehandle = urllib.urlopen('
http://www.coolprop.dreamhosters.com:8010/json/builders')
jj = json.loads(filehandle.read())

times = []
for key in jj.keys():
    filehandle = urllib.urlopen('
http://www.coolprop.dreamhosters.com:8010/json/builders/' + key +
'/builds/-1')
    builder = json.loads(filehandle.read())
    elapsed_time = builder['times'][1] - builder['times'][0]
    times.append((elapsed_time, key))

print sorted(times)[::-1]

On Tue, Nov 25, 2014 at 1:58 PM, Vasily <vasslitvinov at pisem.net> wrote:

> I don't know what this wget module is, but normal wget binary downloads
> those json urls just fine for me...
>
> As a workaround you may try to append "?as_text=1" at the end of the url,
> this should change MIME type to a file, maybe your wget will handle that.
>
> Or you may just try to use urllib.urlopen() function which is built in
> standard Python library.
>
> Thanks,
> Vasily
> 25 нояб. 2014 г. 18:47 пользователь "Ian Bell" <ian.h.bell at gmail.com>
> написал:
>
> Right, I think I have that all sorted, the only bit that I can't figure
>> out is how to programmatically download the JSON data from the server.
>> Since there isn't a .json url to be downloaded, I can't do something like
>>
>> import wget
>> json_file = wget.download('
>> www.coolprop.dreamhosters.com:8010/json/builders
>> <http://www.coolprop.dreamhosterscom:8010/json/builders>')
>>
>> It just sits there and doesn't do anything.
>>
>> You've been very helpful so far, and I am very appreciative.  Any ideas?
>>
>> On Mon, Nov 24, 2014 at 11:40 PM, Vasily <vasslitvinov at pisem.net> wrote:
>>
>>> Hello,
>>>
>>> Have a look at <host:port>/json/help ;-)
>>>
>>> Thanks,
>>> Vasily
>>> 25 нояб. 2014 г. 2:41 пользователь "Ian Bell" <ian.h.bell at gmail.com>
>>> написал:
>>>
>>>> Very nice, yes that does seem to work, now just to get a list of slaves
>>>> from json.
>>>>
>>>> On Mon, Nov 24, 2014 at 3:02 PM, Vasily <vasslitvinov at pisem.net> wrote:
>>>>
>>>>> Hi Ian,
>>>>>
>>>>> What Buildbot version your master is running?
>>>>>
>>>>> At ours 0.8.7p1 the query like
>>>>> <builmaster_host:port>/json/builders/<builder_name>/builds/-1/
>>>>> returns JSON object for the latest completed build which contains a
>>>>> section named "times" - those are start and finish time in Unix notation if
>>>>> I'm not mistaken.
>>>>>
>>>>> Thanks,
>>>>> Vasily
>>>>>
>>>>> 2014-11-24 22:13 GMT+03:00 Ian Bell <ian.h.bell at gmail.com>:
>>>>>
>>>>>> I have quite a few builds in my buildbot config, and I know some are
>>>>>> slower than others, and I want to see what can be done to improve the build
>>>>>> latency.  So I was hoping to be able to obtain the last build duration
>>>>>> through the JSON api, but I haven't been able to figure out how to do
>>>>>> that..  Am I missing something obvious, or is this just not possible?
>>>>>>
>>>>>> Best,
>>>>>> Ian
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>>>> from Actuate! Instantly Supercharge Your Business Reports and
>>>>>> Dashboards
>>>>>> with Interactivity, Sharing, Native Excel Exports, App Integration &
>>>>>> more
>>>>>> Get technology previously reserved for billion-dollar corporations,
>>>>>> FREE
>>>>>>
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Buildbot-devel mailing list
>>>>>> Buildbot-devel at lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/buildbot-devel
>>>>>>
>>>>>>
>>>>>
>>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20141125/c9fe2ce3/attachment.html>


More information about the devel mailing list