def clone(user, source, dest=None, push=None, remoteauth="write", authtype=None, username=None, password=None, kcpass="", vcs="hg", vcsuser=None): """Clones or checks out the repository using the command provided.""" user = user.username job_body = dict(user=user, source=source, dest=dest, push=push, remoteauth=remoteauth, authtype=authtype, username=username, password=password, kcpass=kcpass, vcs=vcs, vcsuser=vcsuser) return queue.enqueue("vcs", job_body, execute="bespin.vcs:clone_run", error_handler="bespin.vcs:vcs_error", use_db=True)
def run_command(user, project, args, kcpass=None): """Run any VCS command through UVC.""" user = user.username project = project.name job_body = dict(user=user, project=project, args=args, kcpass=kcpass) return queue.enqueue("vcs", job_body, execute="bespin.vcs:run_command_run", error_handler="bespin.vcs:vcs_error", use_db=True)
def rescan_project(request, response): user = request.user project_name = request.kwargs['project_name'] project = get_project(user, user, project_name) job_body = dict(user=user.username, project=project_name) jobid = queue.enqueue("vcs", job_body, execute="bespin.filesystem:rescan_project", error_handler="bespin.vcs:vcs_error", use_db=True) response.content_type = "application/json" response.body = simplejson.dumps(dict(jobid=jobid, taskname="Rescan %s" % project_name)) return response()
def clone(user, source, dest=None, push=None, remoteauth="write", authtype=None, username=None, password=None, kcpass="", vcs="hg"): """Clones or checks out the repository using the command provided.""" user = user.username job_body = dict(user=user, source=source, dest=dest, push=push, remoteauth=remoteauth, authtype=authtype, username=username, password=password, kcpass=kcpass, vcs=vcs) return queue.enqueue("vcs", job_body, execute="bespin.vcs:clone_run", error_handler="bespin.vcs:vcs_error", use_db=True)
def run_deploy(user, project, kcpass, options): """Add the deployment request to the worker queue.""" pdo = ProjectDeploymentOptions.get(project) if not pdo: raise NotConfigured("Deployment is not yet configured.") user = user.username project = project.name job_body = dict(user=user, project=project, kcpass=kcpass, options=options) return queue.enqueue("vcs", job_body, execute="bespin.deploy:deploy_impl", error_handler="bespin.deploy:deploy_error", use_db=True)
def rescan_project(request, response): user = request.user project_name = request.kwargs['project_name'] project = get_project(user, user, project_name) job_body = dict(user=user.username, project=project_name) jobid = queue.enqueue("vcs", job_body, execute="bespin.filesystem:rescan_project", error_handler="bespin.vcs:vcs_error", use_db=True) response.content_type = "application/json" response.body = simplejson.dumps( dict(jobid=jobid, taskname="Rescan %s" % project_name)) return response()
def test_sync_queueing(): config.c.async_jobs = False job_handler.message = dict(answer=42, question="what do you get if you multiply six by nine?", execute="bespin.tests.test_queues:job_handler") job_handler.queue = "vcs" job_handler.called = False job_handler.id = None try: id = queue.enqueue("vcs", job_handler.message) assert id is None assert job_handler.called finally: config.c.async_jobs = True
def test_async_queueing(): job_handler.message = dict(data=[1,2,3], execute="bespin.tests.test_queues:job_handler") job_handler.queue = "vcs" job_handler.called = False id = queue.enqueue("vcs", job_handler.message) assert id > 0 job_handler.id = id sq = queue.StupidQueue() cursor = sq.conn.execute("select count(*) from queue") cursor.close() qi = sq._get_item("vcs") assert qi is not None queue.run_queue_item(qi) assert job_handler.called