class CLIClient(object): def __init__(self, server): self.client = IngesterPlatformAPI(server, None) def file_or_json(self, s): """Try to open the file or parse the string as JSON""" obj = None if os.path.exists(s): with open(r, "r") as f: obj = json.load(f) else: obj = json.loads(s) return self.client._marshaller.dict_to_obj(obj) def ping(self): return self.client.ping() def enable(self, ds_id): return self.client.enableDataset(ds_id) def disable(self, ds_id): return self.client.disableDataset(ds_id) def search(self, criteria, limit=20, offset=0): return self.client._marshaller.obj_to_dict( self.client.search(self.file_or_json(criteria), int(offset), int(limit))) def logs(self, ds_id): return self.client._marshaller.obj_to_dict( self.client.getIngesterLogs(ds_id)) def post(self, s): obj = self.file_or_json(s) return (self.client._marshaller.obj_to_dict(self.client.post(obj))) def get(self, *args): if args[0] == "schema": return (self.client.getSchema(args[1])) elif args[0] == "location": return (self.client.getLocation(args[1])) elif args[0] == "dataset": return (self.client.getDataset(args[1]))
class CLIClient(object): def __init__(self, server): self.client = IngesterPlatformAPI(server, None) def file_or_json(self, s): """Try to open the file or parse the string as JSON""" obj = None if os.path.exists(s): with open(r, "r") as f: obj = json.load(f) else: obj = json.loads(s) return self.client._marshaller.dict_to_obj(obj) def ping(self): return self.client.ping() def enable(self, ds_id): return self.client.enableDataset(ds_id) def disable(self, ds_id): return self.client.disableDataset(ds_id) def search(self, criteria, limit=20, offset=0): return self.client._marshaller.obj_to_dict(self.client.search(self.file_or_json(criteria), int(offset), int(limit))) def logs(self, ds_id): return self.client._marshaller.obj_to_dict(self.client.getIngesterLogs(ds_id)) def post(self, s): obj = self.file_or_json(s) return (self.client._marshaller.obj_to_dict(self.client.post(obj))) def get(self, *args): if args[0] == "schema": return (self.client.getSchema(args[1])) elif args[0] == "location": return (self.client.getLocation(args[1])) elif args[0] == "dataset": return (self.client.getDataset(args[1]))
started = False for data_entry in data_entries: with open(os.path.join(cwd, data_entry["file"].f_path)) as f: for l in f.readlines(): l = l.strip() if not started: if l == "BEGIN TEMP": started = True elif started and l == "END TEMP": break else: # parse line l = l.split(",") if len(l) < 3: continue if l[1] != "%s": continue new_data_entry = DataEntry(timestamp=datetime.datetime.now()) new_data_entry["temp"] = float(l[2]) ret.append( new_data_entry ) return ret """ temp_dataset1 = Dataset( location=loc.id, schema=temp_schema.id, data_source=DatasetDataSource(file_dataset.id, processing_script=processing_script % "28180E08030000BE")) temp_dataset1.enabled = True temp_dataset1 = ingester_platform.post(temp_dataset1) ingester_platform.enableDataset(file_dataset.id)