403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.156
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/influxdb/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/influxdb/__pycache__/_dataframe_client.cpython-310.pyc
o

-7�_�K�@s�dZddlmZddlmZddlmZddlmZddlZddlmZddl	Z
ddlZdd	l
mZdd
lmZdd�Zd
d�ZGdd�de�ZdS)zDataFrame client for InfluxDB.�)�absolute_import)�division)�print_function)�unicode_literalsN)�defaultdict�)�InfluxDBClient��_escape_tagcCs<|}|dkr	d}n
|dkrd}n|dkrd}|dvsJ�|S)N�m�ms�u�us�n�ns)�srrr�)�time_precision�unitrr�</usr/lib/python3/dist-packages/influxdb/_dataframe_client.py�_pandas_time_unitsrcCs|�dd��S)NcSst|�S)Nr	)�vrrr�<lambda> sz'_escape_pandas_series.<locals>.<lambda>)�apply�rrrr�_escape_pandas_seriessrcs�eZdZdZe�d�Z									d�fdd�	Z									
			d�fdd
�	Zddd�Z	e
				ddd��Z					ddd�Ze
ddd��Z
d dd�Z�ZS)!�DataFrameClientaDataFrameClient instantiates InfluxDBClient to connect to the backend.

    The ``DataFrameClient`` object holds information necessary to connect
    to InfluxDB. Requests can be made to InfluxDB directly through the client.
    The client reads and writes from pandas DataFrames.
    z1970-01-01 00:00:00.000+00:00N�linec
s |durg}|durg}|	rett�t|�t|	���}t|�D]C}
|
|	}|
d|	}|
dkrC|j|j||���||||||d�}n|j	|j||���|||||d�}t
t|�j|||||
d�qdS|
dkrv|j|||||||d�}n|j	||||||d�}t
t|�j|||||
d�dS)	a�Write to multiple time series names.

        :param dataframe: data points in a DataFrame
        :param measurement: name of measurement
        :param tags: dictionary of tags, with string key-values
        :param tag_columns: [Optional, default None] List of data tag names
        :param field_columns: [Options, default None] List of data field names
        :param time_precision: [Optional, default None] Either 's', 'ms', 'u'
            or 'n'.
        :param batch_size: [Optional] Value to write the points in batches
            instead of all at one time. Useful for when doing data dumps from
            one database to another or when doing a massive write operation
        :type batch_size: int
        :param protocol: Protocol for writing data. Either 'line' or 'json'.
        :param numeric_precision: Precision for floating point values.
            Either None, 'full' or some int, where int is the desired decimal
            precision. 'full' preserves full precision for int and float
            datatypes. Defaults to None, which preserves 14-15 significant
            figures for float and all significant figures for int datatypes.
        Nrr)�measurement�global_tagsr�tag_columns�
field_columns�numeric_precision)r�tagsrr r!)�protocolT)rrr r!rr")
�int�math�ceil�len�float�range�_convert_dataframe_to_lines�iloc�copy�_convert_dataframe_to_json�superr�write_points)�self�	dataframerr#r r!r�database�retention_policy�
batch_sizer$r"�number_batches�batch�start_index�	end_index�points��	__class__rrr0-sz �	�
��	�
�zDataFrameClient.write_points��TFr�GETc
sht||||||||
|	d�	}
tt|�j|fi|
��}|�����d�r2t|�dkr0|j|||d�SiS|S)a�
        Query data into a DataFrame.

        .. danger::
            In order to avoid injection vulnerabilities (similar to `SQL
            injection <https://www.owasp.org/index.php/SQL_Injection>`_
            vulnerabilities), do not directly include untrusted data into the
            ``query`` parameter, use ``bind_params`` instead.

        :param query: the actual query string
        :param params: additional parameters for the request, defaults to {}
        :param bind_params: bind parameters for the query:
            any variable in the query written as ``'$var_name'`` will be
            replaced with ``bind_params['var_name']``. Only works in the
            ``WHERE`` clause and takes precedence over ``params['params']``
        :param epoch: response timestamps to be in epoch format either 'h',
            'm', 's', 'ms', 'u', or 'ns',defaults to `None` which is
            RFC3339 UTC format with nanosecond precision
        :param expected_response_code: the expected status code of response,
            defaults to 200
        :param database: database to query, defaults to None
        :param raise_errors: Whether or not to raise exceptions when InfluxDB
            returns errors, defaults to True
        :param chunked: Enable to use chunked responses from InfluxDB.
            With ``chunked`` enabled, one ResultSet is returned per chunk
            containing all results within that chunk
        :param chunk_size: Size of each chunk to tell InfluxDB to use.
        :param dropna: drop columns where all values are missing
        :param data_frame_index: the list of columns that
            are used as DataFrame index
        :returns: the queried data
        :rtype: :class:`~.ResultSet`
        )	�params�bind_params�epoch�expected_response_code�raise_errors�chunkedr3�method�
