def freeze(options, args): rosrs = ROSRS_Session(options["rosrs_uri"], options["rosrs_access_token"]) service_uri = urljoin(options["rosrs_uri"], "../evo/finalize/") body = { 'target': args[2], } body = json.dumps(body) reqheaders = {} (status, reason, headers, data) = response = rosrs.doRequest(uripath=service_uri, method="POST", body=body, ctype="application/json", reqheaders=reqheaders) if "location" in headers: while print_job_status(parse_job(rosrs, headers['location']), options, True): time.sleep(1) print "freeze operation finished successfully" return 0 else: print status print reason print headers print data print "Given URI isn't correct" return -1
def copy_operation(options, args, ro_type): options["rosrs_access_token"] rosrs = ROSRS_Session(options["rosrs_uri"], options["rosrs_access_token"]) service_uri = urljoin(options["rosrs_uri"], "../evo/copy/") body = { 'copyfrom': args[2], 'type': ro_type, 'finalize': ("%s" % options['freeze']).lower() } body = json.dumps(body) reqheaders = {'Slug': args[3]} response = rosrs.doRequest(uripath=service_uri, method="POST", body=body, ctype="application/json", reqheaders=reqheaders) if response[0] != 201: return handle_copy_error(options, rosrs, response, ro_type) if not options["asynchronous"]: return handle_synchronous_copy_operation_with_esc_option( options, rosrs, response, ro_type) if options["asynchronous"]: return handle_asynchronous_copy_operation(options, rosrs, response, ro_type) return 0
def __init__(self, roconfig, roref, dummysetupfortest=False): """ Initialize: read manifest from object at given directory into local RDF graph roconfig is the research object manager configuration, supplied as a dictionary roref a URI reference that refers to the Research Object to be accessed, or relative path name (see ro_uriutils.resolveFileAsUri for interpretation) dummysetupfortest is an optional parameter that, if True, suppresses some aspects of the setup (does not attempt to read a RO manifest) for isolated testing. """ self.roconfig = roconfig self.roref = roref self.dummyfortest = dummysetupfortest self.manifestgraph = None self.roannotations = None self.registries = None uri = resolveFileAsUri(roref) if not uri.endswith("/"): uri += "/" self.rouri = rdflib.URIRef(uri) if self._isLocal(): self.rosrs = None else: self.rosrs = ROSRS_Session(self.roconfig["rosrs_uri"], self.roconfig["rosrs_access_token"]) self._loadManifest() # Get RO URI from manifest # May be different from computed value if manifest has absolute URI # Nested URIs may be present; ours is the one described by the manifest URI, # which is determined by the _loadManifest() method. for s in self.manifestgraph.subjects(RDF.type, RO.ResearchObject): if self.manifestgraph.value(s, ORE.isDescribedBy) == self.manifesturi: self.rouri = s # Check that the manifest contained at least one RO URI assert self.rouri is not None return