def get_package_details(name,version): try: res = myDb.get_package_byvalues(name,version) # 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 name and version." return except Exception as e: raise Exception('Exception encountered: ' + str(e)) return None
def process_package(self, name, version): # retrieve existing package or try to add a new one package = None matching_package_versions = myDb.get_package_byvalues(name, version) if len(matching_package_versions) > 0: package = matching_package_versions[0] if package.id: print "MATCHING PACKAGE FOUND (", package.id, package.name, package.version, ")" else: # add new package to db package = myDb.put_package(version, name) if package.id: print "ADDED NEW PACKAGE (", package.id, package.name, package.version, ")" return package