def init(self): self.manager = mp.Manager() self.queue = self.manager.Queue() self.consumer_task = None self.pool = mp.Pool(1) self.report_enable = False self.anonymizer = Anonymizer()
def stat_uninstall(bin_path): agent_datasource = AgentDatasource(config_storage=ConfigStorage(alternate_path=f"{bin_path}/configPlugins.json")) report_enable = agent_datasource.get_report_enable() stats_tracker = StatsTracker(sync=True, anonymizer=Anonymizer(alternate_path=f"{bin_path}/anonymize.json")) stats_tracker.report_enable = report_enable login = getpass.getuser() stats_tracker.log_uninstall(login) print("record uninstall")
def __init__(self, sync=False, anonymizer: Anonymizer = Anonymizer()): if not sync: self.manager = mp.Manager() self.queue = self.manager.Queue() self.pool = mp.Pool(1) self.consumer_stats = None self.anonymizer = anonymizer self.report_enable = False
def __parse_state__(command: State, anonymizer: Anonymizer): command_api = StateApi() command_api.command_id = command.command_id command_api.user_name = anonymizer.anonymize(command.user_name) command_api.command = command.command command_api.root = command.root command_api.processes = command.processes command_api.file_changes = command.file_changes command_api.network = command.network command_api.result_code = command.result_code command_api.stderr = command.stderr return command_api
def save_report_info(unassisted, agent_datasource, bin_path, demo_mode): enable_report = True if demo_mode: enable_report = False elif not unassisted: enable_report = \ ask_to_user( "Would you like anonymously send debugging and usage information" "to the CLAI team in order to help improve it? (y/n)") agent_datasource.mark_report_enable(enable_report) stats_tracker = StatsTracker(sync=True, anonymizer=Anonymizer(alternate_path=f'{bin_path}/anonymize.json')) stats_tracker.report_enable = enable_report stats_tracker.log_install(getpass.getuser())
def __new__(cls, sync=False, anonymizer: Anonymizer = Anonymizer()): if cls._instance is None: cls._instance = super(StatsTracker, cls).__new__(cls) cls._instance.init(sync, anonymizer) return cls._instance