Esempio n. 1
0
def details(request):
    logger = logging.getLogger('dashboard')
    artifacts = list()
    version = request.GET.get('version')
    license = request.GET.get('license') or 'community'
    os = request.GET.get('os')
    #read all builds from couchbase server
    couchbase = CbClient("localhost", 8091, "Administrator", "password")
    logger.error("connected to couchbase")
    allbuilds = couchbase.query(bucket='default',
                                ddoc='builds',
                                view='metadata',
                                limit=20000)
    #logger.error(allbuilds["rows"])
    #populate builds
    #  emit(doc.name, [doc.name,doc.url,doc.fullversion,doc.arch,doc.version]);
    for item in allbuilds["rows"]:
        value = item["value"]
        if value["fullversion"].find("toy") >= 0:
            continue
        value['buildnumber'] = value["fullversion"][
            value["fullversion"].find("-") + 1:value["fullversion"].rfind("-")]
        license_match = value["name"].find(license) > 0
        logger.error("license_match %s for %s" %
                     (license_match, value["name"]))
        arch_display_name = ''
        if value["arch"] == "x86_64":
            arch_display_name = "64-bit"
        else:
            arch_display_name = "32-bit"
        if version == value["version"] and os == value[
                "os"] and license_match is True:
            artifact_item = {
                "name": value["name"],
                "url": value["url"],
                "fullversion": value["fullversion"],
                "arch": arch_display_name,
                "buildnumber": int(value['buildnumber']),
                "os": value["os"]
            }
            #get the manifest if it exists ?
            artifact_item["manifest"] = manifest_for_build(
                value["fullversion"]) or "not fond"
            artifacts.append(artifact_item)

    couchbase.close()
    os_display_name = ''
    if os == 'rpm':
        os_display_name = 'Centos'
    elif os == 'deb':
        os_display_name = 'Ubuntu'
    elif os == 'windows':
        os_display_name = 'Windows'
    title = "%s builds ( 32-bit and 64-bit) %s edition" % (os_display_name,
                                                           license)
    artifacts = DataHelper.multikeysort(artifacts, ['buildnumber'])
    return render_to_response('../templates/dashboard/details.html', {
        'title': title,
        'data': artifacts
    })
def manifest(request):
    logger = logging.getLogger('dashboard')
    package_type = request.GET.get('package_type')
    fullversion = request.GET.get('fullversion')
    couchbase = CbClient("localhost", 8091, "Administrator", "password")
    manifests = couchbase.query(bucket='default', ddoc='builds', view='manifests', limit=20000,
        params={"startkey":"\"1.8.1-901-rel\""})

    descriptions = {}
    for item in manifests["rows"]:
        logger.error(package_type)
        value = item["value"]
        logger.error(value)
        if value["name"].find(package_type) >= 0:
            url = value["url"]
            logger.error("downloading manifest from url %s" % (url))
            content = _download(url)
            logger.error(content)
            to_json = _to_json(content, fullversion)
            logger.error(to_json)
            descriptions = _get_commits_description(to_json)
            logger.error(descriptions)
            id = value["name"]
            value
            break
            #convert to json
            #for each project get the git description
            #jsonbuild
    # update database....
    return render_to_response('templates/dashboard/manifest.html',
            {'title': 'manifests', 'data': descriptions})
def gitx(request):
    '''
        get all commits for this project
        for top 20 , do view call to find out the builds
    '''
    logger = logging.getLogger('dashboard')
    project = request.GET.get('project')
    limit = request.GET.get('limit')
    couchbase = CouchbaseClient("http://localhost:8091/pools/default", "default", "")
    cbclient= CbClient("localhost", 8091, "Administrator", "password")
    a,b,value = couchbase.get(project.encode('ascii','ignore'))
    commits = json.loads(value)["tree"]
    counter = 0
    data = list()
    for commit in commits:
        commit["builds"]=[]
        counter = counter + 1
        filter_value = "\"%s-%s\"" % (project, commit["revision"])
        params={"startkey":filter_value,"endkey":filter_value}
        qr = cbclient.query(bucket='default', ddoc='builds', view='commits', limit=100,params=params)
        for item in qr["rows"]:
            logger.error(commit["builds"])
            fullversion = item["value"][1].encode('ascii','ignore')
            if fullversion not in commit["builds"]:
                commit["builds"].append(fullversion)
        data.append(commit)
        end_index = commit["message"].find("\n") or len(commit["message"] - 1)
        commit["message"] = commit["message"][0:end_index]
        if counter == limit:
            break

    return render_to_response('../templates/dashboard/commits.html',
                          {'title': 'commits', 'data': data})
