def prepare_logs_to_send(): log_files = [] logger = logging.getLogger("app." + __name__) for handler in logger.handlers: handler.flush() possible_paths = paths.get_paths_to_settings_folder() for path in possible_paths: for log in os.listdir(path): try: if log.startswith(os.path.basename(LOG_FILE))\ or log.startswith(os.path.basename(EXCEPTIONS_LOG_FILE))\ or log.startswith(os.path.basename(CLOUD_SYNC_LOG_FILE)): log_files.append(os.path.join(path, log)) except Exception: continue if not log_files: logger.info('Log files was not created for some reason. Nothing to send') return if not os.path.exists(LOG_SNAPSHOTS_DIR): try: os.mkdir(LOG_SNAPSHOTS_DIR) except Exception as e: logger.warning("Can't create directory %s" % LOG_SNAPSHOTS_DIR) return e for fname in log_files: shutil.copyfile(fname, os.path.join(LOG_SNAPSHOTS_DIR, os.path.basename(fname)))
def process_logout(self): for path in paths.get_paths_to_settings_folder(): login_info_path = os.path.join(path, 'login_info.bin') if os.path.isfile(login_info_path): try: os.remove(login_info_path) except Exception as e: self.logger.error('Failed to logout: ' + e.message) page = self.server.web_content_files['pages']['logout.html'] self.write_with_autoreplace(page)
def process_logout(self): for path in paths.get_paths_to_settings_folder(): login_info_path = os.path.join(path, 'login_info.bin') if os.path.isfile(login_info_path): try: os.remove(login_info_path) except Exception as e: self.logger.error('Failed to logout: ' + e.message) if sys.platform.startswith('darwin'): page = self.server.web_content_files['logout.html'] self.write_with_autoreplace(page) return self.restart_main_app() self.write_message('Logout. Please wait...', show_time=4)
def process_logout(self): for path in paths.get_paths_to_settings_folder(): login_info_path = os.path.join(path, 'login_info.bin') if os.path.isfile(login_info_path): try: os.remove(login_info_path) except Exception as e: self.logger.error('Failed to logout: ' + e.message) if sys.platform.startswith('darwin'): page = self.read_file('web_interface/logout.html') self.write_with_autoreplace(page) return self.restart_main_app() self.write_message('Logout. Please wait...', show_time=4)
def read_login(): logger = logging.getLogger('app.' + __name__) pack_name = 'login_info.bin' paths_to_settings = paths.get_paths_to_settings_folder() for path in paths_to_settings: logger.info("Searching for login info in %s" % path) try: login_info = read_login_zip(pack_name, path) if login_info: logger.info('Login info loaded from ' + path) return login_info except Exception as e: logger.warning('Failed loading login from ' + path + '. Error: ' + e.message) logger.info("Can't read login info in %s" % str(path)) logger.info('No login info found') return (None, None)