def put_job(): try: # Add a new job. Pokes simons controller code with the correct values for uri, method, vcs_id etc... packageinstance_id = request.forms.get('packageinstance_id') method = request.forms.get('method') vcs_id = request.forms.get('vcs_id') uri = request.forms.get('uri') if packageinstance_id and method and vcs_id and uri: packageinstance = myDb.get_packageinstance_id(packageinstance_id) package_version = packageinstance.package.version package_name = packageinstance.package.name arch = packageinstance.arch.name # TODO: parse list dist = packageinstance.distribution.name suite = packageinstance.suite.name pkg_format = packageinstance.format.name print ("Calling Controller.process_job(" + uri + "," + method + "," + dist + "," + vcs_id + "," + arch + "," + package_version + "," + package_name + "," + suite + "," + pkg_format + ")") # Pass to controller to queue up transport = Transport(None, method, uri, vcs_id) buildController.process_job(dist, arch, package_version, package_name, suite, pkg_format, transport) else: response.status = "400 - Required fields missing." return except Exception as e: raise Exception('Exception encountered: ' + str(e)) return None
def get_packageinstance_id(packageinstance_id): try: # Returns all information about a specific packageinstance res = myDb.get_packageinstance_id(packageinstance_id) # check results returned if res: encoded = jsonpickle.encode(res) response.content_type = "application/json" return encoded else: response.status = "404 - No packageinstance found with this ID." return except Exception as e: raise Exception('Exception encountered: ' + str(e)) return None