DonatShell
Server IP : 180.180.241.3  /  Your IP : 216.73.216.252
Web Server : Microsoft-IIS/7.5
System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586
User : IUSR ( 0)
PHP Version : 5.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Program Files (x86)/MySQL/MySQL Workbench 6.1 CE/modules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : C:/Program Files (x86)/MySQL/MySQL Workbench 6.1 CE/modules/wb_log_reader.pyc

,2Sc@sdZddlZddlmZmZddlmZmZmZddl	m
Z
mZmZddl
mZdefdYZd	efd
YZdefdYZd
efdYZdefdYZdefdYZdefdYZdS(s
.. module:: wb_log_reader
   :synopsis: Reads and parses a log source to retrieve sets of records from it.

This module defines several classes to handle MySQL server logs. It supports logs
stored in the database as well as logs stored in files.

All of the defined classes adhere to a common interface defining and implementing
these public attributes and methods:

Attributes:

    column_specs (tuple):  Specifies each field in the log entries. The elements
            of this tuple are also tuples having the form
            (column_name, column_widh, [column_table_name])
            where:
                column_name (str):  A human readable name for the column. Frontend
                                    code should use this name wherever a column
                                    title is needed.
                column_width (int): The recommended with of the column
                column_table_name (str):  (Optional) the name of the field referred
                                          by this column in the log table for DB logs

    partial_support:        False if the log source is fully supported or a
                            string explaining the limitations regarding the implemented
                            log source reader class otherwise.

Methods:

    has_previous():    Returns True if there are older entries that can be
                       retrieved and False otherwise.

    has_next():        Returns True if there are newer entries that can be
                       retrieved and False otherwise.

    first():           Returns a list of the first (oldest) records in the log.
                       Each element in this list represents a single log entry
                       and is also a list whose elements are the values for the
                       columns defined in `column_specs`.

    last():            The same as `first()` but the records returned are the
                       newest ones.

    previous():        Returns the records that precede the last retrieved
                       records. Before calling it you should verify that
                       `has_previous()` returns True.

    next():            Returns the records that follow the last retrieved
                       records. Before calling it you should verify that
                       `has_next()` returns True.

    current():         Returns the last retrieved records.

    range_text():      Returns a string that gives an indication of the position
                       of the current records in the existent log set (if
                       available). E.g. 'Records 1..50 of 145'


    refresh():         After calling this function the log reader should be able
                       to manage new log entries that were added since the last
                       call to this function or since the creation of the log
                       reader object. This function doesn't return anything.

If it is not possible to read the log entries, the class should raise an
exception with a descriptive message to let the user know the reasons of
the failure.

Current limitations:
----------------------

* No remote server support for logs stored in files.

* Cannot read files that aren't readable by the user running Workbench.

iN(tlog_infot	log_error(tSudoTailInputFiletLocalInputFilet
SFTPInputFile(tLogFileAccessErrort
ServerIOErrortInvalidPasswordError(tserver_os_pathtBaseQueryLogReadercBszeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZRS(
so
    The base class for logs stored in a database.

    **This is not intended for direct instantiation.**
    cCs||_d|_||_||_||_t|_d|_|j	d|_
t|j|j
d|_g|D]}|d^qu|_
dS(sConstructor

        :param ctrl_be:  Control backend instance to make queries
        :param log_table: The name of the table where the log entries are stored
        :type log_table: str
        :param column_specs: Column definitions as explained in the module docstring
        :type column_specs: tuple
        :param ordering_column: The index for the column in `column_specs` that stores
                                the timestamp of the log entries
        :type ordering_column: int
        ii2iN(t	log_tabletNonetlog_filetctrl_betcolumn_specstordering_columntFalsetpartial_supportttotal_counttrefresht
show_counttmaxt
show_starttcolnames(tselfR
R
RRtcolspec((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyt__init__ns							
	cCs
|jdkS(Ni(R(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pythas_previousscCs|j|jdkS(Ni(RR(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pythas_nextscCs
|jS(N(t_query_records(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pytcurrentscCs&t|j|jd|_|jS(Ni(RRRR(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pytpreviousscCs)t|j|j|j|_|jS(N(tminRRRR(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pytnextscCsd|_|jS(Ni(RR(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pytfirsts	cCs&t|j|jd|_|jS(Ni(RRRRR(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pytlastscCsd|jS(Ns
%d records(R(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyt	size_textscCs-d|jt|j|j|j|jfS(NsRecords %d..%d of %d(RR RR(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyt
range_texts	cCs|y|jjd|j}Wn#tk
rB}td|nX|sW|jrftdn|jd|_dS(Ns SELECT count(*) AS count FROM %ssError fetching log contents: %ssError fetching log contentstcount(R
t
exec_queryR
t	ExceptionRtnextRowt	intByNameR(Rtresultte((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRscCsd|j|j|j|j|jf}y|jj|}Wn#tk
rd}td|nXg}|rxd|j	rg|jD]}|j
|^q}|j|qtWn|jrt
d|jn|S(Ns.SELECT * FROM %s ORDER BY %s DESC LIMIT %i, %isError fetching log contents: %ss1There were problems querying the server table %s.(R
RRRRR
R'R(RR)tstringByNametappendRtIOError(RtqueryR+R,trecordstcolnametrow((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRs"

%	(t__name__t
__module__t__doc__RRRRRR!R"R#R$R%RR(((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyR	hs												tGeneralQueryLogReadercBseZddZRS(smysql.general_logcCsDddddddf}d|_tt|j|||ddS(NtTimeit
event_timetFromixt	user_hosttThreadiPt	thread_idtServert	server_idsCommand Typetcommand_typetDetailitargumentii(sTimeiR9(R:ixR;(sThreadiPR=(sServeriPR?(sCommand TypeiPR@(RAiRB(t
detail_columntsuperR7R(RR
t
table_nameR((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRs		(R4R5R(((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyR7stSlowQueryLogReadercBseZddZRS(smysql.slow_logc
CsSddd d!d"d#d$d%d&d'd(f}d|_tt|j|||ddS()Ns
Start Timeit
start_timeR:ixR;s
Query Timet
query_times	Lock Timet	lock_times	Rows Senti2t	rows_sents
Rows Examinedt
rows_examinedtDBiPtdbsLast Insert IDtlast_insert_ids	Insert IDt	insert_ids	Server IDR?tSQLitsql_texti
i(s
Start TimeiRG(sFromixs	user_host(s
Query TimeiRH(s	Lock TimeiRI(s	Rows Senti2RJ(s
Rows Examinedi2RK(RLiPRM(sLast Insert IDi2RN(s	Insert IDi2RO(s	Server IDi2s	server_id(RPiRQ(RCRDRFR(RR
RER((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRs		(R4R5R(((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRFstBaseLogFileReadercBseZdZedZdZdZdZdZdZ	dZ
dZd	Zd
Z
dZdZd
ZdZdZRS(s
        The base class for logs stored in files unreadable to the current user.

        **This is not intended for direct instantiation.**
        c
Cs||_||_||_||_t|_|jd}t|jj}|jjj	}|r|j
r|jjd}n|j|r|n|j
|||_t}	|jjjr!t}
|jjjs~|jjjstdn|jjjstdnt}	q~n]|jjj}
|jjjs~|jjjs]tdn|jjjs~tdq~n|
rtd|j|jjd}y1t|jj|j||_|jj|_Wqtk
r}td||jj dqXns|	rStd|jt!|j|j|_|jj|_n2td	|jt"|j|_|jj|_||_#t$d
|j||_%|j|_&d
|_'dS(sConstructor

            :param ctrl_be:  Control backend instance to retrieve root password if needed
            :param log_file: The path to the log file to read from or a file like instance to
            read log entries from
            :type log_file: str/file
            :param pat: A regular expression pattern that matches a log entry
            :type pat: regular expression object
            :param chunk_size: The size in bytes of the chunks that are read from the log file
            :type chunk_size: int
            :param truncate_long_lines: Whether the log entries that are long should be abbreviated
            :type truncate_long_lines: bool
            :param append_gaps: Whether the data between the end of the record regex and the start
            of the next record regex should be added to the previous entry
            :type append_gaps: (not used)
            s "tdatadirsYou have not enabled remote administration for this server. Without it this log file cannot be shown.
                        Please enable remote administration in this server instance and try again.sRemote log files are only supported for SSH connection.
                        Please configure an SSH connection and try again.s4Will use sudo and dd to get contents of log file %s
tfilesInvalid password to sudo %s
s-Will use sftp to get contents of log file %s
s:Will use plain file access to get contents of log file %s
iN((tpattappend_gapsttruncate_long_linesR
RRtstripRtserver_profileRStis_sql_connectedtget_server_variabletisabstjoint
log_file_namettarget_is_windowstis_localtremote_admin_enabledRtuses_sshtTruetuse_sudoRtpassword_handlertget_password_forRt
server_helperRtsizet	file_sizeRRtreset_password_forRRt
chunk_sizeRtchunk_startt	chunk_endtrecord_count(
RR
RRURkRWRVtospathRStuse_sftpRdtpasswordterror((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRsf					*
	cCs
|jdkS(sH
            If there is a previous chunk that can be read.
            i(Rl(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRHscCs|j|jkS(sD
            If there is a next chunk that can be read.
            (RmRi(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRNscCsd|j|jfS(Ns%%s records starting at byte offset %s(RnRl(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyR%TscCs|j|jS(N(t_format_sizeRi(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyR$WscCs|dkrdSd
dddf}xTt|D]F\}}||dkr/d
|||dd||ddfSq/Wd
||dd|ddfS(s^
            Returns a string with a human friendly representation of a file size
            is0 Bg?tBg@tkBitMBtGBs%.1f %sii(g?Rt(g@Rug0A(g0ARvigA(gARw(t	enumerate(Rtbytestunitstidxtunit((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRsZs	.cCs&|jj|}|r"|jSdS(Ni(RUtsearchtstart(Rtdatatmatch((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyt_get_offset_to_first_recordks
cCstg}|jj|}|rN|j}|jdkrN|j|7_qNnx|r|j}||dkr|jr|ddc|||!7<n|jt|j|j}|jj||}|rQ|j	rQ|j
|dd|dd<qQqQW|ra|jr3|ddc||7<n|j	ra|j
|dd|dd<qant||_|S(sD
            Extracts the records from a chunk of data.
            iii(
RUR}R~RlRVR.tlisttgroupstendRWt_shorten_query_fieldtlenRn(RRR1tfoundRR~((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyt_parse_chunkqs,	&		%cCst|}y|d jd}Wn-tk
rR|d jdjd}nX|dkrid|nd|d}|dkr|S|d|S(	s
            Receives a query stored in a log file and prepares it for the output in
            the log viewer shortening to 256 characters and taking care of encoding issues
            isutf-8tlatin1is%d bytess%.1f KBg@s [truncated, %s total](Rtencodet
ValueErrortdecode(RRtltabbrRh((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRs
 $cCsi|jj|j|j}|j|jdkrR|j|}|j|7_nd}|j||S(s
            Returns a list with the records in the current chunk.
            Each record is a list with the values for each column of
            the corresponding log entry.
            i
i(Rt	get_rangeRlRmRkRR(RRtoffset((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRscCsE|jdkrgS|j|_td|j|j|_|jS(s
            Returns a list with the records in the previous chunk.
            Each record is a list with the values for each column of
            the corresponding log entry.
            i(RlRmRRkR(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRs
cCsK|j|jkrgS|j|_t|j|j|j|_|jS(s
            Returns a list with the records in the next chunk.
            Each record is a list with the values for each column of
            the corresponding log entry.
            (RmRiRlR RkR(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyR!s
cCsd|_|j|_|jS(sL
            Returns a list with the records in the first chunk
            i(RlRkRmR(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyR"s	cCs2td|j|j|_|j|_|jS(sL
            Returns a list with the records in the first chunk
            i(RRiRkRlRmR(R((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyR#scCsS|jj}||jkrO||_td|j|j|_|j|_ndS(s
            Checks if the log file has been updated since it was opened and if so
            reopen the file again to keep going with the changes.
            Warning: this function only supports appending to the log file.
            iN(RRhRiRRkRlRm(Rtnew_size((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRs
	(R4R5R6RcRRRR%R$RsRRRRRR!R"R#R(((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRRs W								
					tErrorLogFileReadercBs/eZdZdedZdZdZRS(sX
    This class enables the retrieval of log entries in a MySQL error
    log file.
    i@icCsd}tj|tj}tt|j|||||dtdd
ddf|_tj|d
tj|_d|_	dS(Ns^(?P<v56>(\d{2,4}-\d{1,2}-\d{2} {1,2}\d{1,2}:\d{2}:\d{2}) (\d+) \[(.*)\] (.*?))$|^(?P<v55>(\d{6} {1,2}\d{1,2}:\d{2}:\d{2}) {1,2}([^ ]*) (.*?))$|^(?P<old>(\d{2})(\d{2})(\d{2}) {1,2}(\d{1,2}:\d{2}:\d{2}) ([a-zA-Z0-9_]*?) (.*?))$RVt	TimestampiR<idtTypetDetailsis|^(?P<any>.+)$i(s	Timestampi(sThreadid(sTypeid(Ri(
tretcompiletMRDRRRRtpat2RC(RR
t	file_nameRkRWt
partial_reRU((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRs(cCsg}|jj|}|rN|j}|jdkrN|j|7_qNnxj|r|j}|j}|dr|jt|dd!n|dr|d}|jd|d |dd	!|d	d!|djfd
|d|dgnk|d
rH|jd|d|d|d|dfd
|d|dgn|jd
d
d
|dg|j	}|jj||}|rQ|j
rQ|j|dd|dd<qQqQW|r|j
r|j|dd|dd<qnt||_
|S(sD
            Extracts the records from a chunk of data.
            itv56iitv55is
20%s-%s-%s %siitiitoldi
iii
iii(RR}R~Rlt	groupdictRR.RtlstripRRWRRRn(RRR1RRtgdicttgtts((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRs4	


P
D&	%cCsutt|j}|j|jkrq|d}td|d Dsq|jt|d8_|d=qqn|S(Nicss|]}|dkVqdS(RN((t.0tf((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pys	<genexpr>!s(RDRRRmRitanyR(RR1trec((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRs

i(R4R5R6RcRRR(((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyRs	&tGeneralLogFileReadercBseZdZdedZRS(s`
    This class enables the retrieval of log entries in a MySQL general query
    log file.
    i@icCsYtjdtj}tt|j|||||d
ddd
f|_d	|_dS(NsQ^(\d{6} {1,2}\d{1,2}:\d{2}:\d{2}[\t ]+|[\t ]+)(\s*\d+)(\s*.*?)(?:\t+| {2,})(.*?)$RiR<iPsCommand TypeRAii(s	Timestampi(sThreadiP(sCommand TypeiP(sDetaili(RRRRDRRRRC(RR
RRkRWRU((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyR.s"i(R4R5R6RcR(((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyR)stSlowLogFileReadercBs eZdZdeedZRS(s]
    This class enables the retrieval of log entries in a MySQL slow query
    log file.
    i@icCsetjdtj}tt|j||||||d
ddddddf|_d|_dS(Ns(?:^|\n)# Time: (\d{6} {1,2}\d{1,2}:\d{2}:\d{2}).*?\n# User@Host: (.*?)\n# Query_time: +([0-9.]+) +Lock_time: +([\d.]+) +Rows_sent: +(\d+) +Rows_examined: +(\d+)\s*\n(.*?)(?=\n# |\n[^\n]+, Version: |$)s
Start Timeis	User@HostiPs
Query Times	Lock Times	Rows Sents
Rows ExaminedRAii(s
Start Timei(s	User@HostiP(s
Query TimeiP(s	Lock TimeiP(s	Rows SentiP(s
Rows ExaminediP(sDetaili(RRtSRDRRRRC(RR
RRkRWRVRU((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyR@s%i(R4R5R6RcRR(((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyR;s(R6Rt
workbench.logRRtwb_server_managementRRRt	wb_commonRRRtworkbench.utilsRtobjectR	R7RFRRRRR(((sLC:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE\modules\wb_log_reader.pyt<module>\s`
J

Anon7 - 2022
AnonSec Team