def add_vector(self, vector): self.vectors.append(vector) if len(self.vectors) > self.MAX_VECTOR_LENGTH: self.vectors.pop(0) if not self.has_activated: if self.is_full: self.has_activated = True Logger.field("Session Activated", "{}".format(self.display_id)) self.timestamp_end = time.time() self.time_left = self.SESSION_LONG_LIFE_FRAMES if self.is_full else self.SESSION_SHORT_LIFE_FRAMES
def _execute_rolling_window(self, rolling_window_size=5): """ Clean up the directory to fit within the rolling window size. """ session_files = os.listdir(self.OUTPUT_DIR) if len(session_files) > rolling_window_size: session_files.sort() # Delete the first n files from the session folder. excess = len(session_files) - rolling_window_size Logger.field("File Storage", "{}/{}".format(len(session_files), rolling_window_size)) if excess > 0: prune_files = session_files[:excess] for f in prune_files: Logger.field("Pruning File", "{}".format(f)) file_path = os.path.join(self.OUTPUT_DIR, f) os.remove(file_path)
def read_manifest(self, path: str, file_name: str = "resource_manifest.json") -> dict: """ Load a manifest from file into this RM's memory. """ resource_path = os.path.join(path, file_name) if not os.path.exists(resource_path): pass with open(resource_path, "r") as f: data = json.load(f) # Show the details of the loaded manifest. Logger.header("Loaded Manifest") for k in self.resources: Logger.field(k, self.resources[k]) self.resources = data return self.resources
""" Use this script to continously run the counter app. """ import argparse from tools.logger import Logger from counter.counter import Counter __author__ = "Jakrin Juangbhanich" __copyright__ = "Copyright 2018, GenVis Pty Ltd." __email__ = "*****@*****.**" __version__ = "0.0.1" def get_args(): parser = argparse.ArgumentParser() parser.add_argument('-v', '--visualize', action="store_true", help="Whether or not to visualize the results.") return parser.parse_args() args = get_args() visualize = args.visualize if __name__ == "__main__": Logger.field("Running", "Counter App") counter = Counter(visualize) counter.process(0)
def end(self): """ End the session and write the results to a file. """ Logger.field("Session Ended", "{}".format(self.display_id)) self.create_results_data()