Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/NvidiaDetector/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/NvidiaDetector/__pycache__/nvidiadetector.cpython-310.pyc
o

��fD�@s\dZddlZddlmZmZddlZddlZddlZdZGdd�de	�Z
Gdd�de�ZdS)	z* Detection tool for nVidia graphics cards �N)�Popen�PIPEz)/usr/share/ubuntu-drivers-common/obsoletec@seZdZdZdS)�NoDatadirErrorz4Exception thrown when no modaliases dir can be foundN)�__name__�
__module__�__qualname__�__doc__�r	r	�?/usr/lib/python3/dist-packages/NvidiaDetector/nvidiadetector.pyr"src@sxeZdZdZddefdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�NvidiaDetectiona
    A simple class to:
      * Detect the available graphics cards
      * See what drivers support them (If they are
        NVIDIA cards). If more than one card is
        available, try to find the highest common
        driver version which supports them all.
        (READ the comments in the code for further
        details)
      * Return the recommended driver version
    NcCsbddi|_||_||_|�|�|_|��|��|��|��|r)|�	�dSt
|���dS)a�
        printonly = if set to None will make an instance
                    of this class return the selected
                    driver.
                    If set to True it won't return
                    anything. It will simply and print
                    the choice.

        verbose   = if set to True will make the methods
                    print what is happening.
        �currenti�N)� _NvidiaDetection__driver_aliases�	printonly�verbose�getObsoletePackages�oldPackages�	detection�getData�getCards�removeUnsupported�printSelection�print�selectDriver)�selfrr�obsoleter	r	r
�__init__3s
zNvidiaDetection.__init__cCs(|j��D]\}}||kr|SqdS)z7Get the name of a driver from its corresponding integerN)r
�items)r�value�k�vr	r	r
�__get_name_from_valueQs
�z%NvidiaDetection.__get_name_from_valuecCs:|j�|�}|dur|�d�rt|�dd��}t|�}|S)z2Get the integer associated to the name of a driverNz-server�)r
�get�endswith�int�replace)r�namerr	r	r
�__get_value_from_nameXs
z%NvidiaDetection.__get_value_from_namecCsDg}zdd�t|���D�}dd�|D�}W|Sty!Y|Sw)z.Read the list of obsolete packages from a filecSsg|]}|���qSr	)�strip��.0�xr	r	r
�
<listcomp>esz7NvidiaDetection.getObsoletePackages.<locals>.<listcomp>cSsg|]}|dkr|�qS)r!r	r)r	r	r
r,fs)�open�	readlines�IOError)rr�tempListr	r	r
ras��z#NvidiaDetection.getObsoletePackagescCs�g|_tddgtdd�}|��d�d�}t�d�}t�d�}|D]M}|�|�}|�|�}|rN|�d	��	��
�}|�d
��	��
�}	|d|	}
|j�|
�q!|rn|�d	��	��
�}|�d
��	��
�}	|d|	}
|j�|
�q!dS)
z^
        Detect the models of the graphics cards
        and store them in self.cards
        �lspciz-nT��stdout�universal_newlinesr�
z6.*03(80|0[0-2]): *(?P<vendor>.+):(?P<device>.+) \(.+\)z/.*03(80|0[0-2]): *(?P<vendor>.+):(?P<device>.+)�vendor�device�:N)�cardsrr�communicate�split�re�compile�match�groupr(�lower�append)r�p1�p�indentifier1�indentifier2�line�m1�m2�id1�id2�idr	r	r
rks(




��zNvidiaDetection.detectionc
Cs�i|_t�d�}t�d�}t��D]�}|j�d�r(d|jvs(d|jvs(d|jvr)qz|jjd}Wnt	t
fy<Yqw|�|j�}|rK|�d�}n	t
�d	|j�q|�|�}zK|r�||�d
�dd��dd
�}|�d�D]2}|�|���}	|	s�t
�d|j|f�qp|	�d���}
|	�d���}|j�|g��|
d|�qpWqty�t
�d|j|f�Yqwt|j���dkr�tj��td�dSdS)zi
        Get the data from the modaliases for each driver
        and store them in self.drivers
        zpci:v0000(.+)d0000(.+)svz5nvidia(?:\-driver|)\-([0-9]+)(:?\-server|)(:?\:i386|)�nvidia-�updates�experimentalr�
