Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/libcloud/compute/__pycache__/ssh.cpython-39.pyc
Ðазад
a q�h�[ � @ sF d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dZzdd l Z d ZW n e yr Y n0 dd lZdd lZdd l Z dd lZdd lZddlmZ ddlmZ dd lmZ ddlmZ ddlmZ g d�ZdZG dd� de�ZG dd� de�ZG dd� de�Z G dd� de�Z!G dd� de�Z"e Z#e�sBe"Z#d S )z. Wraps multiple ways to communicate over SSH. � )�Type)�Optional)�Tuple)�List)�Union)�castFNT)�split)�join)�ExtraLogFormatter)�StringIO)�b)� BaseSSHClient�ParamikoSSHClient�ShellOutSSHClient�SSHCommandTimeoutErrorzahttps://libcloud.readthedocs.io/en/latest/compute/deployment.html#supported-private-ssh-key-typesc s2 e Zd ZdZd � fdd� Zdd� Zdd� Z� ZS ) r zB Exception which is raised when an SSH command times out. Nc s8 || _ || _|| _|| _d| | _tt| ��| j� d S )Nz#Command didn't finish in %s seconds)�cmd�timeout�stdout�stderr�message�superr �__init__)�selfr r r r �� __class__� ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/libcloud/compute/ssh.pyr C s zSSHCommandTimeoutError.__init__c C s d| j | jf S )Nz.<SSHCommandTimeoutError: cmd="%s",timeout=%s)>)r r �r r r r �__repr__M s �zSSHCommandTimeoutError.__repr__c C s | � � S �N)r r r r r �__str__Q s zSSHCommandTimeoutError.__str__)NN)�__name__� __module__�__qualname__�__doc__r r r � __classcell__r r r r r ? s r c @ sN e Zd ZdZddd�Zdd� Zdd d�Zdd � Zddd�Zdd� Z dd� Z dS )r zM Base class representing a connection over SSH/SCP to a remote node. � �rootNc C sL |dur$d}t �|t� |s |n|}|| _|| _|| _|| _|| _|| _dS )a� :type hostname: ``str`` :keyword hostname: Hostname or IP address to connect to. :type port: ``int`` :keyword port: TCP port to communicate on, defaults to 22. :type username: ``str`` :keyword username: Username to use, defaults to root. :type password: ``str`` :keyword password: Password to authenticate with or a password used to unlock a private key if a password protected key is used. :param key: Deprecated in favor of ``key_files`` argument. :type key_files: ``str`` or ``list`` :keyword key_files: A list of paths to the private key files to use. NzYYou are using deprecated "key" argument which has been replaced with "key_files" argument) �warnings�warn�DeprecationWarning�hostname�port�username�password� key_filesr ) r r+ r, r- r. �keyr/ r r r r r r Z s zBaseSSHClient.__init__c C s t d��dS )z� Connect to the remote node over SSH. :return: True if the connection has been successfully established, False otherwise. :rtype: ``bool`` z+connect not implemented for this ssh clientN��NotImplementedErrorr r r r �connect� s �zBaseSSHClient.connect�wc C s t d��dS )a� Upload a file to the remote node. :type path: ``str`` :keyword path: File path on the remote node. :type contents: ``str`` :keyword contents: File Contents. :type chmod: ``int`` :keyword chmod: chmod file to this after creation. :type mode: ``str`` :keyword mode: Mode in which the file is opened. :return: Full path to the location where a file has been saved. :rtype: ``str`` z'put not implemented for this ssh clientNr1 )r �path�contents�chmod�moder r r �put� s �zBaseSSHClient.putc C s t d��dS )a Delete/Unlink a file on the remote node. :type path: ``str`` :keyword path: File path on the remote node. :return: True if the file has been successfully deleted, False otherwise. :rtype: ``bool`` z*delete not implemented for this ssh clientNr1 )r r5 r r r �delete� s �zBaseSSHClient.deletec C s t d��dS )z� Run a command on a remote node. :type cmd: ``str`` :keyword cmd: Command to run. :return ``list`` of [stdout, stderr, exit_status] z'run not implemented for this ssh clientNr1 �r r r r r r �run� s �zBaseSSHClient.runc C s t d��dS )z� Shutdown connection to the remote node. :return: True if the connection has been successfully closed, False otherwise. :rtype: ``bool`` z)close not implemented for this ssh clientNr1 r r r r �close� s �zBaseSSHClient.closec C sH t �d�}t�d�}|rDt �|�}|�t� � |�|� |�t j � |S )Nzlibcloud.compute.sshZLIBCLOUD_DEBUG) �logging� getLogger�os�getenv�FileHandler�setFormatterr � addHandler�setLevel�DEBUG)r �loggerr5 �handlerr r r �_get_and_setup_logger� s z#BaseSSHClient._get_and_setup_logger)r&