def manifest_for_build(buildnumber):
    logger = logging.getLogger('manifest_for_build')
    couchbase = CbClient("localhost", 8091, "Administrator", "password")
    manifests = manifests = couchbase.query(bucket='default', ddoc='builds', view='manifests', limit=20000,
        params={"startkey": "\"" + buildnumber + "\""})
    result = []
    for item in manifests["rows"]:
        result.append(item["value"])
    return result
 def read(self, request, build_id):
     couchbase = CbClient("localhost", 8091, "Administrator", "password")
     response = []
     allbuilds = couchbase.query(bucket='default', ddoc='builds',
         view='metadata', limit=200, params={"startkey": "\"%s\"" % (build_id)})
     for item in allbuilds["rows"]:
         row = item["value"]
         response.append(row)
     couchbase.close()
     return response
Esempio n. 6
0
def manifest_for_build(buildnumber):
    logger = logging.getLogger('manifest_for_build')
    couchbase = CbClient("localhost", 8091, "Administrator", "password")
    manifests = manifests = couchbase.query(
        bucket='default',
        ddoc='builds',
        view='manifests',
        limit=20000,
        params={"startkey": "\"" + buildnumber + "\""})
    result = []
    for item in manifests["rows"]:
        result.append(item["value"])
    return result
def populate_all_manifests(request):
    logger = logging.getLogger('dashboard')
    couchbase = CouchbaseClient("http://localhost:8091/pools/default", "default", "")
    cbclient= CbClient("localhost", 8091, "Administrator", "password")
    qr = cbclient.query(bucket='default', ddoc='builds', view='manifests', limit=20000)
    for item in qr["rows"]:
        doc = item["value"]
        if doc["name"].find("-manifest.xml") == -1:
            #        if doc["name"].find("-manifest.xml") == -1 and 'commits' not in doc:
            manifest_commits = ManifestPopulate(doc, doc["url"]).json()
            doc['commits'] = manifest_commits
            couchbase.set(doc['name'].encode('ascii','ignore'), 0, 0,
                          json.dumps(doc).encode('ascii','ignore'))
            logger.info("retreived git commits for %s" % (doc['name']))
    return render_to_response('../templates/dashboard/empty.html')
def details(request):
    logger = logging.getLogger('dashboard')
    artifacts = list()
    version = request.GET.get('version')
    license = request.GET.get('license') or 'community'
    os = request.GET.get('os')
    #read all builds from couchbase server
    couchbase = CbClient("localhost", 8091, "Administrator", "password")
    logger.error("connected to couchbase")
    allbuilds = couchbase.query(bucket='default', ddoc='builds', view='metadata', limit=20000)
    #logger.error(allbuilds["rows"])
    #populate builds
    #  emit(doc.name, [doc.name,doc.url,doc.fullversion,doc.arch,doc.version]);
    for item in allbuilds["rows"]:
        value = item["value"]
        if value["fullversion"].find("toy") >= 0:
            continue
        value['buildnumber'] = value["fullversion"][value["fullversion"].find("-")+1:value["fullversion"].rfind("-")]
        license_match = value["name"].find(license) > 0
        logger.error("license_match %s for %s" % (license_match, value["name"]))
        arch_display_name = ''
        if value["arch"] == "x86_64":
            arch_display_name = "64-bit"
        else:
	        arch_display_name = "32-bit"
        if version == value["version"] and os == value["os"] and license_match is True:
            artifact_item = {"name": value["name"],"url": value["url"], 
                             "fullversion": value["fullversion"],"arch": arch_display_name, 
                             "buildnumber": int(value['buildnumber']),"os": value["os"]}
            #get the manifest if it exists ?
            artifact_item["manifest"] = manifest_for_build(value["fullversion"]) or "not fond"
            artifacts.append(artifact_item)

    couchbase.close()
    os_display_name = ''
    if os == 'rpm':
        os_display_name = 'Centos'
    elif os == 'deb':
        os_display_name = 'Ubuntu'
    elif os == 'windows':
        os_display_name = 'Windows'
    title = "%s builds ( 32-bit and 64-bit) %s edition" % (os_display_name, license)
    artifacts = DataHelper.multikeysort(artifacts, ['buildnumber'])
    return render_to_response('../templates/dashboard/details.html',
            {'title': title, 'data': artifacts})
