-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/trace.pyc


=)Oc@@sdZddlmZddlZddlZddlZddlZddlmZee	dddl
Z
ee	ddada
dae
jZejdZdZd	Zd
ZdZdZd
ZdZdZdZdddZdZdZdZdZ e!dZ"e!dZ#dZ$dZ%de!dZ&d.Z'de!dZ(d Z)e*d!Z+d"Z,d#Z-dd$Z.d%Z/d&Z0d'Z1d(ej2fd)YZ3d*e4fd+YZ5d,e5fd-YZ6dS(/s|Messages and logging.

Messages are supplied by callers as a string-formatting template, plus values
to be inserted into it.  The actual %-formatting is deferred to the log
library so that it doesn't need to be done for messages that won't be emitted.

Messages are classified by severity levels: critical, error, warning, info,
and debug.

They can be sent to two places: to stderr, and to ~/.bzr.log.  For purposes
such as running the test suite, they can also be redirected away from both of
those two places to another location.

~/.bzr.log gets all messages, and full tracebacks for uncaught exceptions.
This trace file is always in UTF-8, regardless of the user's default encoding,
so that we can always rely on writing any message.

Output to stderr depends on the mode chosen by the user.  By default, messages
of info and above are sent out, which results in progress messages such as the
list of files processed by add and commit.  In debug mode, stderr gets debug messages too.

Errors that terminate an operation are generally passed back as exceptions;
others may be just emitted as messages.

