a
    $ñ»je2  ã                   @  s  d dl mZ d dlZd dlZd dlmZ ddlmZ eG dd„ dƒƒZeG dd	„ d	ƒƒZ	eG d
d„ dƒƒZ
eG dd„ dƒƒZG dd„ dejƒZG dd„ dejƒZeG dd„ dƒƒZeG dd„ dƒƒZeG dd„ dƒƒZddœdd„Zdddœdd „Zd!dœd"d#„ZdS )$é    )ÚannotationsN)Ú	dataclassé   )ÚT_JSON_DICTc                   @  s|   e Zd ZU dZded< ded< ded< ded< ded< ded	< d
Zded< d
Zded< ddœdd„Zedd dœdd„ƒZ	d
S )Ú	GPUDevicez,Describes a single graphics processor (GPU).ÚfloatÚ	vendor_idÚ	device_idÚstrÚvendor_stringÚdevice_stringÚdriver_vendorÚdriver_versionNztyping.Optional[float]Ú
sub_sys_idÚrevisionr   ©Úreturnc                 C  sn   t ƒ }| j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | jd urV| j|d< | jd urj| j|d< |S )	NÚvendorIdÚdeviceIdÚvendorStringÚdeviceStringÚdriverVendorÚdriverVersionÚsubSysIdr   )	Údictr   r	   r   r   r   r   r   r   ©ÚselfÚjson© r   ú7E:\soccer\ml_env\Lib\site-packages\mycdp/system_info.pyÚto_json#   s    









zGPUDevice.to_json©r   r   c                 C  s€   | t |d ƒt |d ƒt|d ƒt|d ƒt|d ƒt|d ƒ| dd ¡d urZt |d ƒnd | dd ¡d urxt |d ƒnd d	�S )
Nr   r   r   r   r   r   r   r   )r   r	   r   r   r   r   r   r   )r   r
   Úget©Úclsr   r   r   r   Ú	from_json1   s    





ÿÿñzGPUDevice.from_json)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   r    Úclassmethodr%   r   r   r   r   r      s   
r   c                   @  sD   e Zd ZU dZded< ded< ddœdd„Zedd d	œd
d„ƒZdS )ÚSizez7Describes the width and height dimensions of an entity.ÚintÚwidthÚheightr   r   c                 C  s   t ƒ }| j|d< | j|d< |S )Nr.   r/   )r   r.   r/   r   r   r   r   r    O   s    

zSize.to_jsonr!   c                 C  s   | t |d ƒt |d ƒd�S )Nr.   r/   )r.   r/   )r-   r#   r   r   r   r%   U   s    

þzSize.from_jsonN©r&   r'   r(   r)   r*   r    r+   r%   r   r   r   r   r,   G   s   
r,   c                   @  sL   e Zd ZU dZded< ded< ded< ddœd	d
„Zedd dœdd„ƒZdS )Ú VideoDecodeAcceleratorCapabilityzo
    Describes a supported video decoding profile with its associated minimum
    and maximum resolutions.
    r
   Úprofiler,   Úmax_resolutionÚmin_resolutionr   r   c                 C  s0   t ƒ }| j|d< | j ¡ |d< | j ¡ |d< |S )Nr2   ÚmaxResolutionÚminResolution)r   r2   r3   r    r4   r   r   r   r   r    j   s
    
z(VideoDecodeAcceleratorCapability.to_jsonr!   c                 C  s*   | t |d ƒt |d ¡t |d ¡d�S )Nr2   r5   r6   )r2   r3   r4   )r
   r,   r%   r#   r   r   r   r%   q   s
    
ýz*VideoDecodeAcceleratorCapability.from_jsonNr0   r   r   r   r   r1   ]   s   
r1   c                   @  sT   e Zd ZU dZded< ded< ded< ded< d	d
œdd„Zed	d dœdd„ƒZdS )Ú VideoEncodeAcceleratorCapabilityzx
    Describes a supported video encoding profile with its associated maximum
    resolution and maximum framerate.
    r
   r2   r,   r3   r-   Úmax_framerate_numeratorÚmax_framerate_denominatorr   r   c                 C  s6   t ƒ }| j|d< | j ¡ |d< | j|d< | j|d< |S )Nr2   r5   ÚmaxFramerateNumeratorÚmaxFramerateDenominator)r   r2   r3   r    r8   r9   r   r   r   r   r    Š   s    


z(VideoEncodeAcceleratorCapability.to_jsonr!   c                 C  s2   | t |d ƒt |d ¡t|d ƒt|d ƒd�S )Nr2   r5   r:   r;   )r2   r3   r8   r9   )r
   r,   r%   r-   r#   r   r   r   r%   ’   s    


