%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/alt/python27/lib/python2.7/site-packages/paste/
Upload File :
Create Path :
Current File : //proc/self/root/opt/alt/python27/lib/python2.7/site-packages/paste/reloader.pyo

�
a�Nc@s�dZddlZddlZddlZddlZddlZddlmZdd�Zde	fd��YZ
ejjd�r�ydd	l
mZWnek
r�q�Xd
e
fd��YZne
jZe
jZdS(s�
A file monitor and server restarter.

Use this like:

..code-block:: Python

    import reloader
    reloader.install()

Then make sure your server is installed with a shell script like::

    err=3
    while test "$err" -eq 3 ; do
        python server.py
        err="$?"
    done

or is run from this .bat file (if you use Windows)::

    @echo off
    :repeat
        python server.py
    if %errorlevel% == 3 goto repeat

or run a monitoring process in Python (``paster serve --reload`` does
this).  

Use the ``watch_file(filename)`` function to cause a reload/restart for
other other non-Python files (e.g., configuration files).  If you have
a dynamic set of files that grows over time you can use something like::

    def watch_config_files():
        return CONFIG_FILE_CACHE.keys()
    paste.reloader.add_file_callback(watch_config_files)

Then every time the reloader polls files it will call
``watch_config_files`` and check all the filenames it returns.
i����N(tclassinstancemethodicCs?td|�}tjd|j�}|jt�|j�dS(s,
    Install the reloading monitor.

    On some platforms server threads may not terminate when the main
    thread does, causing ports to remain open/locked.  The
    ``raise_keyboard_interrupt`` option creates a unignorable signal
    which causes the whole application to shut-down (rudely).
    t
poll_intervalttargetN(tMonitort	threadingtThreadtperiodic_reloadt	setDaemontTruetstart(Rtmontt((s?/opt/alt/python27/lib/python2.7/site-packages/paste/reloader.pytinstall2s	
RcBs_eZgZgZgZd�Zd�Zd�Zd�Ze	e�Zd�Z
e	e
�Z
RS(cCsSi|_t|_||_t|j�|_|jj|�t|j	�|_
dS(N(t
module_mtimesRtkeep_runningRtlisttglobal_extra_filestextra_filest	instancestappendtglobal_file_callbackstfile_callbacks(tselfR((s?/opt/alt/python27/lib/python2.7/site-packages/paste/reloader.pyt__init__Fs			cCs>x7tr9|j�s&tjd�Pntj|j�qWdS(Ni(Rtcheck_reloadtost_exitttimetsleepR(R((s?/opt/alt/python27/lib/python2.7/site-packages/paste/reloader.pyRNs
	
cCs�t|j�}xJ|jD]?}y|j|��Wqtjd|IJtj�qXqWx_tjj	�D]N}y
|j
}Wnttfk
r�}qlnX|dk	rl|j|�qlqlWx6|D].}y+tj|�}|r�|j}nd}Wnttfk
rq�nX|jd�rZtjj|d �rZttj|d �j|�}nO|jd�r�tjj|d d�r�ttj|d d�j|�}n|jj|�s�||j|<q�|j||kr�tjd|IJtSq�WtS(	Ns)Error calling paste.reloader callback %r:is.pyci����s	$py.classi����s.pys%s changed; reloading...(RRRtextendtsyststderrt	tracebackt	print_exctmodulestvaluest__file__tAttributeErrortImportErrortNoneRRtstattst_mtimetOSErrortIOErrortendswithtpathtexiststmaxR
thas_keytFalseR(Rt	filenamest
file_callbacktmoduletfilenametexcR(tmtime((s?/opt/alt/python27/lib/python2.7/site-packages/paste/reloader.pyRZsD


%"&
cCsftjj|�}|dkrRx|jD]}|j|�q(W|jj|�n|jj|�dS(s Watch the named file for changesN(	RR-tabspathR'Rt
watch_fileRRR(RtclsR5tinstance((s?/opt/alt/python27/lib/python2.7/site-packages/paste/reloader.pyR9scCsT|dkr@x|jD]}|j|�qW|jj|�n|jj|�dS(s{Add a callback -- a function that takes no parameters -- that will
        return a list of filenames to watch for changes.N(R'Rtadd_file_callbackRRR(RR:tcallbackR;((s?/opt/alt/python27/lib/python2.7/site-packages/paste/reloader.pyR<�s
(t__name__t
__module__RRRRRRR9RR<(((s?/opt/alt/python27/lib/python2.7/site-packages/paste/reloader.pyR@s			%	
	
tjava(t
SystemRestartt
JythonMonitorcBseZdZd�ZRS(s�
            Monitor that utilizes Jython's special
            ``_systemrestart.SystemRestart`` exception.

            When raised from the main thread it causes Jython to reload
            the interpreter in the existing Java process (avoiding
            startup time).

            Note that this functionality of Jython is experimental and
            may change in the future.
            cCs9x2tr4|j�s!t��ntj|j�qWdS(N(RRRARRR(R((s?/opt/alt/python27/lib/python2.7/site-packages/paste/reloader.pyR�s	(R>R?t__doc__R(((s?/opt/alt/python27/lib/python2.7/site-packages/paste/reloader.pyRB�s(RCRRRRR tpaste.util.classinstanceRRtobjectRtplatformt
startswitht_systemrestartRAR&RBR9R<(((s?/opt/alt/python27/lib/python2.7/site-packages/paste/reloader.pyt<module>)s W
	

Zerion Mini Shell 1.0