How to use the gear.Client function in gear

To help you get started, we’ve selected a few gear examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github junneyang / xxcloud / gearmanjobclient.py View on Github external
mysql = mysqlLib()
    url = None
    try:
        param = (username ,jenkinsurl, jobname, json.dumps(build_params), 0)
        n,last_id = mysql.add_task(param)
        print(u"INFO, job initial, 0")
        unique_id = last_id
        if (specifynode == 1):
            J = Jenkins(jenkinsurl)
            jobs = Jobs(J)
            job = jobs[jobname]
            build_params['UNIQUE_ID'] = unique_id
            invoke = job.invoke(build_params=build_params)
            print("INFO, specifynode true")
        elif (specifynode == 0):
            client = gear.Client()
            client.addServer(gear_server, port = gear_port)
            client.waitForServer()  # Wait for at least one server to be connected
            build_params['UNIQUE_ID'] = unique_id
            job = gear.Job('build:' + jobname, json.dumps(build_params))
            client.submitJob(job)
            print("INFO, specifynode false")
        param=(1, unique_id)
        mysql.update_task_status(param)
        print(u"INFO, job submit, 1")
        print(u"INFO, job unique id :" + str(unique_id))
        url = "http://10.48.55.39:8889/jobstatus/?job=" + str(unique_id)
        print(u"INFO, you could link " + url + " to trace the job status")
    except Exception as e:
        print(e)
    finally:
        mysql.close()