chunk_size�SELECTr)�data_frame_index)	�dictr/r�query�strip�upper�
startswithr(�
_to_dataframe)r1rJr?r@rArBr3rCrDrFrE�dropnarH�
query_args�resultsr;rrrJ�s$.�	�zDataFrameClient.queryc
stt�}t|t�rt|j|�fdd�tt|��D��S|��D]N\}}|\}}|dur.|}n
|tt	|����f}t
�|�}	t
�|	j
�|	_
|rN|	j|dd�n|	jddd�|	jjdurb|	j�d�|	_d|	j_||�|	�q|��D]\}}t
�|���}	�r�|	jdddd	�|	||<qr|S)
Ncsg|]}��qSrr)�.0�_�rOrr�
<listcomp>�sz1DataFrameClient._to_dataframe.<locals>.<listcomp>T)�inplace�time�UTC�allr)�how�axisrV)r�list�
isinstance�maprNr*r(�items�tuple�sorted�pd�	DataFrame�to_datetimerW�	set_index�index�tzinfo�tz_localize�name�append�concat�
sort_indexrO)
r1�rsrOrH�result�key�datarir#�dfrrTrrN�s2
�

zDataFrameClient._to_dataframecsXt|tj�std�t|����t|jtj�s!t|jtj�s!td��|dur'|ng}|dur/|ng}�dur7�ni�|sGt	t
|j��t
|���}t|jtj�sUt�
|j�|_|jjdurb|j�d�|_|j�d�|_|�d�}dddd	d
dd��|d��|s���fd
d�t|j||���D�}|S���fdd�t|j||�d�||���D�}|S)N�%Must be DataFrame, but type was: {0}.�4Must be DataFrame with DatetimeIndex or PeriodIndex.rX�str�objectr�@�@���.A�e��A����+B�Ņ1�B�rr
rrr�hcsHg|] \}\}}�|�tjtjgtj�����t�|j��d��qS))r�fieldsrW)�replace�np�inf�nanrO�to_dict�int64�value)rR�tsrS�rec)r�precision_factorrrrUs
���z>DataFrameClient._convert_dataframe_to_json.<locals>.<listcomp>c	sdg|].\}}\}}�tt|���t�����|�tjtjgtj�����t�	|j
��d��qS))rr#r}rW)rIr\r_r~rr�r�rOr�r�r�)rRr��tagrSr��rr�r#rrrU,s����record)r]rbrc�	TypeError�format�typerf�PeriodIndex�
DatetimeIndexr\�set�columns�
differencerdrgrh�astype�get�zip�iterrowsr�)r2rr#r r!rr:rr�rr.�s\
���
��	
��
��
z*DataFrameClient._convert_dataframe_to_jsoncCs�|jdd���}t|�dkrgSt|tj�std�t|����t|j	tj
�s1t|j	tj�s1td��|jdd�|j
D�d�}t�|j
�}|durIg}|durOg}|durUi}t|�r]t|�ng}t|�rgt|�ng}|rw|swt||�|��}|s�t||�|��}d	d
ddd
dd��|d	�}	t|j	tj
�r�|j	��j�tj�|	�tj��t�}
nt�|j	�j�tj�|	�tj��t�}
|r�|r�|D]
}||||<|�|�q�||}|�d�}|jd	d�}|j||dd�}|�dd��}
|
jd	d�}
~n|�rd�dd�t |�!��D��}tj||j	d�}
nd}
||�"tj#tj#gtj$�}t�%|�}|j||dd�}|j
jd�&�|}d||j
d	d�||j
d	d�<d||<|jd	d��'dd��}~t(|�}||
d|d|
�&�}|S)NrY)rZrrrrscSsi|]}|t|��qSrr	)rR�itemrrr�
<dictcomp>Qsz?DataFrameClient._convert_dataframe_to_lines.<locals>.<dictcomp>)r�rrvrwrxryrzr{�)r[r�)�datatypecs�fdd��D�S)Ncs&g|]}|rd�jd|nd�qS)�,�=r�)ri)rRrrrrrU�s&zQDataFrameClient._convert_dataframe_to_lines.<locals>.<lambda>.<locals>.<listcomp>rrrrrr�sz=DataFrameClient._convert_dataframe_to_lines.<locals>.<lambda>cSs,g|]\}}|dvrd�|t|��nd�qS))Nr�z,{}={}r�)r�r
)rR�krrrrrU�s���z?DataFrameClient._convert_dataframe_to_lines.<locals>.<listcomp>)rf�fieldr�r�cSs
|�d�S)Nr�)�lstrip)�xrrrr�s
� ))rOr-r(r]rbrcr�r�r�rfr�r��renamer��Seriesr\�isinr��to_timestamp�valuesr�rr�rtrdrj�fillnarl�_stringify_dataframer�sum�joinrar_r~r�r��isnull�tolistr^r
)r1r2rr!r rrr"�
column_seriesr�rWr��tag_dfr#�
tag_string�field_df�nansr}r:rrrr+;s�	
���
�
���
����
��
��
�$z+DataFrameClient._convert_dataframe_to_linesr�cCsb|��}|jdgd�j}|jdgd�j}|dur|�t�}nj|dkrG|jdgd�j}|j|j�|�}||�t�||<||�t�||<nAt|t	�r�|jdgd�j}|j|j�|�}||�
|�||<|dkr~||�t�||<||�t�||<n
|�t�}ntd��|dkr�||d	7<d
||d
||<n	|dkr�|�t
�}|j�t�|_|S)N�integer)�includeru�full�floating�
zInvalid numeric precision.r��i�"r�)r-�
select_dtypesr�r�rtr��applymap�reprr]r%�round�
ValueErrorrr)�dframer"r��int_columns�string_columns�
float_columns�nonfloat_columnsrrrr��sT��
�
��
���
z$DataFrameClient._stringify_dataframercCsn||j��}|dkr|dS|dkr|dS|dkr|S|dkr%|dS|dkr-|d	S|d
kr5|dSdS)Nr|ir�<rrrvr
rwrrx)�EPOCH�
total_seconds)r1�datetimer�secondsrrr�_datetime_to_epoch�s�z"DataFrameClient._datetime_to_epoch)	NNNNNNNrN)NNNr=NTFrr>TN)TN)NNNN)NNNNN)r�r)�__name__�
__module__�__qualname__�__doc__rb�	Timestampr�r0rJrN�staticmethodr.r+r�r��
__classcell__rrr;rr#sR
�e�
A �L
�u3r)r��
__future__rrrrr&�collectionsr�pandasrb�numpyr�clientr�
line_protocolr
rrrrrrr�<module>s

Youez - 2016 - github.com/yon3zu
LinuXploit