üz*VideoEncodeAcceleratorCapability.from_jsonNr0   r   r   r   r   r7   z   s   
r7   c                   @  s>   e Zd ZdZdZdZdZddœdd„Zedd d	œd
d„ƒZ	dS )ÚSubsamplingFormatz4YUV subsampling type of the pixels of a given image.Zyuv420Zyuv422Zyuv444r
   r   c                 C  s   | j S ©N©Úvalue©r   r   r   r   r    ¢   s    zSubsamplingFormat.to_jsonr!   c                 C  s   | |ƒS r=   r   r#   r   r   r   r%   ¥   s    zSubsamplingFormat.from_jsonN)
r&   r'   r(   r)   ZYUV420ZYUV422ZYUV444r    r+   r%   r   r   r   r   r<   œ   s   r<   c                   @  s>   e Zd ZdZdZdZdZddœdd„Zedd d	œd
d„ƒZ	dS )Ú	ImageTypezImage format of a given image.ZjpegZwebpÚunknownr
   r   c                 C  s   | j S r=   r>   r@   r   r   r   r    °   s    zImageType.to_jsonr!   c                 C  s   | |ƒS r=   r   r#   r   r   r   r%   ³   s    zImageType.from_jsonN)
r&   r'   r(   r)   ZJPEGZWEBPÚUNKNOWNr    r+   r%   r   r   r   r   rA   ª   s   rA   c                   @  sT   e Zd ZU dZded< ded< ded< ded< d	d
œdd„Zed	d dœdd„ƒZdS )Ú ImageDecodeAcceleratorCapabilityz
    Describes a supported image decoding profile with its associated minimum
    and maximum resolutions and subsampling.
    rA   Ú
image_typer,   Úmax_dimensionsÚmin_dimensionsztyping.List[SubsamplingFormat]Úsubsamplingsr   r   c                 C  sH   t ƒ }| j ¡ |d< | j ¡ |d< | j ¡ |d< dd„ | jD ƒ|d< |S )NÚ	imageTypeÚmaxDimensionsÚminDimensionsc                 S  s   g | ]}|  ¡ ‘qS r   ©r    ©Ú.0Úir   r   r   Ú
<listcomp>Ì   ó    z<ImageDecodeAcceleratorCapability.to_json.<locals>.<listcomp>rH   )r   rE   r    rF   rG   rH   r   r   r   r   r    Ç   s    z(ImageDecodeAcceleratorCapability.to_jsonr!   c                 C  s<   | t  |d ¡t |d ¡t |d ¡dd„ |d D ƒd�S )NrI   rJ   rK   c                 S  s   g | ]}t  |¡‘qS r   )r<   r%   rM   r   r   r   rP   Õ   s   z>ImageDecodeAcceleratorCapability.from_json.<locals>.<listcomp>rH   )rE   rF   rG   rH   )rA   r%   r,   r#   r   r   r   r%   Ï   s    ÿüz*ImageDecodeAcceleratorCapability.from_jsonNr0   r   r   r   r   rD   ¸   s   
rD   c                   @  st   e Zd ZU dZded< ded< ded< ded	< d
ed< dZded< dZded< ddœdd„Zedd dœdd„ƒZ	dS )ÚGPUInfoz4Provides information about the GPU(s) on the system.ztyping.List[GPUDevice]Údevicesztyping.List[str]Údriver_bug_workaroundsz-typing.List[VideoDecodeAcceleratorCapability]Úvideo_decodingz-typing.List[VideoEncodeAcceleratorCapability]Úvideo_encodingz-typing.List[ImageDecodeAcceleratorCapability]Úimage_decodingNztyping.Optional[dict]Úaux_attributesÚfeature_statusr   r   c                 C  s–   t ƒ }dd„ | jD ƒ|d< dd„ | jD ƒ|d< dd„ | jD ƒ|d< dd„ | jD ƒ|d	< d
d„ | jD ƒ|d< | jd ur~| j|d< | jd ur’| j|d< |S )Nc                 S  s   g | ]}|  ¡ ‘qS r   rL   rM   r   r   r   rP   ï   rQ   z#GPUInfo.to_json.<locals>.<listcomp>rS   c                 S  s   g | ]}|‘qS r   r   rM   r   r   r   rP   ð   rQ   ÚdriverBugWorkaroundsc                 S  s   g | ]}|  ¡ ‘qS r   rL   rM   r   r   r   rP   ñ   rQ   ÚvideoDecodingc                 S  s   g | ]}|  ¡ ‘qS r   rL   rM   r   r   r   rP   ò   rQ   ÚvideoEncodingc                 S  s   g | ]}|  ¡ ‘qS r   rL   rM   r   r   r   rP   ó   rQ   ÚimageDecodingÚauxAttributesÚfeatureStatus)r   rS   rT   rU   rV   rW   rX   rY   r   r   r   r   r    í   s    



