Edit File: imunify_patch_id.cpython-311.pyc
� Gh� � �R � d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z ddl mZ ddlm Z ddlmZ ddlmZ dd lmZ dd lmZ ddlmZmZmZ ddlmZ dd lmZ ddlmZ ddl m!Z! dZ"dZ#dZ$ ej% e&� � Z' G d� de(� � Z)e*Z+de*de+fd�Z, e� � de*de+fd�� � Z- e d�� � de*fd�� � Z.de*de fd�Z/de+fd�Z0de de+dz fd�Z1de de+ddfd �Z2 ed!d"�#� � de*fd$�� � Z3e$fd%e4e*ef d&e5de4e*e4e*e5f f fd'�Z6dS )(u This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see <https://www.imunify360.com/legal/eula> � N)�defaultdict)� lru_cache)�islice)�Path)�Any)� urlencode)�IndependentAgentIDAPI)�HostingPanel)�async_lru_cache�log_error_and_ignore�safe_fileops)�IMUNIFY_PATCH_PURCHASE_URL)�VulnerabilityAPI)�VulnerabilityHitStatus)�VulnerabilityHitz.imunify_patch_id� � c � � e Zd ZdS )�ImunifyPatchIdErrorN)�__name__� __module__�__qualname__� � �T/opt/imunify360/venv/lib/python3.11/site-packages/imav/contracts/imunify_patch_id.pyr r 5 s � � � � � ��Dr r �username�returnc � � K � t | � � � d{V ��}t |� � x}r|S t � � }t ||� � � d{V �� |S )a� Ensure the Imunify.Patch ID file exists for the given user. This function checks if the Imunify.Patch ID file exists in the user's home directory. If it does not exist, it generates a new ID, writes it to the file, and returns the ID. If the file already exists, it reads and returns the existing ID. Args: username (str): The username for which to ensure the ID file. Returns: ImunifyPatchUserId: The Imunify.Patch user ID. N)�_get_id_file� _read_id_file�_generate_id�_write_id_file)r �id_file�_ids r �ensure_id_filer% <