def __get_operator_info(self): if is_android: #TODO: Optimization, avoid repetitive calls return mi2app_utils.get_operator_info() else: self.__op = self.get_analyzer('TrackCellInfoAnalyzer').get_cur_op() return self.__op
def _save_log(self): self.__log_timestamp = str( time.strftime('%Y%m%d_%H%M%S', time.localtime(os.path.getmtime(self.__orig_file)))) milog_base_name = "diag_log_%s_%s_%s.mi2log" % ( self.__log_timestamp, util.get_phone_info(), util.get_operator_info()) milog_abs_name = os.path.join(self.__log_dir, milog_base_name) shutil.copyfile(self.__orig_file, milog_abs_name) os.remove(self.__orig_file) return milog_abs_name
def _save_log(self): orig_base_name = os.path.basename(self.__orig_file) orig_dir_name = os.path.dirname(self.__orig_file) milog_base_name = "diag_log_%s_%s_%s.mi2log" % ( self.__log_timestamp, util.get_phone_info(), util.get_operator_info()) # milog_abs_name = os.path.join(self.__log_dir, milog_base_name) milog_abs_name = os.path.join(self.__own_log_task_dir, milog_base_name) if os.path.isfile(self.__orig_file): shutil.copyfile(self.__orig_file, milog_abs_name) os.remove(self.__orig_file) return milog_abs_name
def __init__(self, config): Analyzer.__init__(self) self.__log_dir = util.get_mobileinsight_log_path() self.__dec_log_dir = util.get_mobileinsight_log_decoded_path() self.__orig_file = "" self.__raw_msg = {} self.__raw_msg_key = "" self.__msg_cnt = 0 self.__dec_msg = [] self.__is_wifi_enabled = False self.state = states[0] self.sr_round = 0 self.round = 0 self.sr_record = [] self.record = { 'round': 0, 'total': 0, 'msg': [], } self.__sr_log_path = "%s/sr/sr_latency_%s_%s_%s.txt" % \ (util.get_mobileinsight_path(), datetime.now().strftime('%Y%m%d_%H%M%S'), util.get_phone_info(), util.get_operator_info()) self.__MILabPluginName = 'SRLatency' self.__own_log_uploaded_dir = os.path.join( util.get_mobileinsight_plugin_path(), self.__MILabPluginName, "log", "uploaded") if not os.path.exists(self.__own_log_uploaded_dir): os.makedirs(self.__own_log_uploaded_dir) self.__task = "Unknown" if 'task' in config: self.__task = config['task'] self.__own_log_task_dir = os.path.join( util.get_mobileinsight_plugin_path(), self.__MILabPluginName, "log", self.__task) if not os.path.exists(self.__own_log_task_dir): os.makedirs(self.__own_log_task_dir) try: if config['is_use_wifi'] == '1': self.__is_use_wifi = True else: self.__is_use_wifi = False except BaseException: self.__is_use_wifi = False # try: # if config['is_dec_log'] == '1': # self.__is_dec_log = True # self.__dec_log_name = "diag_log_" + \ # datetime.datetime.now().strftime('%Y%m%d_%H%M%S') + ".txt" # self.__dec_log_path = os.path.join( # self.__dec_log_dir, self.__dec_log_name) # else: # self.__is_dec_log = False # except BaseException: # self.__is_dec_log = False try: self.__dec_log_type = config['log_type'] except BaseException: self.__dec_log_type = "" if not os.path.exists(self.__log_dir): os.makedirs(self.__log_dir) if not os.path.exists(self.__dec_log_dir): os.makedirs(self.__dec_log_dir) self.add_source_callback(self._logger_filter) # Add this code at the end of onCreate() self.br = BroadcastReceiver(self.on_broadcast, actions=['MobileInsight.Main.StopService']) self.br.start()