xref: /6.0.3/testrunner/lib/builds/build_query.py (revision 91bc7681)
1#this class will contain methods which we
2#use later to
3# map a version # -> rpm url
4from datetime import datetime
5import time
6import urllib2
7import re
8import socket
9import BeautifulSoup
10import testconstants
11import logger
12import traceback
13import sys
14from testconstants import WIN_CB_VERSION_3
15from testconstants import SHERLOCK_VERSION
16from testconstants import COUCHBASE_VERSION_2
17from testconstants import COUCHBASE_VERSION_3
18from testconstants import COUCHBASE_VERSION_2_WITH_REL
19from testconstants import COUCHBASE_RELEASE_FROM_VERSION_3,\
20                          COUCHBASE_RELEASE_FROM_SPOCK
21from testconstants import COUCHBASE_FROM_VERSION_3, COUCHBASE_FROM_SPOCK, \
22                          COUCHBASE_FROM_ALICE, COUCHBASE_FROM_MAD_HATTER, \
23                          COUCHBASE_FROM_601
24from testconstants import CB_RELEASE_REPO
25from testconstants import CB_LATESTBUILDS_REPO
26from testconstants import CE_EE_ON_SAME_FOLDER
27
28
29class MembaseBuild(object):
30    def __init__(self):
31        self.url = ''
32        self.name = ''
33        self.time = ''
34        self.size = ''
35        self.product = ''
36        self.product_version = ''
37        self.build_number = 0
38        self.os = ''
39        self.deliverable_type = ''
40        self.architecture_type = ''
41        self.toy = ''
42        self.change = None  # a MembaseChange
43        self.url_latest_build = ''
44
45    def __repr__(self):
46        return self.__str__()
47
48    #let's also have a json object for all these classes
49    def __str__(self):
50        url = 'url : {0}'.format(self.url)
51        name = 'name : {0}'.format(self.name)
52        product = 'product : {0}'.format(self.product)
53        product_version = 'product_version : {0}'.format(self.product_version)
54        os = 'os : {0}'.format(self.os)
55        deliverable_type = 'deliverable_type : {0}'.format(self.deliverable_type)
56        architecture_type = 'architecture_type : {0}'.format(self.architecture_type)
57        if self.toy:
58            toy = 'toy : {0}'.format(self.toy)
59        else:
60            toy = ''
61        return '{0} {1} {2} {3} {4} {5} {6} {7}'.format(url, name, product, product_version, os, deliverable_type,
62                                                    architecture_type, toy)
63
64
65class MembaseChange(object):
66    def __init__(self):
67        self.url = ''
68        self.name = ''
69        self.time = ''
70        self.build_number = ''
71
72
73class BuildQuery(object):
74    def __init__(self):
75        self.log = logger.Logger.get_logger()
76        pass
77
78    # let's look at buildlatets or latest/sustaining or any other
79    # location
80    def parse_builds(self):
81        #parse build page and create build object
82        pass
83
84    def find_build(self, builds, product, type, arch, version, toy='', openssl='', \
85                   direct_build_url=None, distribution_version=None, \
86                   distribution_type=""):
87        if direct_build_url is None:
88            if not isinstance(builds, list) and builds.url is not None:
89                return builds
90            else:
91                for build in builds:
92                    if build.product_version.find(version) != -1 and product == build.product\
93                       and build.architecture_type == arch and type == build.deliverable_type\
94                       and build.toy == toy:
95                        return build
96        elif direct_build_url != "":
97            if "exe" in builds.deliverable_type:
98                if "rel" in version and version[:5] in WIN_CB_VERSION_3:
99                    version = version.replace("-rel", "")
100            """ direct url only need one build """
101
102            """ if the job trigger with url, no need to check version.
103                remove builds.product_version.find(version) != -1 """
104            if product == builds.product and builds.architecture_type == arch:
105                return builds
106            else:
107                self.log.info("if build not found, url link may not match...")
108        return None
109
110    def find_membase_build(self, builds, product, deliverable_type, os_architecture, build_version, is_amazon=False):
111        if is_amazon:
112            build = BuildQuery().find_build(builds, product, deliverable_type,
113                                            os_architecture, build_version)
114            if build:
115                build.url = build.url.replace("http://builds.hq.northscale.net", \
116                                                  "http://packages.northscale.com.s3.amazonaws.com")
117                build.url = build.url.replace("enterprise", "community")
118                build.name = build.name.replace("enterprise", "community")
119                return build
120
121        for build in builds:
122            if build.product_version.find(build_version) != -1 and product == build.product\
123               and build.architecture_type == os_architecture and deliverable_type == build.deliverable_type:
124                return build
125
126        return None
127
128    def find_membase_build_with_version(self, builds, build_version):
129        for build in builds:
130            if build.product_version == build_version or build.product_version.find(build_version) != -1:
131                #or if it starts with that version ?
132                return build
133        return None
134
135    def find_membase_release_build(self, product, deliverable_type, os_architecture,
136                                    build_version, is_amazon=False, os_version=""):
137        build_details = build_version
138        if build_version[:5] in COUCHBASE_VERSION_2_WITH_REL:
139            if build_version[-4:] != "-rel":
140                build_details = build_details + "-rel"
141        elif build_version.startswith("1.8.0"):
142            build_details = "1.8.0r-55-g80f24f2"
143            product = "couchbase-server-enterprise"
144        build = MembaseBuild()
145        build.deliverable_type = deliverable_type
146        build.time = '0'
147        build.size = '0'
148        build.product_version = build_version
149        build.architecture_type = os_architecture
150        build.product = product
151        os_name = ""
152        build.name = '{1}_{2}_{0}.{3}'.format(build_version, product,
153                                               os_architecture, deliverable_type)
154        build.build_number = 0
155        if deliverable_type == "exe":
156            """ /3.0.1/couchbase-server-enterprise_3.0.1-windows_amd64.exe """
157            if not re.match(r'[1-9].[0-9].[0-9]$', build_version):
158                if build_version[:5] in COUCHBASE_RELEASE_FROM_VERSION_3:
159                    arch_type = "amd64"
160                    if "x86_64" not in os_architecture:
161                        arch_type = "x86"
162                    build.url = "{5}{0}/{1}_{4}-windows_{2}.{3}"\
163                        .format(build_version[:build_version.find('-')],
164                        product, arch_type, deliverable_type, build_details[:5],
165                        CB_RELEASE_REPO)
166                else:
167                    if "2.5.2" in build_details[:5]:
168                        build.url = "{5}{0}/{1}_{4}_{2}.setup.{3}"\
169                            .format(build_version[:build_version.find('-')],
170                            product, os_architecture, deliverable_type,
171                            build_details[:5], CB_RELEASE_REPO)
172                    else:
173                        build.url = "{5}{0}/{1}_{2}_{4}.setup.{3}"\
174                            .format(build_version[:build_version.find('-')],
175                            product, os_architecture, deliverable_type,
176                            build_details, CB_RELEASE_REPO)
177            else:
178                if build_version[:5] in COUCHBASE_RELEASE_FROM_VERSION_3:
179                    arch_type = "amd64"
180                    if "x86_64" not in os_architecture:
181                        arch_type = "x86"
182                    build.url = "{5}{0}/{1}_{4}-windows_{2}.{3}"\
183                        .format(build_version, product, arch_type,
184                        deliverable_type, build_details[:5], CB_RELEASE_REPO)
185                else:
186                    build.url = "{5}{0}/{1}_{2}_{4}.setup.{3}"\
187                        .format(build_version, product, os_architecture,
188                        deliverable_type, build_details, CB_RELEASE_REPO)
189            build.url_latest_build = "{4}{0}_{1}_{3}.setup.{2}"\
190                             .format(product, os_architecture, deliverable_type,
191                                            build_details, CB_LATESTBUILDS_REPO)
192        else:
193            """ check match full version x.x.x-xxxx """
194            if not re.match(r'[1-9].[0-9].[0-9]$', build_version):
195                """  in release folder
196                        /3.0.1/couchbase-server-enterprise-3.0.1-centos6.x86_64.rpm
197                        /3.0.1/couchbase-server-enterprise_3.0.1-ubuntu12.04_amd64.deb
198                        /3.0.2/couchbase-server-enterprise-3.0.2-centos6.x86_64.rpm
199                      build release url:
200                               http://builds.hq.northscale.net/releases/3.0.1/
201                      build latestbuilds url:
202                               http://builds.hq.northscale.net/latestbuilds/
203                                  couchbase-server-enterprise_x86_64_3.0.1-1444.rpm
204                """
205                if build_version[:5] in COUCHBASE_RELEASE_FROM_VERSION_3:
206                    if "rpm" in deliverable_type:
207                        build.url = "{5}{0}/{1}-{4}-centos6.{2}.{3}"\
208                                .format(build_version[:build_version.find('-')],
209                                product, os_architecture, deliverable_type,
210                                        build_details[:5], CB_RELEASE_REPO)
211                    elif "deb" in deliverable_type:
212                        os_architecture = "amd64"
213                        os_name = "ubuntu12.04"
214                        if  "ubuntu 14.04" in os_version:
215                            os_name = "ubuntu14.04"
216                        elif "ubuntu 16.04" in os_version:
217                            os_name = "ubuntu16.04"
218                        build.url = "{6}{0}/{1}_{4}-{5}_{2}.{3}"\
219                                .format(build_version[:build_version.find('-')],
220                                 product, os_architecture, deliverable_type,
221                                 build_details[:5], os_name, CB_RELEASE_REPO)
222                else:
223                    if "2.5.2" in build_details[:5]:
224                        build.url = "{5}{0}/{1}_{4}_{2}.{3}"\
225                            .format(build_version[:build_version.find('-')],
226                            product, os_architecture, deliverable_type,
227                                    build_details[:5], CB_RELEASE_REPO)
228                    else:
229                        build.url = "{5}{0}/{1}_{2}_{4}.{3}"\
230                            .format(build_version[:build_version.find('-')],
231                            product, os_architecture, deliverable_type,
232                                        build_details, CB_RELEASE_REPO)
233            else:
234                if build_version[:5] in COUCHBASE_RELEASE_FROM_VERSION_3:
235                    if "rpm" in deliverable_type:
236                        build.url = "{5}{0}/{1}-{4}-centos6.{2}.{3}"\
237                            .format(build_version, product, os_architecture,
238                            deliverable_type, build_details[:5], CB_RELEASE_REPO)
239                    elif "deb" in deliverable_type:
240                        os_architecture = "amd64"
241                        os_name = "ubuntu12.04"
242                        if  "ubuntu 14.04" in os_version:
243                            os_name = "ubuntu14.04"
244                        elif "ubuntu 16.04" in os_version:
245                            os_name = "ubuntu16.04"
246                        build.url = "{6}{0}/{1}_{4}-{5}_{2}.{3}"\
247                            .format(build_version, product, os_architecture,
248                            deliverable_type, build_details[:5], os_name,
249                                                         CB_RELEASE_REPO)
250                        """ http://builds.hq.northscale.net/releases/3.0.1/
251                        couchbase-server-enterprise_3.0.1-ubuntu12.04_amd64.deb """
252                else:
253                    build.url = "{5}{0}/{1}_{2}_{4}.{3}"\
254                        .format(build_version, product, os_architecture,
255                        deliverable_type, build_details, CB_RELEASE_REPO)
256            build.url_latest_build = "{4}{0}_{1}_{3}.{2}"\
257                      .format(product, os_architecture, deliverable_type,
258                               build_details, CB_LATESTBUILDS_REPO)
259        # This points to the Internal s3 account to look for release builds
260        if is_amazon:
261            build.url = 'https://s3.amazonaws.com/packages.couchbase/releases/{0}/{1}_{2}_{0}.{3}'\
262                .format(build_version, product, os_architecture, deliverable_type)
263            build.url = build.url.replace("enterprise", "community")
264            build.name = build.name.replace("enterprise", "community")
265        return build
266
267    def find_couchbase_release_build(self, product, deliverable_type, os_architecture,
268                                    build_version, is_amazon=False, os_version="",
269                                    direct_build_url=None):
270        build_details = build_version
271        if build_version[:5] in COUCHBASE_VERSION_2_WITH_REL:
272            if build_version[-4:] != "-rel":
273                build_details = build_details + "-rel"
274        build = MembaseBuild()
275        build.deliverable_type = deliverable_type
276        build.time = '0'
277        build.size = '0'
278        build.product_version = build_version
279        build.architecture_type = os_architecture
280        build.product = product
281        os_name = ""
282        build.name = '{1}_{2}_{0}.{3}'.format(build_version, product,
283                                               os_architecture, deliverable_type)
284        build.build_number = 0
285        if deliverable_type == "exe":
286            """ /3.0.1/couchbase-server-enterprise_3.0.1-windows_amd64.exe """
287            if not re.match(r'[1-9].[0-9].[0-9]$', build_version):
288                if build_version[:5] in COUCHBASE_RELEASE_FROM_VERSION_3:
289                    arch_type = "amd64"
290                    if "x86_64" not in os_architecture:
291                        arch_type = "x86"
292                    build.url = "{5}{0}/{1}_{4}-windows_{2}.{3}"\
293                            .format(build_version[:build_version.find('-')],
294                            product, arch_type, deliverable_type, build_details[:5],
295                            CB_RELEASE_REPO)
296                else:
297                    if "2.5.2" in build_details[:5]:
298                        build.url = "{5}/{0}/{1}_{4}_{2}.setup.{3}"\
299                            .format(build_version[:build_version.find('-')],
300                            product, os_architecture, deliverable_type,
301                            build_details[:5], CB_RELEASE_REPO)
302                    else:
303                        build.url = "{5}{0}/{1}_{2}_{4}.setup.{3}"\
304                            .format(build_version[:build_version.find('-')],
305                            product, os_architecture, deliverable_type,
306                            build_details, CB_RELEASE_REPO)
307            else:
308                if build_version[:5] in COUCHBASE_RELEASE_FROM_VERSION_3:
309                    arch_type = "amd64"
310                    if "x86_64" not in os_architecture:
311                        arch_type = "x86"
312                    build.url = "{5}{0}/{1}_{4}-windows_{2}.{3}"\
313                        .format(build_version, product, arch_type,
314                         deliverable_type, build_details[:5], CB_RELEASE_REPO)
315                else:
316                    build.url = "{5}{0}/{1}_{2}_{4}.setup.{3}"\
317                        .format(build_version, product, os_architecture,
318                        deliverable_type, build_details, CB_RELEASE_REPO)
319            build.url_latest_build = "{4}{0}_{1}_{3}.setup.{2}"\
320                             .format(product, os_architecture,
321                             deliverable_type, build_details, CB_LATESTBUILDS_REPO)
322        elif deliverable_type == "msi":
323            if not re.match(r'[1-9].[0-9].[0-9]$', build_version):
324                if build_version[:5] in COUCHBASE_RELEASE_FROM_SPOCK:
325                    arch_type = "amd64"
326                    if "x86_64" not in os_architecture:
327                        arch_type = "x86"
328                    build.url = "{5}{0}/{1}_{4}-windows_{2}.{3}"\
329                            .format(build_version[:build_version.find('-')],
330                            product, arch_type, deliverable_type, build_details[:5],
331                            CB_RELEASE_REPO)
332            else:
333                if build_version[:5] in COUCHBASE_RELEASE_FROM_SPOCK:
334                    arch_type = "amd64"
335                    if "x86_64" not in os_architecture:
336                        arch_type = "x86"
337                    build.url = "{5}{0}/{1}_{4}-windows_{2}.{3}"\
338                        .format(build_version, product, arch_type,
339                         deliverable_type, build_details[:5], CB_RELEASE_REPO)
340        elif deliverable_type == "zip":
341            if not re.match(r'[1-9].[0-9].[0-9]$', build_version):
342                if build_version[:5] in COUCHBASE_RELEASE_FROM_VERSION_3:
343                    os_name = "macos"
344                    build.url = "{6}{0}/{1}_{4}-{5}_{2}.{3}"\
345                                .format(build_version[:build_version.find('-')],
346                                product, os_architecture, deliverable_type,
347                                build_details[:5],os_name, CB_RELEASE_REPO)
348        else:
349            """ check match full version x.x.x-xxxx """
350            if not re.match(r'[1-9].[0-9].[0-9]$', build_version):
351                """  in release folder
352                        /3.0.1/couchbase-server-enterprise-3.0.1-centos6.x86_64.rpm
353                        /3.0.1/couchbase-server-enterprise_3.0.1-ubuntu12.04_amd64.deb
354                        /3.0.2/couchbase-server-enterprise-3.0.2-centos6.x86_64.rpm
355                      build release url:
356                               http://builds.hq.northscale.net/releases/3.0.1/
357                      build latestbuilds url:
358                               http://builds.hq.northscale.net/latestbuilds/
359                                  couchbase-server-enterprise_x86_64_3.0.1-1444.rpm
360                """
361                if build_version[:5] in COUCHBASE_RELEASE_FROM_VERSION_3:
362                    if "rpm" in deliverable_type:
363                        if "centos" in os_version.lower():
364                            if "centos 7" in os_version.lower():
365                                os_name = "centos7"
366                            else:
367                                os_name = "centos6"
368                        elif "suse" in os_version.lower():
369                            if "11" in os_version.lower():
370                                os_name = "suse11"
371                            elif "12" in os_version.lower():
372                                os_name = "suse12"
373                        elif "oracle linux" in os_version.lower():
374                            os_name = "oel6"
375                        elif "amazon linux 2" in os_version.lower():
376                            if build_version[:5] in COUCHBASE_FROM_MAD_HATTER or \
377                                            build_version[:5] in COUCHBASE_FROM_601:
378                                os_name = "amzn2"
379                            else:
380                                self.fail("Amazon Linux 2 doesn't support version {0} "\
381                                                              .format(build_version[:5]))
382                        elif "red hat" in os_version.lower():
383                            if "8.0" in os_version.lower():
384                                os_name = "rhel8"
385                        else:
386                            os_name = "centos6"
387                        build.url = "{6}{0}/{1}-{4}-{5}.{2}.{3}"\
388                                .format(build_version[:build_version.find('-')],
389                                product, os_architecture, deliverable_type,
390                                build_details[:5],os_name, CB_RELEASE_REPO)
391                    elif "deb" in deliverable_type:
392                        os_architecture = "amd64"
393                        os_name = "ubuntu12.04"
394                        if  "ubuntu 14.04" in os_version.lower():
395                            os_name = "ubuntu14.04"
396                        elif "ubuntu 16.04" in os_version.lower():
397                            os_name = "ubuntu16.04"
398                        elif "ubuntu 18.04" in os_version.lower():
399                            if build_version[:5] in COUCHBASE_FROM_601:
400                                os_name = "ubuntu18.04"
401                            else:
402                                self.fail("ubuntu 18.04 doesn't support version %s "
403                                                                % build_version[:5])
404                        build.url = "{6}{0}/{1}_{4}-{5}_{2}.{3}"\
405                                .format(build_version[:build_version.find('-')],
406                                 product, os_architecture, deliverable_type,
407                                 build_details[:5], os_name, CB_RELEASE_REPO)
408                else:
409                    if "2.5.2" in build_details[:5]:
410                        if product == "moxi-server" and deliverable_type == "deb":
411                            build.url = "{5}{0}/{1}_{4}_{2}_openssl098.{3}".format(
412                                            build_version[:build_version.find('-')],
413                                            product,
414                                            os_architecture,
415                                            deliverable_type,
416                                            build_details[:5],
417                                            CB_RELEASE_REPO)
418                        else:
419                            build.url = "{5}{0}/{1}_{4}_{2}.{3}".format(
420                                            build_version[:build_version.find('-')],
421                                            product,
422                                            os_architecture,
423                                            deliverable_type,
424                                            build_details[:5],
425                                            CB_RELEASE_REPO)
426                    else:
427                        build.url = "{5}{0}/{1}_{2}_{4}.{3}"\
428                            .format(build_version[:build_version.find('-')],
429                            product, os_architecture, deliverable_type,
430                            build_details, CB_RELEASE_REPO)
431            else:
432                if build_version[:5] in COUCHBASE_RELEASE_FROM_VERSION_3:
433                    if "rpm" in deliverable_type:
434                        if "centos" in os_version.lower():
435                            if "centos 7" in os_version.lower():
436                                os_name = "centos7"
437                            else:
438                                os_name = "centos6"
439                        elif "suse" in os_version.lower():
440                            if "11" in os_version.lower():
441                                os_name = "suse11"
442                            elif "12" in os_version.lower():
443                                os_name = "suse12"
444                        elif "oracle linux" in os_version.lower():
445                            os_name = "oel6"
446                        elif "amazon linux 2" in os_version.lower():
447                            if build_version[:5] in COUCHBASE_FROM_MAD_HATTER or \
448                                            build_version[:5] in COUCHBASE_FROM_601:
449                                os_name = "amzn2"
450                            else:
451                                self.fail("Amazon Linux 2 doesn't support version %s "
452                                          % build_version[:5])
453                        else:
454                            os_name = "centos6"
455                        build.url = "{6}{0}/{1}-{4}-{5}.{2}.{3}"\
456                                .format(build_version[:build_version.find('-')],
457                                product, os_architecture, deliverable_type,
458                                build_details[:5],os_name, CB_RELEASE_REPO)
459                    elif "deb" in deliverable_type:
460                        os_architecture = "amd64"
461                        os_name = "ubuntu12.04"
462                        if  "ubuntu 14.04" in os_version.lower():
463                            os_name = "ubuntu14.04"
464                        elif "ubuntu 16.04" in os_version.lower():
465                            os_name = "ubuntu16.04"
466                        elif "ubuntu 18.04" in os_version.lower():
467                            if build_version[:5] in COUCHBASE_FROM_601:
468                                os_name = "ubuntu18.04"
469                            else:
470                                self.fail("ubuntu 18.04 doesn't support version %s "
471                                                                % build_version[:5])
472                        build.url = "{6}{0}/{1}_{4}-{5}_{2}.{3}"\
473                            .format(build_version, product, os_architecture,
474                            deliverable_type, build_details[:5], os_name,
475                            CB_RELEASE_REPO)
476                else:
477                    build.url = "{5}{0}/{1}_{2}_{4}.{3}".format(build_version,
478                                product, os_architecture, deliverable_type,
479                                build_details, CB_RELEASE_REPO)
480            build.url_latest_build = "{4}{0}_{1}_{3}.{2}".format(product,
481                        os_architecture, deliverable_type, build_details,
482                        CB_LATESTBUILDS_REPO)
483        # This points to the Internal s3 account to look for release builds
484        """ add ce folder in community version from 3.0.2 release """
485        if "community" in product and build_version[:5] not in CE_EE_ON_SAME_FOLDER:
486            build.url = build.url.replace("couchbase-server-community", \
487                                          "ce/couchbase-server-community")
488        if is_amazon:
489            """
490                for centos only
491                         https://s3.amazonaws.com/packages.couchbase.com/releases/
492                         4.0.0/couchbase-server-enterprise-4.0.0-centos6.x86_64.rpm """
493            build.url = "https://s3.amazonaws.com/packages.couchbase.com/releases/"\
494                        "{0}/{1}-{0}-centos6.{2}.{3}" \
495                        .format(build_version, product, os_architecture,
496                                                       deliverable_type)
497            build.url = build.url.replace("enterprise", "community")
498            build.name = build.name.replace("enterprise", "community")
499        if direct_build_url is not None and deliverable_type != "exe":
500            build.url = direct_build_url
501        return build
502
503    def sort_builds_by_version(self, builds):
504        membase_builds = list()
505        for build in builds:
506            if build.product == 'membase-server-enterprise':
507                membase_builds.append(build)
508
509        return sorted(membase_builds,
510                      key=lambda membase_build: membase_build.build_number, reverse=True)
511
512    def sort_builds_by_time(self, builds):
513        membase_builds = list()
514        for build in builds:
515            if build.product == 'membase-server-enterprise':
516                membase_builds.append(build)
517
518        return sorted(membase_builds,
519                      key=lambda membase_build: membase_build.time, reverse=True)
520
521
522    def get_latest_builds(self):
523        return self._get_and_parse_builds('http://builds.hq.northscale.net/latestbuilds')
524
525    def get_sustaining_latest_builds(self):
526        return self._get_and_parse_builds('http://builds.hq.northscale.net/latestbuilds/sustaining')
527
528    def get_all_builds(self, version=None, timeout=None, direct_build_url=None, deliverable_type=None, \
529                       architecture_type=None,edition_type=None, repo=None, toy="", \
530                       distribution_version=None, distribution_type=""):
531        try:
532            latestbuilds, latestchanges = \
533                self._get_and_parse_builds('http://builds.hq.northscale.net/latestbuilds', version=version, \
534                                           timeout=timeout, direct_build_url=direct_build_url, \
535                                           deliverable_type=deliverable_type, architecture_type=architecture_type, \
536                                           edition_type=edition_type,repo=repo, toy=toy, \
537                                           distribution_version=distribution_version, \
538                                           distribution_type=distribution_type)
539        except Exception as e:
540            latestbuilds, latestchanges = \
541                self._get_and_parse_builds('http://packages.northscale.com.s3.amazonaws.com/latestbuilds', \
542                                           version=version, timeout=timeout, direct_build_url=direct_build_url)
543
544        return latestbuilds, latestchanges
545
546
547    #baseurl = 'http://builds.hq.northscale.net/latestbuilds/'
548    def _get_and_parse_builds(self, build_page, version=None, timeout=None, direct_build_url=None, \
549                              deliverable_type=None, architecture_type=None, edition_type=None, \
550                              repo=None, toy="", distribution_version=None, distribution_type=""):
551        builds = []
552        changes = []
553        if direct_build_url is not None and direct_build_url != "":
554            query = BuildQuery()
555            build = query.create_build_info_from_direct_url(direct_build_url)
556            return build, changes
557        elif repo is not None and edition_type is not None and \
558             architecture_type is not None and deliverable_type is not None:
559            query = BuildQuery()
560            build = query.create_build_url(version, deliverable_type, architecture_type, \
561                                           edition_type, repo, toy, distribution_version, \
562                                           distribution_type)
563            return build, changes
564        else:
565            page = None
566            soup = None
567            index_url = '/index.html'
568            if version:
569                if version.find("-") != -1:
570                    index_url = "/index_" + version[:version.find("-")] + ".html"
571                else:
572                    index_url = "/index_" + version + ".html"
573            #try this ten times
574            for _ in range(0, 10):
575                try:
576                    self.log.info("Try collecting build information from url: %s" % (build_page + index_url))
577                    if timeout:
578                        socket.setdefaulttimeout(timeout)
579                    page = urllib2.urlopen(build_page + index_url)
580                    soup = BeautifulSoup.BeautifulSoup(page)
581                    break
582                except:
583                    time.sleep(5)
584            if not page:
585                raise Exception('unable to connect to %s' % (build_page + index_url))
586            query = BuildQuery()
587            for incident in soup('li'):
588                contents = incident.contents
589                build_id = ''
590                build_description = ''
591                for content in contents:
592                    if BeautifulSoup.isString(content):
593                        build_description = content.string
594                    elif content.name == 'a':
595                        build_id = content.string.string
596                try:
597                    if build_id.lower().startswith('changes'):
598                        change = query.create_change_info(build_id, build_description)
599                        change.url = '%s/%s' % (build_page, build_id)
600                        changes.append(change)
601                    else:
602                        build = query.create_build_info(build_id, build_description)
603                        build.url = '%s/%s' % (build_page, build_id)
604                        builds.append(build)
605                except Exception as e:
606                    print "ERROR in creating build/change info for: Build_id: %s , Build_Description: %s" % (build_id, build_description)
607                    print traceback.print_exc(file=sys.stderr)
608                    #raise e : Skipping parsing for this build information,
609                    #Eventually, It will fail with build not found error at install.py:240
610            for build in builds:
611                for change in changes:
612                    if change.build_number == build.product_version:
613                        build.change = change
614                        """ print 'change : ', change.url,change.build_number """
615                        break
616            return builds, changes
617
618    def create_build_info_from_direct_url(self, direct_build_url):
619        if direct_build_url is not None and direct_build_url != "":
620            build = MembaseBuild()
621            build.url = direct_build_url
622            build.toy = ""
623            build_info = direct_build_url.split("/")
624            build_info = build_info[len(build_info)-1]
625            """ windows build name: couchbase_server-enterprise-windows-amd64-3.0.0-892.exe
626                                    couchbase-server-enterprise_3.5.0-952-windows_amd64.exe """
627            build.name = build_info
628            deliverable_type = ["exe", "msi", "rpm", "deb", "zip"]
629            if build_info[-3:] in deliverable_type:
630                build.deliverable_type = build_info[-3:]
631                build_info = build_info[:-4]
632            else:
633                raise Exception('Check your url. Deliverable type %s does not support yet' \
634                                 % (direct_build_url[-3:]))
635            """ build name at this location couchbase-server-enterprise_x86_64_3.0.0-797-rel
636                windows build name: couchbase_server-enterprise-windows-amd64-3.0.0-892 """
637
638            """ Remove the code below when cb name is standardlized (MB-11372) """
639            if "windows" in direct_build_url and build.deliverable_type == "exe" \
640                and build_info not in SHERLOCK_VERSION:
641                build_info = build_info.replace("-windows-amd64-","_x86_64_")
642                build_info = build_info.replace("couchbase_server","couchbase-server")
643            """ End remove here """
644
645            """ sherlock build name
646                centos 6: couchbase-server-enterprise-3.5.0-71-centos6.x86_64
647                debian7:  couchbase-server-enterprise_3.5.0-10-debian7_amd64.deb
648                debian8:  couchbase-server-enterprise_4.5.0-1194-debian8_amd64.deb
649                ubuntu 12.04:
650                    couchbase-server-enterprise_3.5.0-723-ubuntu12.04_amd64.deb
651                mac:
652                    couchbase-server-enterprise_3.5.0-1120-macos_x86_64.zip
653                windows:
654                    couchbase_server-enterprise-windows-amd64-3.5.0-926.exe
655                    couchbase-server-enterprise_3.5.0-952-windows_amd64.exe"""
656
657            if any( x + "-" in build_info for x in COUCHBASE_FROM_VERSION_3):
658                deb_words = ["debian7", "debian8", "ubuntu12.04", "ubuntu14.04",
659                             "ubuntu16.04", "ubuntu18.04", "windows", "macos"]
660                if "centos" not in build_info and "suse" not in build_info and \
661                   "rhel8" not in build_info:
662                    tmp_str = build_info.split("_")
663                    product_version = tmp_str[1].split("-")
664                    product_version = "-".join([i for i in product_version \
665                                                 if i not in deb_words])
666                else:
667                    product_version = build_info.split("-")
668                    product_version = product_version[3] + "-" + product_version[4]
669                if product_version[:5] in testconstants.COUCHBASE_VERSIONS:
670                    build.product_version = product_version
671                    if "centos" not in build_info and "suse" not in build_info and \
672                       "rhel8" not in build_info:
673                        build_info = build_info.replace("_" + product_version,"")
674                    else:
675                        build_info = build_info.replace("-" + product_version,"")
676                if "x86_64" in build_info:
677                    build.architecture_type = "x86_64"
678                    if "centos" in build_info or "suse" in build_info or \
679                       "rhel8" in build_info:
680                        build_info = build_info.replace(".x86_64", "")
681                    elif "macos" in build_info:
682                        build_info = build_info.replace("_x86_64", "")
683                elif "x86" in build_info:
684                    build.architecture_type = "x86"
685                    build_info = build_info.replace(".x86", "")
686                elif "_amd64" in build_info:
687                    build.architecture_type = "x86_64"
688                    build_info = build_info.replace("_amd64", "")
689                elif "-amd64" in build_info:
690                    build.architecture_type = "x86_64"
691                    build_info = build_info.replace("-amd64", "")
692                del_words = ["centos6", "debian7", "debian8", "debian9",
693                             "ubuntu12.04", "ubuntu14.04", "ubuntu16.04", "ubuntu18.04",
694                             "windows", "macos", "centos7", "suse11", "suse12", "amzn2",
695                             "rhel8"]
696                if build_info.startswith("couchbase-server"):
697                    build.product = build_info.split("-")
698                    build.product = "-".join([i for i in build.product \
699                                                 if i not in del_words])
700                return build
701            product_version = build_info.split("_")
702            product_version = product_version[len(product_version)-1]
703            if product_version[:5] in testconstants.COUCHBASE_VERSIONS:
704                build.product_version = product_version
705                build_info = build_info.replace("_" + product_version,"")
706            else:
707                raise Exception("Check your url. Couchbase server does not have "
708                                       "version %s yet " % (product_version[:5]))
709
710            if "x86_64" in build_info:
711                build.architecture_type = "x86_64"
712                build_info = build_info.replace("_x86_64", "")
713            elif "x86" in build_info:
714                build.architecture_type = "x86"
715                build_info = build_info.replace("_x86", "")
716
717            if build_info.startswith("couchbase-server"):
718                build.product = build_info
719            else:
720                self.fail("unknown server name")
721            return build
722
723    def create_build_url(self, version, deliverable_type, architecture_type,
724                              edition_type, repo, toy, distribution_version,
725                                                         distribution_type):
726        build = MembaseBuild()
727        """
728        version: 3.0.0-xx or 3.0.0-xx-rel
729        deliverable_type: deb
730        distribution_version: ubuntu12 or debian7
731        architecture_type: x86_64
732        edition_type: couchbase-server-enterprise or couchbase-server-community
733        repo: http://builds.hq.northscale.net/latestbuilds/
734        sherlock repo: http://latestbuilds.hq.couchbase.com/couchbase-server/sherlock
735        sherlock build name with extra build number:
736               /684/couchbase-server-enterprise-3.5.0-684-centos6.x86_64.rpm
737               /1454/couchbase-server-enterprise-4.0.0-1454-centos6.x86_64.rpm
738               /1796/couchbase-server-enterprise-4.0.0-1796-oel6.x86_64.rpm
739               /723/couchbase-server-enterprise_3.5.0-723-ubuntu12.04_amd64.deb
740               /723/couchbase-server-enterprise_3.5.0-732-debian7_amd64.deb
741               /1194/couchbase-server-enterprise_4.5.0-1194-debian8_amd64.deb
742               /1120/couchbase-server-enterprise_3.5.0-1120-macos_x86_64.zip
743        toy=Ce
744        build.name = couchbase-server-enterprise_x86_64_3.0.0-xx-rel.deb
745        build.url = http://builds.hq.northscale.net/latestbuilds/
746                              couchbase-server-enterprise_x86_64_3.0.0-xx-rel.deb
747        For toy build: name  =
748            couchbase-server-community_cent58-3.0.0-toy-toyName-x86_64_3.0.0-xx-toy.rpm
749            http://latestbuilds.hq.couchbase.com/couchbase-server/
750                toy-wied/14/couchbase-server-enterprise-1004.0.0-14-centos6.x86_64.rpm
751                toy-nimish/16/couchbase-server-enterprise_1003.5.0-16-windows_amd64.exe
752        For windows build diff - and _ compare to unix build
753                       name = couchbase_server-enterprise-windows-amd64-3.0.0-998.exe
754                              couchbase_server-enterprise-windows-amd64-3.0.2-1603.exe
755                              couchbase_server-enterprise-windows-amd64-3.0.3-1716.exe
756                              couchbase-server-enterprise_3.5.0-952-windows_amd64.exe
757                              couchbase-server-enterprise_3.5.0-1390-windows_x86.exe
758            From build 5.0.0-2924, we don't make any exe build.
759            It will be all in msi
760        """
761        build.toy = "toy-" + toy
762        build.deliverable_type = deliverable_type
763        build.architecture_type = architecture_type
764        build.distribution_version = distribution_version
765        build.distribution_type = distribution_type
766
767        os_name = ""
768        setup = ""
769        build_number = ""
770
771        unix_deliverable_type = ["deb", "rpm", "zip"]
772        if deliverable_type in unix_deliverable_type:
773            if toy == "" and version[:5] not in COUCHBASE_VERSION_2 and \
774                                   version[:5] not in COUCHBASE_VERSION_3:
775                if "rel" not in version and toy == "":
776                    build.product_version = version
777                elif "-rel" in version:
778                    build.product_version = version.replace("-rel", "")
779            elif toy != "":
780                build.product_version = version
781            else:
782                if "rel" not in version and toy == "":
783                    build.product_version = version + "-rel"
784                else:
785                    build.product_version = version
786        if deliverable_type in ["exe", "msi"]:
787            if version[:5] in COUCHBASE_VERSION_2:
788                setup = "setup."
789            else:
790                os_name= "windows-"
791            if "rel" in version and version[:5] not in COUCHBASE_VERSION_2:
792                build.product_version = version.replace("-rel", "")
793            elif "rel" not in version and version[:5] in COUCHBASE_VERSION_2:
794                build.product_version = version + "-rel"
795            else:
796                build.product_version = version
797            if "couchbase-server" in edition_type and version[:5] in WIN_CB_VERSION_3:
798                edition_type = edition_type.replace("couchbase-", "couchbase_")
799            if version[:5] not in COUCHBASE_VERSION_2:
800                if "x86_64" in architecture_type:
801                    build.architecture_type = "amd64"
802                elif "x86" in architecture_type:
803                    build.architecture_type = "x86"
804            """
805                    In spock from build 2924 and later release, we only support
806                    msi installation method on windows
807            """
808            if "-" in version and version.split("-")[0] in COUCHBASE_FROM_SPOCK:
809                deliverable_type = "msi"
810
811        if "deb" in deliverable_type and "centos6" in edition_type:
812            edition_type = edition_type.replace("centos6", "ubuntu_1204")
813        if "debian" in distribution_version:
814            os_name = "debian7_"
815        joint_char = "_"
816        version_join_char = "_"
817        if toy is not "":
818            joint_char = "-"
819        if "exe" in deliverable_type and version[:5] not in COUCHBASE_VERSION_2:
820            joint_char = "-"
821            version_join_char = "-"
822        if toy == "" and version[:5] not in COUCHBASE_VERSION_2 and \
823                                   version[:5] not in COUCHBASE_VERSION_3:
824            """ format for sherlock build name
825            /684/couchbase-server-enterprise-3.5.0-684-centos6.x86_64.rpm
826            /1154/couchbase-server-enterprise-3.5.0-1154-centos7.x86_64.rpm
827            /1454/couchbase-server-enterprise-4.0.0-1454-centos6.x86_64.rpm
828            /1796/couchbase-server-enterprise-4.0.0-1796-oel6.x86_64.rpm
829            /723/couchbase-server-enterprise_3.5.0-723-ubuntu12.04_amd64.deb
830            /723/couchbase-server-enterprise_3.5.0-732-debian7_amd64.deb
831            /795/couchbase_server-enterprise-windows-amd64-3.5.0-795.exe
832            /952/couchbase-server-enterprise_3.5.0-952-windows_amd64.exe
833            /1390/couchbase-server-enterprise_3.5.0-1390-windows_x86.exe
834            /1120/couchbase-server-enterprise_3.5.0-1120-macos_x86_64.zip"""
835            build_number = build.product_version.replace(version[:6],"")
836            """ distribution version:    centos linux release 7.0.1406 (core)
837                distribution version:    centos release 6.5 (final)  """
838            rpm_version = "centos6"
839
840            if "centos" in distribution_version or "red hat" in distribution_version or \
841               "rhel" in distribution_version:
842                if "centos 7" in distribution_version:
843                    rpm_version = "centos7"
844                elif "red hat enterprise linux server release 6" in distribution_version:
845                    rpm_version = "centos6"
846                elif "red hat enterprise linux server release 7" in distribution_version:
847                    rpm_version = "centos7"
848                elif "rhel8" in distribution_version:
849                    rpm_version = "rhel8"
850                build.name = edition_type + "-" + build.product_version + \
851                   "-" + rpm_version + "." + build.architecture_type + \
852                   "." + build.deliverable_type
853            elif "suse" in distribution_version:
854                if "suse 12" in distribution_version:
855                    if version[:5] in COUCHBASE_FROM_SPOCK:
856                        suse_version="suse12"
857                        build.distribution_version = "suse12"
858                    else:
859                        self.fail("suse 12 does not support on this version %s "
860                                                                  % version[:5])
861                else:
862                    suse_version="suse11"
863                    build.distribution_version = "suse11"
864                build.name = edition_type + "-" + build.product_version + \
865                   "-" + suse_version + "." + build.architecture_type + \
866                   "." + build.deliverable_type
867            elif "oracle linux" in distribution_version:
868                build.distribution_version = "oracle linux"
869                os_name = "oel6"
870                build.name = edition_type + "-" + build.product_version + \
871                   "-" + os_name + "." + build.architecture_type + \
872                   "." + build.deliverable_type
873            elif "amazon linux release 2" in distribution_version:
874                if version[:5] in COUCHBASE_FROM_MAD_HATTER or \
875                                version[:5] in COUCHBASE_FROM_601:
876                    build.distribution_version = "amazon linux 2"
877                    os_name = "amzn2"
878                    build.name = edition_type + "-" + build.product_version + \
879                                 "-" + os_name + "." + build.architecture_type + \
880                                 "." + build.deliverable_type
881                else:
882                    self.fail("Amazon Linux 2 doesn't support version %s "
883                              % version[:5])
884            else:
885                os_name = ""
886                joint_char = "-"
887
888                """ sherlock build in unix only support 64-bit """
889                build.architecture_type = "amd64"
890                if  "ubuntu 12.04" in distribution_version:
891                    os_name = "ubuntu12.04"
892                elif "ubuntu 14.04" in distribution_version:
893                    os_name = "ubuntu14.04"
894                elif "ubuntu 16.04" in distribution_version:
895                    os_name = "ubuntu16.04"
896                elif "ubuntu 18.04" in distribution_version.lower():
897                    if version[:5] in COUCHBASE_FROM_MAD_HATTER or \
898                        version[:5] in COUCHBASE_FROM_601:
899                        os_name = "ubuntu18.04"
900                    else:
901                        self.fail("ubuntu 18.04 doesn't support version %s "
902                                                              % version[:5])
903                elif "debian gnu/linux 7" in distribution_version:
904                    build.distribution_version = "debian7"
905                    os_name = "debian7"
906                elif "debian gnu/linux 8" in distribution_version:
907                    build.distribution_version = "debian8"
908                    os_name = "debian8"
909                elif "debian gnu/linux 9" in distribution_version:
910                    build.distribution_version = "debian9"
911                    os_name = "debian9"
912                elif "windows" in distribution_version:
913                    os_name = "windows"
914                    if "x86_64" not in architecture_type:
915                        build.architecture_type = "x86"
916                elif "mac" in distribution_type:
917                    os_name = "macos"
918                    build.architecture_type = "x86_64"
919                build.name = edition_type + "_" + build.product_version + \
920                   joint_char + os_name + "_" +  build.architecture_type + \
921                   "." + build.deliverable_type
922            build.url = repo + build_number + "/" + build.name
923        elif toy is not "":
924            centos_version = "centos6"
925            build_info = version.split("-")
926            build_number = build_info[1]
927            if "centos" in distribution_version:
928                build.name = edition_type + "-" + build.product_version + \
929                   "-" + centos_version + "." + build.architecture_type + \
930                   "." + build.deliverable_type
931            build.url = repo + build.toy + "/" +build_number \
932                        + "/" + build.name
933        elif version[:3] == "3.1":
934            os_name = ""
935            if "suse" in distribution_version:
936                build.distribution_version = "suse11"
937                os_name = "suse11_"
938            elif "centos release 6" in distribution_version:
939                build.distribution_version = "centos6"
940                os_name = "centos6_"
941            elif  "ubuntu 12.04" in distribution_version:
942                os_name = "ubuntu_1204_"
943            elif "debian gnu/linux 7" in distribution_version:
944                build.distribution_version = "debian7"
945                os_name = "debian7_"
946            elif "debian gnu/linux 8" in distribution_version:
947                build.distribution_version = "debian8"
948                os_name = "debian8_"
949            elif "windows" in distribution_version:
950                os_name = "windows-"
951                if "x86_64" not in architecture_type:
952                    build.architecture_type = "x86"
953            elif "mac" in distribution_type:
954                build.architecture_type = "x86_64"
955            build.name = edition_type + joint_char + os_name + \
956                build.architecture_type +  version_join_char + \
957                build.product_version + "." + setup + build.deliverable_type
958            build.url = repo + build.name
959        else:
960            build.name = edition_type + joint_char + os_name + \
961                build.architecture_type +  version_join_char + \
962                build.product_version + "." + setup + build.deliverable_type
963            build.url = repo + build.name
964
965
966        """ reset build.architecture back to x86_64 in windows """
967        build.architecture_type = architecture_type
968        return build
969
970    def create_build_info(self, build_id, build_decription):
971        build = MembaseBuild()
972        build.deliverable_type = self._product_deliverable_type(build_id)
973        build.time = self._product_time(build_decription)
974        build.size = self._product_size(build_decription)
975        build.product_version = self._product_version(build_id)
976        build.architecture_type = self._product_arch_type(build_id)
977        build.product = self._product_name(build_id)
978        build.name = build_id
979        build.build_number = self._build_number(build)
980        build.toy = self._product_toy(build_id)
981        return build
982
983    def create_change_info(self, build_id, build_decription):
984        change = MembaseChange()
985        change.name = build_id.strip()
986        change.build_number = self._change_build_number(build_id)
987        change.time = self._change_time(build_decription)
988        return change
989
990
991    def _product_name(self, build_id):
992        list = build_id.split('_')
993        if "centos6" in build_id:
994            # return couchbase-server-ent/com_centos6
995            return "_".join(list[:2])
996        elif "ubuntu_1204" in build_id:
997            # return couchbase-server-ent/com_ubuntu_1204
998            return "_".join(list[:3])
999        # this should be done w/ more generic rule for toy-split
1000        elif "cent54" in build_id:
1001            list = build_id.split("-toy")
1002            return list[0]
1003        else:
1004            return list[0]
1005        #the first one is the product
1006
1007    def _product_arch_type(self, build_id):
1008        list = build_id.split('_')
1009        if '64' in build_id.split('_') or build_id.find('x86_64') != -1:
1010            return 'x86_64'
1011        elif 'x86' in build_id.split('_'):
1012            return 'x86'
1013        return ''
1014
1015
1016    def _product_toy(self, build_id):
1017        r = re.search("[^_]+-toy-([\w-]*)-x86", build_id)
1018        if r:
1019            return r.group(1)
1020        return ''
1021
1022    def _change_time(self, build_description):
1023        list = build_description.split('/')
1024        timestamp = list[1].strip()
1025        timestamp = timestamp[:timestamp.index(')')]
1026        return datetime.strptime(timestamp, '%a %b %d %H:%M:%S %Y')
1027
1028    def _change_build_number(self, build_id):
1029        list = build_id.split('_')
1030        #get list[1] . get rid of .txt
1031        build_number = list[1].strip()
1032        if re.search('.txt', build_number):
1033            build_number = build_number[:build_number.index('.txt')]
1034            return build_number
1035
1036    def _build_number(self, build):
1037        #get the first - and then the first - after that
1038        first_dash = build.product_version.find('-')
1039        if first_dash != -1:
1040            second_dash = build.product_version.find('-', first_dash + 1)
1041            if second_dash != -1:
1042                try:
1043                    return int(build.product_version[first_dash + 1:second_dash])
1044                except Exception:
1045                    return -1
1046        return -1
1047
1048    def _product_version(self, build_id):
1049        list = build_id.split('_')
1050        version_item = ''
1051        for item in list:
1052            if re.match(r'[0-2].[0-9].[0-9]-[0-9]+-rel', item):
1053                version_item = item
1054                if list[-1].endswith('xml'):
1055                    break
1056                return version_item
1057        if version_item == '':
1058            for item in list:
1059                if item.endswith('.setup.exe') or item.endswith('rpm') or\
1060                   item.endswith('deb') or item.endswith('tar.gz') or item.endswith('zip'):
1061                    version_item = item
1062                    break
1063        if version_item != '':
1064            if version_item.endswith('.setup.exe'):
1065                return version_item[:version_item.index('.setup.exe')]
1066            elif version_item.endswith('.tar.gz'):
1067                return version_item[:version_item.index('.tar.gz')]
1068            elif version_item.endswith('.deb'):
1069                return version_item[:version_item.index('.deb')]
1070            elif version_item.endswith('.rpm'):
1071                return version_item[:version_item.index('.rpm')]
1072            elif version_item.endswith('.zip'):
1073                return version_item[:version_item.index('.zip')]
1074        return ''
1075
1076    def _product_deliverable_type(self, build_id=''):
1077        list = build_id.split('_')
1078        version_item = ''
1079        for item in list:
1080            if item.endswith('.setup.exe') or item.endswith('rpm') or\
1081               item.endswith('deb') or item.endswith('tar.gz') or item.endswith('zip'):
1082                version_item = item
1083                break
1084        if version_item != '':
1085            if version_item.endswith('.setup.exe'):
1086                return 'exe'
1087            elif version_item.endswith('.tar.gz'):
1088                return 'tar.gz'
1089            elif version_item.endswith('.deb'):
1090                return 'deb'
1091            elif version_item.endswith('.rpm'):
1092                return 'rpm'
1093            elif version_item.endswith('.zip'):
1094                return 'zip'
1095        return ''
1096
1097    def _product_time(self, build_description):
1098        list = build_description.split('/')
1099        timestamp = list[1].strip()
1100        timestamp = timestamp[:timestamp.index(')')]
1101        return datetime.strptime(timestamp, '%a %b %d %H:%M:%S %Y')
1102
1103    def _product_size(self, build_description):
1104        list = build_description.split('/')
1105        filesize = list[0]
1106        filesize = filesize[filesize.index('(') + 1:]
1107        return filesize.strip()
1108
1109#q = BuildQuery()
1110#builds, changes = q.get_latest_builds()
1111#for build in builds:
1112#    print build.product,' ',build.time ,' ',build.deliverable_type,' ',build.product_version ,'',build.size,'',build.architecture_type
1113#    if build.change:
1114#        change = build.change
1115#        print change.name,change.build_number,change.time,change.url
1116
1117#for change in changes:
1118#    print change.name,change.build_number,change.time
1119
1120#builds = q.get_membase_latest_builds()
1121#for build in builds:
1122#    print build.product,' ',build.time ,' ',build.deliverable_type,' ',build.product_version ,'',build.size,'',build.architecture_type
1123
1124