Exceptions are reported in a brief form to stderr so as not to look scary.
BzrErrors are required to be able to format themselves into a properly
explanatory message.  This is not true for builtin exceptions such as
KeyError, which typically just str to "0".  They're printed in a different
form.
i(tabsolute_importN(tlazy_imports\
from cStringIO import StringIO
import errno
import locale
import tempfile
import traceback
sH
from bzrlib import (
    debug,
    errors,
    osutils,
    ui,
    )
tbzrcO@s!tjjtj||dS(sbOutput a note to the user.

    Takes the same parameters as logging.info.

    :return: None
    N(tuit
ui_factoryt
clear_termt_bzr_loggertinfo(targstkwargs((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytnotels

cO@s!tjjtj||dS(N(RRRRtwarning(RR	((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyRzs
cO@stj||dS(siShow an error message to the user.

    Don't use this for exceptions, use report_exception instead.
    N(Rterror(RR	((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt
show_errorscG@stdkrdSttdddk	r5tjr5dSt|trV|jd}nt|dkrg}x<|D]4}t|tr|jd}n|j|quW|t	|}n|}t
j
}d|tf}||d}tj|dS(Ntclosedtutf8is%0.3f  s
(
t_trace_filetNonetgetattrRt
isinstancetunicodetencodetlentappendttuplettimet_bzr_log_start_timetwrite(tfmtRt	real_argstargtouttnowt	timestamp((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytmutters$!
cG@st}|dkrd}n
|d}tjd|d||jj}dj|d }t|d||fdS(sPerform a mutter of fmt and args, logging the call trace.

    :param stacklevel: The number of frames to show. None will show all
        frames.
    :param fmt: The format string to pass to mutter.
    :param args: A list of substitution variables.
    itlimittfiles
is
Called from:
%sN(tStringIORt	tracebacktprint_stacktgetvaluet
splitlinestjoinR"(t
stacklevelRRtoutfR#tformatted_linestformatted_stack((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytmutter_callsites		
cC@siddl}yDtj||j}|dkr5dS|d}tj||Wntk
rddSXdS(Niiis.oldi@(tstattostST_SIZEtosutilstrenametOSError(ttrace_fnameR0tsizet	old_fname((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt_rollover_trace_maybes

cC@sVtjd}|r|Stjd}|dkrCtj}ntjj|dS(NtBZR_LOGtBZR_HOMEs.bzr.log(R3tpath_from_environRt
_get_home_dirR1tpathR*(tbzr_logthome((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt_get_bzr_log_filenamescC@sd}tatty]|t}|jd|jdkrt|jd|jd|jdn|SWn*tk
r}tjjd|fnXdS(	sOpen the .bzr.log trace file.

    If the log is more than a particular length, the old file is renamed to
    .bzr.log.old and a new file is started.  Otherwise, we append to the
    existing file.

    This sets the global _bzr_log_filename.
    cS@stjtjBtjB}xtrytj||}PWn+tk
rd}|jtj	kreqenXy'tj||tj
BtjBd}Wn+tk
r}|jtjkrqqXtj
|PqWtj|ddS(sOpen existing log file, or create with ownership and permissions

        It inherits the ownership and permissions (masked by umask) from
        the containing directory to cope better with being run under sudo
        with $HOME still set to the user's homedir.
        itati(R1tO_WRONLYtO_APPENDR3tO_TEXTtTruetopenR5terrnotENOENTtO_CREATtO_EXCLtEEXISTtcopy_ownership_from_pathtfdopen(tfilenametflagstfdte((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt_open_or_create_log_files 	
'

s
is=this is a debug log for diagnosing/reporting problems in bzr
s=you can delete or truncate this file, or include sections in
s8bug reports to https://bugs.launchpad.net/bzr/+filebug

sfailed to open trace file: %s
N(	RAt_bzr_log_filenameR9RttelltEnvironmentErrortsyststderrR(RStbzr_log_fileRR((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt
_open_bzr_logs		



cC@stjtdd}t}|d
k	rG|j|jddnt|dd}tt	j
tjddtj
}tjd	j||S(sConfigure default logging: messages to stderr and debug to .bzr.log

    This should only be called once per process.

    Non-command-line programs embedding bzrlib do not need to call this.  They
    can instead either pass a file to _push_log_file, or act directly on
    logging.getLogger("bzr").

    Output can be redirected away by calling _push_log_file.

    :return: A memento from push_log_file for restoring the log state.
    ttimezonetlocalsutf-8s
sA[%(process)5d] %(asctime)s.%(msecs)03d %(levelname)s: %(message)ss%Y-%m-%d %H:%M:%StreplacetlevelRN(R3tformat_local_dateRRZRRRt
push_log_filetEncodedStreamHandlerRWRXtget_terminal_encodingtloggingtINFOt	getLoggert
addHandler(t
start_timeRYtmementotstderr_handler((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytenable_default_loggings
				cC@st|ddtj}|dkr-d}n|jtj||tjd}|j}|j2|j||j	tjt
}|a
|t
f}d||||fS(sIntercept log and trace messages and send them to a file.

    :param to_file: A file-like object to which messages will be sent.

    :returns: A memento that should be passed to _pop_log_file to restore the
        previously active logging.
    sutf-8R^s%(levelname)8s  %(message)sRtlog_mementoN(RaRctDEBUGRtsetFormattert	FormatterRethandlersRftsetLevelR(tto_filet
log_formattdate_formattnew_handlert
bzr_loggertold_handlerstold_trace_filetresult((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyR`,s
	

cC@sg|\}}}}}|atjd}|j||j||_|dk	rc|jndS(sUndo changes to logging/tracing done by _push_log_file.

    This flushes, but does not close the trace file (so that anything that was
    in it is output.

    Takes the memento returned from _push_log_file.RN(RRcRet
removeHandlertcloseRoRtflush(t.0tmagicRvRtRwtnew_trace_fileRu((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytpop_log_fileOs

	cC@sttjdS(sLog the last exception to the trace file only.

    Used for exceptions that occur internally and that may be
    interesting to developers but not to users.  For example,
    errors loading plugins.
    N(R"R&t
format_exc(((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytlog_exception_quietlybscC@s0|at|dktjj|dkdS(s]Set the verbosity level.

    :param level: -ve for quiet, 0 for normal, +ve for verbose
    iN(t_verbosity_levelt_update_logging_levelRRtbe_quiet(R^((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytset_verbosity_levellscC@stS(sHGet the verbosity level.

    See set_verbosity_level() for values.
    (R(((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytget_verbosity_levelwscC@s!|rtdn
tddS(Nii(R(tquiet((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyRs
cC@s-|rtjtjntjtjdS(sHide INFO messages if quiet.N(RRpRctWARNINGRd(R((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyRscC@s
tdkS(s Is the verbosity level negative?i(R(((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytis_quietscC@s
tdkS(s Is the verbosity level positive?i(R(((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt
is_verbosestcC@sOtjdkr8ddlm}|jd|d|ntd|d|dS(sWrite out a memory dump.twin32i(t
win32utilstmessagetshortN(RWtplatformtbzrlibRtdebug_memory_win32apit_debug_memory_proc(RRR((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytdebug_memorystVmPeaktVmSizetVmRSScC@sytdtjd}Wntk
r1dSXz|j}Wd|jX|rct|nxU|jD]G}|st|qpx+tD]#}|j	|rt|PqqWqpWdS(Ns/proc/%s/statustrb(
R$R1tgetpidtIOErrortreadRzR
R)t
_short_fieldst
startswith(RRtstatus_filetstatustlinetfield((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyRs 




cC@szybtjdddd\}}tj|d}ddlm}|j||jd|Wn?tk
r|jd	t	n|jd
t	nXWd|dk	r|jn|dk	rtj|nXdS(Ntprefixtbzr_memdumptsuffixs.jsontwi(tscannersMemory dumped to %s
s'Dumping memory requires meliae module.
s Exception while dumping memory.
(ttempfiletmkstempR1RNtmeliaeRtdump_gc_objectsRtImportErrorRRRz(terr_fileRQtnamet	dump_fileR((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt_dump_memory_usages"





cC@sB|j}|j}|dks0|r4|dkr4|Sd||fS(sGive name of error class including module for non-builtin exceptions

    If `unqualified_bzrlib_errors` is True, errors specific to bzrlib will
    also omit the module prefix.
    t
exceptionst__main__s
bzrlib.errorss%s.%s(s
exceptionss__main__(t__name__t
__module__(teclasstunqualified_bzrlib_errorst
class_nametmodule_name((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt_qualified_exception_names		cC@sstdtjkr*t||tjS|\}}}t|tr\|jdtjSt|t	r|jddtjkrt
|n
|jdtjSt|trt|j
drt||dtjSt|dts	t||tjStj|r[t|d	dtjkrG|jd
tjSt||tjSt||tjSdS(sReport an exception to err_file (typically stderr) and to .bzr.log.

    This will show either a full traceback or a short message as appropriate.

    :return: The appropriate exit code for this error.
    Rsbzr: interrupted
sbzr: out of memory
tmem_dumps)Use -Dmem_dump to dump memory to a file.
sNo module named s7You may need to install this Python library separately.tinternal_errorRHsbzr: broken pipe
N(Rtdebugtdebug_flagstprint_exceptionterrorst
EXIT_ERRORRtKeyboardInterruptRtMemoryErrorRRtstrRtreport_user_errorRRFR3tis_environment_errorRRHtEPIPEt
report_bugtEXIT_INTERNAL_ERROR(texc_infoRtexc_typet
exc_objecttexc_tb((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytreport_exceptions<




	



cC@sY|\}}}|jd|j|j|f|jdtj|||d|dS(Nsbzr: ERROR: %s.%s: %s
s
R$(RRRR&R(RRRRR((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyRs
	
cC@s9|jd|df|r5|jd|fndS(sReport to err_file an error that's not an internal error.

    These don't get a traceback unless -Derror was given.

    :param exc_info: 3-tuple from sys.exc_info()
    :param advice: Extra advice to the user to be printed following the
        exception.
    sbzr: ERROR: %s
is%s
N(R(RRtadvice((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyRs	cC@s!ddlm}|||dS(s8Report an exception that probably indicates a bug in bzri(RN(tbzrlib.crashR(RRR((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyRscC@swytjjtjjWnRtk
r3}n@tk
rr}ddl}|j|j|jgkrlqsnXdS(Ni(	RWtstdoutR{RXt
ValueErrorRRHtEINVALR(RRRH((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt_flush_stdout_stderr#s
cC@strtjndS(N(RR{(((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt_flush_trace4sRacB@s2eZdZddddZdZdZRS(swRobustly write logging events to a stream using the specified encoding

    Messages are expected to be formatted to unicode, but UTF-8 byte strings
    are also accepted. An error during formatting or a str message in another
    encoding will be quitely noted as an error in the Bazaar log file.

    The stream is not closed so sys.stdout or sys.stderr may be passed.
    tstricticC@sStjj||||_|dkr=t|dd}n||_||_dS(Ntencodingtascii(RctHandlert__init__tstreamRRRR(tselfRRRR^((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyREs		cC@s/t|jdd}|dk	r+|ndS(NR{(RRR(RR{((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyR{MscC@syZ|j|}t|ts3|jd}n|jj|j|j|jdWnzt	k
rt
d}}y4t|jjd}t|j
jd}Wnt	k
rnXtd||nXdS(Nsutf-8s
s<Unformattable>Rs&Logging record unformattable: %s %% %s(tformatRRtdecodeRRRRRt	ExceptionRtreprtmsgRR"(RtrecordRRR((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pytemitRs*


N(RRt__doc__RRR{R(((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyRa;s	tConfigcB@s eZdZdZdZRS(sConfiguration of message tracing in bzrlib.

    This implements the context manager protocol and should manage any global
    variables still used. The default config used is DefaultConfig, but
    embedded uses of bzrlib may wish to use a custom manager.
    cC@s|S(N((R((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt	__enter__nscC@stS(N(tFalse(RRtexc_valR((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt__exit__qs(RRRRR(((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyRfs	t
DefaultConfigcB@s eZdZdZdZRS(srA default configuration for tracing of messages in bzrlib.

    This implements the context manager protocol.
    cC@st|_t|_|S(N(RTt_original_filenameRjt_original_state(R((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyR{s	cC@st|j|jatS(N(RRRRTR(RRRR((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyRs
	(RRRRR(((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyRus	(RRR(7Rt
__future__RRcR1RWRtbzrlib.lazy_importRtglobalsRRRRRTt_start_timeRReRR
RR
R"R/R9RARZRjR`RRRRRFRRRRRRRRRRRRRRRRRRatobjectRR(((s0/usr/lib/python2.7/dist-packages/bzrlib/trace.pyt<module>.s`										
	>	#		
							,					+

Copyright © 2017 || Recoded By Mr.Bumblebee