Esempio n. 9
0
def populate_all_manifests(request):
    logger = logging.getLogger('dashboard')
    couchbase = CouchbaseClient("http://localhost:8091/pools/default",
                                "default", "")
    cbclient = CbClient("localhost", 8091, "Administrator", "password")
    qr = cbclient.query(bucket='default',
                        ddoc='builds',
                        view='manifests',
                        limit=20000)
    for item in qr["rows"]:
        doc = item["value"]
        if doc["name"].find("-manifest.xml") == -1:
            #        if doc["name"].find("-manifest.xml") == -1 and 'commits' not in doc:
            manifest_commits = ManifestPopulate(doc, doc["url"]).json()
            doc['commits'] = manifest_commits
            couchbase.set(doc['name'].encode('ascii', 'ignore'), 0, 0,
                          json.dumps(doc).encode('ascii', 'ignore'))
            logger.info("retreived git commits for %s" % (doc['name']))
    return render_to_response('../templates/dashboard/empty.html')
Esempio n. 10
0
def gitx(request):
    '''
        get all commits for this project
        for top 20 , do view call to find out the builds
    '''
    logger = logging.getLogger('dashboard')
    project = request.GET.get('project')
    limit = request.GET.get('limit')
    couchbase = CouchbaseClient("http://localhost:8091/pools/default",
                                "default", "")
    cbclient = CbClient("localhost", 8091, "Administrator", "password")
    a, b, value = couchbase.get(project.encode('ascii', 'ignore'))
    commits = json.loads(value)["tree"]
    counter = 0
    data = list()
    for commit in commits:
        commit["builds"] = []
        counter = counter + 1
        filter_value = "\"%s-%s\"" % (project, commit["revision"])
        params = {"startkey": filter_value, "endkey": filter_value}
        qr = cbclient.query(bucket='default',
                            ddoc='builds',
                            view='commits',
                            limit=100,
                            params=params)
        for item in qr["rows"]:
            logger.error(commit["builds"])
            fullversion = item["value"][1].encode('ascii', 'ignore')
            if fullversion not in commit["builds"]:
                commit["builds"].append(fullversion)
        data.append(commit)
        end_index = commit["message"].find("\n") or len(commit["message"] - 1)
        commit["message"] = commit["message"][0:end_index]
        if counter == limit:
            break

    return render_to_response('../templates/dashboard/commits.html', {
        'title': 'commits',
        'data': data
    })
Esempio n. 11
0
def manifest(request):
    logger = logging.getLogger('dashboard')
    package_type = request.GET.get('package_type')
    fullversion = request.GET.get('fullversion')
    couchbase = CbClient("localhost", 8091, "Administrator", "password")
    manifests = couchbase.query(bucket='default',
                                ddoc='builds',
                                view='manifests',
                                limit=20000,
                                params={"startkey": "\"1.8.1-901-rel\""})

    descriptions = {}
    for item in manifests["rows"]:
        logger.error(package_type)
        value = item["value"]
        logger.error(value)
        if value["name"].find(package_type) >= 0:
            url = value["url"]
            logger.error("downloading manifest from url %s" % (url))
            content = _download(url)
            logger.error(content)
            to_json = _to_json(content, fullversion)
            logger.error(to_json)
            descriptions = _get_commits_description(to_json)
            logger.error(descriptions)
            id = value["name"]
            value
            break
            #convert to json
            #for each project get the git description
            #jsonbuild
    # update database....
    return render_to_response('templates/dashboard/manifest.html', {
        'title': 'manifests',
        'data': descriptions
    })