zGPUInfo.to_jsonr!   c                 C  s”   | dd„ |d D ƒdd„ |d D ƒdd„ |d D ƒdd„ |d	 D ƒd
d„ |d D ƒ|  dd ¡d urnt|d ƒnd |  dd ¡d urŒt|d ƒnd d�S )Nc                 S  s   g | ]}t  |¡‘qS r   )r   r%   rM   r   r   r   rP   ý   rQ   z%GPUInfo.from_json.<locals>.<listcomp>rS   c                 S  s   g | ]}t |ƒ‘qS r   )r
   rM   r   r   r   rP   þ   s   rZ   c                 S  s   g | ]}t  |¡‘qS r   )r1   r%   rM   r   r   r   rP     s   ÿr[   c                 S  s   g | ]}t  |¡‘qS r   )r7   r%   rM   r   r   r   rP     s   ÿr\   c                 S  s   g | ]}t  |¡‘qS r   )rD   r%   rM   r   r   r   rP   	  s   ÿr]   r^   r_   )rS   rT   rU   rV   rW   rX   rY   )r"   r   r#   r   r   r   r%   ú   s*    ÿþþþÿÿçzGPUInfo.from_json)
r&   r'   r(   r)   r*   rX   rY   r    r+   r%   r   r   r   r   rR   Û   s   
rR   c                   @  sL   e Zd ZU dZded< ded< ded< dd	œd
d„Zedd dœdd„ƒZdS )ÚProcessInfozRepresents process info.r
   Útype_r-   Úid_r   Úcpu_timer   r   c                 C  s(   t ƒ }| j|d< | j|d< | j|d< |S )NÚtypeÚidÚcpuTime)r   ra   rb   rc   r   r   r   r   r    %  s
    


zProcessInfo.to_jsonr!   c                 C  s&   | t |d ƒt|d ƒt|d ƒd�S )Nrd   re   rf   )ra   rb   rc   )r
   r-   r   r#   r   r   r   r%   ,  s
    


ýzProcessInfo.from_jsonNr0   r   r   r   r   r`     s   
r`   zPtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.Tuple[GPUInfo, str, str, str]]r   c                  c  s<   ddi} | V }t  |d ¡t|d ƒt|d ƒt|d ƒfS )aÇ  
    Returns information about the system.
    :returns: A tuple with the following items:
        0. **gpu** - Information about the GPUs on the system.
        1. **modelName** -
         A platform-dependent description of the model of the machine.
         On Mac OS, this is, for example, 'MacBookPro'.
         Will be the empty string if not supported.
        2. **modelVersion** -
         A platform-dependent description of the version of the machine.
         On Mac OS, this is, for example, '10.1'.
         Will be the empty string if not supported.
        3. **commandLine** -
         The command line string used to launch the browser.
         Will be the empty string if not supported.
    ÚmethodzSystemInfo.getInfoZgpuZ	modelNameZmodelVersionZcommandLine)rR   r%   r
   ©Úcmd_dictr   r   r   r   Úget_info5  s    ÿ


ürj   r
   z0typing.Generator[T_JSON_DICT, T_JSON_DICT, bool])Úfeature_stater   c                 c  s*   t ƒ }| |d< d|dœ}|V }t|d ƒS )zP
    Returns information about the feature state.
    :param feature_state:
    ZfeatureStatezSystemInfo.getFeatureState)rg   ÚparamsZfeatureEnabled)r   Úbool)rk   rl   ri   r   r   r   r   Úget_feature_stateV  s    þrn   zDtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[ProcessInfo]]c                  c  s    ddi} | V }dd„ |d D ƒS )zi
    Returns information about all running processes.
    :returns: An array of process info blocks.
    rg   zSystemInfo.getProcessInfoc                 S  s   g | ]}t  |¡‘qS r   )r`   r%   rM   r   r   r   rP   r  rQ   z$get_process_info.<locals>.<listcomp>ZprocessInfor   rh   r   r   r   Úget_process_infog  s    ÿro   )Ú
__future__r   ÚenumÚtypingÚdataclassesr   Úutilr   r   r,   r1   r7   ÚEnumr<   rA   rD   rR   r`   rj   rn   ro   r   r   r   r   Ú<module>   s.   7!">!