Exemplo n.º 1
0
def put_packageinstance():
	try:
		# Add a new packageinstance.
		package_id = request.forms.get('package_id')
		arch_id = request.forms.get('arch_id')
		suite_id = request.forms.get('suite_id')
		dist_id = request.forms.get('dist_id')
		format_id =  request.forms.get('format_id')
		slave = request.forms.get('slave')

		if not slave:
			slave = "false"

		if package_id and arch_id  and suite_id  and dist_id and format_id and slave:

			package = myDb.get_package_id(package_id)
			arch = myDb.get_arch_id(arch_id)
			suite = myDb.get_suite_id(suite_id)
			dist = myDb.get_dist_id(dist_id)
			pkg_format = myDb.get_format_id(format_id)

			myDb.put_packageinstance(package,arch,suite,dist,pkg_format,slave)
		else:
			response.status = "400 - Required fields missing."
		return
	except Exception as e:
		raise Exception('Exception encountered: ' + str(e))
		return None
Exemplo n.º 2
0
 def cancel_package(self, package_id):
     # cancels all instances of a package
     package = myDb.get_package_id(package_id)
     if not package.id:
         response.status = "404 - no package matching package_id"
     else:
         unfinished_jobs_list = myDb.get_unfinished_jobs()
         for unfinished_job in unfinished_jobs_list:
             if (unfinished_job.packageinstance.package.name == package.name) and (
                 unfinished_job.packageinstance.package.version == package.version
             ):
                 self.process_cancel(unfinished_job)
     return
Exemplo n.º 3
0
def get_package_id(package_id):
	try:
		# Returns all information about a specific package
		res = myDb.get_package_id(package_id)

		# check results returned
		if res:
			encoded = jsonpickle.encode(res)
			response.content_type = "application/json"
			return encoded
		else:
			response.status = "404 - No package found with this ID."
			return
	except Exception as e:
		raise Exception('Exception encountered: ' + str(e))
		return None