File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/pkg/__pycache__/win.cpython-310.pyc
o
�N�g"� � @ st d Z ddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlmZ dZ
zddlZddlZddlZddlZddlZddlZW n eyX edkrWed��� w edkrze�� Ze�e�d�� e�e�Ze�e� e�ej� ne�e�Zzddlm Z W n ey� ddlm Z Y nw dd l!m"Z" G d
d� d�Z#G dd
� d
�Z$dd� Z%edkr�e%� dS dS )aK
Collect information about software installed on Windows OS
================
:maintainer: Salt Stack <https://github.com/saltstack>
:codeauthor: Damon Atkins <https://github.com/damon-atkins>
:maturity: new
:depends: pywin32
:platform: windows
Known Issue: install_date may not match Control Panel\Programs\Programs and Features
� N)�
cmp_to_keyz0.1�__main__z Please install pywin32/pypiwin32z[%(levelname)s]: %(message)s)�OrderedDict��Versionc @ sL e Zd ZdZe�d�Ze�d�Ze�d�Zi Z i Z
ejej
fejejejejfejd�Ze�� d dkrEe�� r?dejd�Zndd d�Znejdd�Zd+dd�Zd
d� Zedd� �Zedd� �Ze dd� �Z!d,dd�Z"dd� Z#d,dd�Z$e dd� �Z%e dd� �Z&e dd � �Z'e d!d"� �Z(e d#d$� �Z)e d%d&� �Z*e d'd(� �Z+e d)d*� �Z,d S )-�RegSoftwareInfoz�
Retrieve Registry data on a single installed software item or component.
Attribute:
None
:codeauthor: Damon Atkins <https://github.com/damon-atkins>
zO^\{(\w{8})-(\w{4})-(\w{4})-(\w\w)(\w\w)-(\w\w)(\w\w)(\w\w)(\w\w)(\w\w)(\w\w)\}$zG^(\w{8})(\w{4})(\w{4})(\w\w)(\w\w)(\w\w)(\w\w)(\w\w)(\w\w)(\w\w)(\w\w)$z$\d+\.\d+\.\d+[\w.-]*|\d+\.\d+[\w.-]*)�str�list�int�bytesr �32bit�TFNFc
C sJ || _ d| _d| _d| _d| _| j�|�}|dur0tdd�D ]}| j|�|�ddd� 7 _q|r\d| _ d| _
d| _d �||�| _
| jr[d
�|| j�| _|� d�| _d�|| j�| _n&d
| _ || _
| j| | _d�|�| _
| jr�d| j� �| _d| _d�| j�| _zt�tt| j �| j
dtj| jB �| _W n tjy� } z|jtjkr�t�d|||� � d}~ww d| _| jr�zt�tt| j �| jdtj| jB �| _W n& tjy� } z|jtjkr�t�d|||� d| _n� W Y d}~nd}~ww d| _t�| j��dd�}|�r!t |d��rt!�"|�#� �| _dS t |d��r#t$|�| _dS dS dS )a(
Initialise against a software item or component.
All software has a unique "Identifer" within the registry. This can be free
form text/numbers e.g. "MySoftware" or
GUID e.g. "{0EAF0D8F-C9CF-4350-BD9A-07EC66929E04}"
Args:
key_guid (str): Identifer.
sid (str): Security IDentifier of the User or None for Computer/Machine.
use_32bit (bool):
Regisrty location of the Identifer. ``True`` 32 bit registry only
meaning fully on 64 bit OS.
� N� � ����
HKEY_USERSFr z9{}\Software\Microsoft\Windows\CurrentVersion\Uninstall\{}z){}\Software\Classes\Installer\Products\{}z*\Software\Microsoft\Installer\UpgradeCodeszSSoftware\Microsoft\Windows\CurrentVersion\Installer\UserData\{}\Products\{}\Patches�HKEY_LOCAL_MACHINEz6Software\Microsoft\Windows\CurrentVersion\Uninstall\{}z$Software\Classes\Installer\Products\z'Software\Classes\Installer\UpgradeCodeszYSoftware\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\{}\PatcheszISoftware/Component Not Found key_guid: '%s', sid: '%s' , use_32bit: '%s'zgSoftware/Component Not Found in Products section of registry key_guid: '%s', sid: '%s', use_32bit: '%s'Z
LastWriteTime�utctimetuple�__int__)%�_RegSoftwareInfo__reg_key_guid�_RegSoftwareInfo__squidZ#_RegSoftwareInfo__reg_products_path�&_RegSoftwareInfo__reg_upgradecode_path�_RegSoftwareInfo__patch_list�_RegSoftwareInfo__guid_pattern�match�range�group�_RegSoftwareInfo__reg_hive�_RegSoftwareInfo__reg_32bit�"_RegSoftwareInfo__reg_32bit_access�format�$_RegSoftwareInfo__reg_uninstall_path�"_RegSoftwareInfo__reg_patches_path�"_RegSoftwareInfo__use_32bit_lookup�win32api�RegOpenKeyEx�getattr�win32con�KEY_READ�&_RegSoftwareInfo__reg_uninstall_handle�
pywintypes�error�winerror�ERROR_FILE_NOT_FOUND�log�%_RegSoftwareInfo__reg_products_handle�debug�_RegSoftwareInfo__mod_time1970ZRegQueryInfoKeyW�get�hasattr�time�mktimer r
)�selfZkey_guid�sid� use_32bitZ
guid_match�index�excZmod_win_time� r<