Mini Shell

Direktori : /lib/python3.6/site-packages/orca/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/orca/__pycache__/debug.cpython-36.opt-1.pyc

3

�2[C�
@sJdZdZdZdZdZdZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZdZ
d	Zd
ZdZdZd
ZdZdZdZeZdZeZdZdZdgZddddddddddg
ZgZgZgZdZ dZ!dd�Z"dd �Z#d<d"d#�Z$d=d$d%�Z%d>d&d'�Z&d?d(d)�Z'd@d*d+�Z(dAd,d-�Z)ddl*Z*d.d/�Z+d0d1�Z,d2d3�Z-d4d5�Z.d6d7�Z/d8d9�Z0d:d;�Z1dS)Bz�Provides debug utilities for Orca.  Debugging is managed by a debug
level, which is held in the debugLevel field.  All other methods take
a debug level, which is compared to the current debug level to
determine if the content should be output.z$Id$z
$Revision$z$Date$z-Copyright (c) 2005-2008 Sun Microsystems Inc.ZLGPL�Ni'i�i�i i�iXi�i�FZorca�	traceback�	linecacheZlocale�gettextZlogging�UserDictZ	encodings�	posixpath�genericpath�reTcCs(|tkr$t|�tjdt�t|�dS)zrPrints out information regarding the current exception.

    Arguments:
    - level: the accepted debug level
    �dN)�
debugLevel�printlnr�	print_exc�	debugFile)�level�r�/usr/lib/python3.6/debug.py�printException�srcCs*|tkr&t|�tjddt�t|�dS)zXPrints out the current stack.

    Arguments:
    - level: the accepted debug level
    Nr	)r
rr�print_stackr
)rrrr�
printStack�sr�cCs�|tkr�|jdd�}|r*dtjd�|f}tr�ytj|dg�Wq�tk
rfd}tj|dg�Yq�d}tj|dg�Yq�Xn\ytjj|dg�WnFtk
r�d}tjj|dg�Yn d}tjj|dg�YnXdS)	z�Prints the text to stderr unless debug is enabled.

    If debug is enabled the text will be redirected to the
    file debugFile.

    Arguments:
    - level: the accepted debug level
    - text: the text to print (default is a blank line)
    uz[OBJ]z%s - %sz%H:%M:%S�
z#TypeError when trying to write textz#Exception when trying to write textN)	r
�replace�timeZstrftimer
�
writelines�	TypeError�sys�stderr)r�text�	timestamprrrr�s*rcCs�|tkrdStj�}|d|d}}|d}tj|�}x(t|jj��D]\}}t|�|j|<qHWtjtj	|�dd�}	dtj
|d�|d|dtj
|d�|d|	f}
d	|
d
|f}t|d|�dS)zmPrints the return result, along with information about the
    method, arguments, and any errors encountered.N��r�'rz"CALL:   %s.%s (line %s) -> %s.%s%s�z%s
%s %szRESULT:z%s)r
�inspect�stack�getargvalues�list�locals�items�strrZformatargvaluesZ
getmodulenamer)r�resultr#Zcurrent�prev�frame�args�key�valueZfArgsZ
callString�stringrrr�printResult�s
r0cCs\trtj|j�rdSt|t�}d|j|j|j|jf}t|||�|rXt|d||�dS)atPrints out an Python Event object.  The given level may be
    overridden if the eventDebugLevel is greater.  Furthermore, only
    events with event types matching the eventDebugFilter regular
    expression will be printed.

    Arguments:
    - level: the accepted debug level
    - event: the Python Event to print
    - sourceInfo: additional string to print out
    NzOBJECT EVENT: %s (%d, %d, %s)z             %s)	�eventDebugFilter�match�type�max�eventDebugLevelZdetail1Zdetail2Zany_datar)r�eventZ
sourceInforrrrr�printObjectEvent�s
r7cCstt|t�||�dS)z�Prints out an input event.  The given level may be overridden
    if the eventDebugLevel (see setEventDebugLevel) is greater.

    Arguments:
    - level: the accepted debug level
    - string: the string representing the input event
    N)rr4r5)rr/rrrr�printInputEvents	r8cCs&|tkr"|r"t|t||||�|�dS)a:Lists the details of the given accessible with the given
    indentation.

    Arguments:
    - level: the accepted debug level
    - indent: a string containing spaces for indentation
    - accessible: the accessible whose details are to be listed
    - includeApp: if True, include information about the app
    N)r
r�getAccessibleDetails)r�indentZ
accessible�
includeApprrrr�printDetails!sr<c4Cs�|tkrdS|rzy|j�}Wn|d}d}Yq~X|rpy|d|j}Wqxttfk
rl|d}YqxXq~|d}n|}y|j�}Wn|d7}YnXy|j�}Wn|d7}g}YnXg}x|D]}	|jtj	|	��q�Wd	j
|�}
y|j�}Wn|d
7}d}YnX|�rRg}x"|D]}
|jtj|
j
����q(Wd	j
|�}nd}yd	j
tjj|��}Wnd}YnXy(|d|j�p�d
|j�|
|||f7}Wn|d7}YnX|S)z�Returns a string, suitable for printing, that describes the
    given accessible.

    Arguments:
    - indent: A string to prefix the output with
    - includeApp: If True, include information about the app
                  for this accessible.
    rzapp=(exception getting app) Nzapp.name='%s' z$app.name='(exception getting name)' z	app=None z(exception getting state set)z(exception getting states)� z (exception getting relation set)z"(exception calling listInterfaces)z@name='%s' role='%s' state='%s' 