Modaliases�z/%s package has unexpected name scheme. Skipping�(N�)r!�,z&Package %s has unexpected modalias: %s�r8z*Package %s has invalid modalias header: %sr�none)�driversr<r=�apt�Cacher&�
startswith�	candidate�record�KeyError�AttributeErrorr>r?�logging�error�%_NvidiaDetection__get_value_from_name�findr%r;�lstripr@�
setdefaultrA�
ValueError�len�keys�sysr3�flushr)r�vendor_product_re�
package_re�package�m�
package_match�stripped_package_name�driver_version�alias�vpr6�productr	r	r
r�s^




��
�
����
�zNvidiaDetection.getDatacCs�i|_g|_	|jD]}|d|�d��dkr(|jr"td|d�|j�|�q
t|jdd�|_		|jD]4}d}|j	D] }||j|vr\d}|jrRtd	||f�|j�
|g��|�q<|si|j�
|g��d
�q5d
S)z�
        See if the detected graphics cards are NVIDIA cards.
        If they are NVIDIA cards, append them to self.nvidiaCards
        rr8�10dezNVIDIA card found (rRT��reverseFzCard %s supported by driver %sN)�driversForCards�nvidiaCardsr9rarrrA�sortedrV�orderedListrc)r�card�	supported�driverr	r	r
r�s0
�
	
���zNvidiaDetection.getCardscCs\g}|jD]}d|j|vr|�|�q|D]}|jr!td|�|j�|�|j|=qdS)zf
        Remove unsupported cards from self.nvidiaCards and from
        self.driversForCards
        NzRemoving unsupported card )rvrArrrw�remove)r�unsupportedCardsrz�unsupportedr	r	r
r�s

�
�z!NvidiaDetection.removeUnsupportedc
Cs�t|j�}|dkr�|dkru	i}|jD]}|j|D]}|�|d�||d7<qqt|dd�}	g}|D]
}|||krD|�|�q7t|�dkrc	|jdd�|d}|jrb|jsbt	d|�n-	|d}|jrt|jstt	d|�n	|jt
|j���dd}|jr�|js�t	d|�	|�|�}	|	dur�|dkr�d	p�d
t
|	�}|S|dkr�d	p�d
t
|�}|S	|jr�t	d�d}|S)zZ
        If more than one card is available, try to get the highest common driver
        rrPTrtzRecommended NVIDIA driver: zRecommended NVIDIA driver: %dNi�znvidia-driver-rLzNo NVIDIA package to install)rerwrvrcrxrA�sortrrr�listrf�%_NvidiaDetection__get_name_from_value�str)
r�cardsNumber�
occurrencerz�drv�occurrences�
candidatesr|�choice�driver_namer	r	r
rsZ
	
�
���
�	�zNvidiaDetection.selectDriverc		Cs�	g}g}tddgtdd�}|��d}|�d�}|D]}|�d�dkr.|�|�d	�d�qt|t�rPz|�|�r>	W|SW|St	yO|�|�Y|Sw|D]}z|�|�r[	WqRt	yj|�|�YqRw|S)
z�
        USAGE:
            * pkglist is the list of packages  you want to check
            * use lists for one or more packages
            * use a string if it is only one package
            * lists will work well in both cases
        �dpkgz--get-selectionsTr2rr5z	install����	)
rrr:r;rarA�
isinstancer��indexrd)	r�pkglist�lines�notinstalledrBrC�crF�pkgr	r	r
�checkpkgds<
�

��	�
��zNvidiaDetection.checkpkgcCs|�|j�}t|�t|j�kS)z�
        oldPackages = a list of the names of the obsolete drivers
        notInstalled = a list of the obsolete drivers which are not
                       installed
        )r�rre)r�notInstalledr	r	r
�
getDrivers�s
zNvidiaDetection.getDriverscCsV|��}|��r |rtj��t|�dStj��td�dStj��t|�dS)z6
        Part for the kernel postinst.d/ hook
        rUN)rr�rgr3rhr)rr|r	r	r
r�s


zNvidiaDetection.printSelection)rrrr�obsoletePackagesPathrr�r`rrrrrrr�r�rr	r	r	r
r&s	
!<.^$r)
rr<�
subprocessrrrgr^rWr��	Exceptionr�objectrr	r	r	r
�<module>s

Spamworldpro Mini