%srelations='%s' interfaces='%s'�Nonez(exception fetching data))r
�getApplication�name�LookupError�RuntimeErrorZgetStateZ	getStates�append�pyatspiZ
stateToString�joinZgetRelationSetZrelationToStringZgetRelationTypeZutilsZlistInterfacesZgetRoleName)rZaccr:r;�appr/ZstateSetZstatesZ
state_strings�stateZstate_stringZ	relationsZrelation_stringsZrelationZ
rel_stringZiface_stringrrrr91sf








r9c	CsVd\}}y|jd}|jd}WnYn"X|jd�sB|jd�rN|dd�}||fS)N�__file__�__name__z.pycz.pyor)NN���)�	f_globals�endswith)r+�filename�modulerrr�_getFileAndModule�s
rOc
Cs�ts
tStj}trPtjp |j�}ytjp0|j�}WnYnX|jtkrPdStrd|j�tkrddSt	r�dd�t
tjjt	�D�r�dSdS)NFcSsg|]}|r|�qSrr)�.0�xrrr�
<listcomp>�sz"_shouldTraceIt.<locals>.<listcomp>T)
�objEvent�TRACE_ONLY_PROCESSING_EVENTS�source�
TRACE_APPSZhost_applicationr?r@�TRACE_ROLESZgetRole�TRACE_EVENTS�mapr3�
startswith)ZeventSourcerFrrr�_shouldTraceIt�s"
r[cCs|t�s
dSt|�\}}|o|s"tS|tkr.tStrH|jd�dtkrHtS|dkrTtS|j}tj||�j	�}d|||f}|dk�r4t
j|�}dd	�|dD�}	ytt
|d
j|	��}
WnPtk
�rt|	�dko�t|	dt��r�tt
|d
j|	d��}
ntSYnXx*t|	�D]\}}|d||
|f7}�qW|j�j�}
|
�rn|
ddk�rn|dk�rbtSd
||f}tt|�tS)a�Line tracing utility to output all lines as they are executed by
    the interpreter.  This is to be used by sys.settrace and is for 
    debugging purposes.
   
    Arguments:
    - frame: is the current stack frame
    - event: 'call', 'line', 'return', 'exception', 'c_call', 'c_return',
             or 'c_exception'
    - arg:   depends on the event type (see docs for sys.settrace)
    N�.r�call�line�returnzTRACE %s:%s: %scSsg|]}|dkr|�qS)�selfr)rPrQrrrrR�sztraceit.<locals>.<listcomp>r!rz
  ARG %s=%sz%s (rv: %s))r]r^r_)r[rO�traceit�TRACE_IGNORE_MODULES�
TRACE_MODULES�split�f_linenor�getline�rstripr"r$r%rY�getr�len�
isinstance�	enumerate�stripr�	LEVEL_ALL)r+r6�argrMrN�linenor^�outputZargvals�keys�values�ir-ZlineElementsrrrra�s@




racCsBtjddddt|�g�}|jd�jd�}ttdd�|��}t|�S)	NZlsofz-wz-Ffz-pzUTF-8rcSs |o|ddko|dd�j�S)Nr�fr)�isdigit)�srrr�<lambda>�sz getOpenFDCount.<locals>.<lambda>)�
subprocessZcheck_outputr(�decoderdr%�filterri)�pidZprocs�filesrrr�getOpenFDCount�sr}c	CsDy"tjd|�}|j�}|j�Wnd}YnX|jdd�}|S)Nzcat /proc/%s/cmdlinez(Could not obtain cmdline)�r=)�os�popen�read�closer)r{�openFileZcmdlinerrr�
getCmdline�s
r�cCs:tjd|dtjd�j}|j�}|j�dd�|j�D�S)Nzpgrep %sT)�shell�stdoutcSsg|]}t|��qSr)�int)rP�prrrrR�szpidOf.<locals>.<listcomp>)rx�Popen�PIPEr�r�r�rd)ZprocNamer��pidsrrr�pidOf�s
r�c	Cs�tjjd�}ttd|j�xpt|�D]d\}}|j�}t|�}t	|�}y
|j
}Wnd}YnX|dkrnd}ttd|d||||f�q&Wdg}x\|D]T}t|�}|s�ttd	|�q�x2|D]*}t|�}t	|�}ttd
||||f�q�Wq�WdS)NrzINFO: Desktop has %i apps:zERROR: Could not get namerzWARNING: Possible hangz)%3i. %s (pid: %s) %s file descriptors: %irZapportzINFO: no pid for %sz*INFO: %s (pid: %s) %s file descriptors: %i)rDZRegistryZ
getDesktoprrmZ
childCountrkZget_process_idr�r}r@r�)	ZdesktoprsrFr{�cmdZfdsr@Z	otherAppsr�rrr�examineProcesses�s2



r�)rF)N)NF)F)TF)rT)2�__doc__Z__id__�__version__Z__date__Z
__copyright__Z__license__r"rrrrDrxrZ	LEVEL_OFFZLEVEL_SEVEREZ
LEVEL_WARNINGZ
LEVEL_INFOZLEVEL_CONFIGURATIONZ
LEVEL_FINEZLEVEL_FINERZLEVEL_FINESTrmr
r
r5r1ZdebugEventQueuercrbrVrXrWrTrSrrrr0r7r8r<r9rrOr[rar}r�r�r�rrrr�<module>sf	


"




P
4