MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /proc/self/root/usr/lib/python2.4/site-packages/mx/DateTime/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/usr/lib/python2.4/site-packages/mx/DateTime/NIST.pyc
m
KX;c
@sdZdkZdkZdkZdkZdkZdkZdkZdkZdZ	yei
ddZWneij
o
dZnXyei
ddZ
Wneij
o
dZ
nXd2Zhdd<d	d<dd<dd<dd<dd<d
d<d
d<dd<dd<Zd3ZdeifdYZdZeieZd Zeieieieieeieieeid!	Zeid"Zed#eieeieieid$Z da!d%a"d&a#gZ$d'Z%deiei&ei'e$d(Z'e'Z(dei)e'd)Z)e)Z*d*Z+d'ei'e eid+Z,d,Z-d-d.Z.e%e$d/Z/d0Z0e0Z1d1Z2dS(4sP Access routines to the NIST Network Time Services.

    This module allows you to access the UTC standard time bases via
    the Internet. The two functions localtime() and gmtime() will
    return accurate DateTime instances based on the NIST services.

    Since access through the Internet can be slow, the module also
    provides a way to calibrate the computer's clock and then have
    localtime() and gmtime() use the calibrated clock instead of the
    NIST services. To calibrate the two functions, call calibrate()
    with the number of calibration rounds you wish to apply.

    Copyright (c) 2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
    Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info@egenix.com
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.

Nitdaytimettcpi
ttimei%s
time.nist.govstime-a.nist.govstime-b.nist.govstime-nw.nist.govstime-a.timefreq.bldrdoc.govstime-b.timefreq.bldrdoc.govstime-c.timefreq.bldrdoc.govsutcnist.colorado.edusutcnist1.reston.mci.netsnist1.datum.coms
204.70.131.13s129.6.16.35s132.163.135.132s132.163.135.130s
209.0.72.7s131.107.1.10s132.163.135.131s129.6.16.36s
192.43.244.18s128.138.140.44s&http://time-a.timefreq.bldrdoc.gov:14/tErrorcBstZRS(N(t__name__t
__module__(((t4/usr/lib/python2.4/site-packages/mx/DateTime/NIST.pyRFss(?P<mjd>\d+) (?P<date>\d+-\d\d-\d\d) (?P<hour>\d?\d):(?P<minute>\d\d):(?P<second>\d\d) (?P<dst>\d\d) (?P<leap>\d) (?P<health>\d) (?P<msadv>\d+(?:\.\d+)?) (?P<label>[\w()]+) (?P<otm>.)cCsti|}|ptd|n|i}t|}xxtt	|D]d}||}yt|||<WqRtj
o1yt
|||<Wqtj
oqXqRXqRW|S(sS Returns a sequence representing the parsed information in daytime.

        The sequence has the following format:
          [mjd,date,hour,minute,second,dst,leap,health,msadv,label,otm]

        Numbers are converted to numbers. Entries may be None.

        Raises a ValueError is the daytime information cannot be
        parsed.

    sunkown daytime format: "%s"N(t
_daytimeREtmatchRtmt
ValueErrortgroupstlisttltrangetlentitvaluetinttfloat(RRRR	R
R((Rt_parse_datetimeXs"
cCs|}|
i|o|
|}n5y||}Wn|	j
odSnX||
|<|||}|idxy|i||f}
Wn-|	j
o!}to
d|GHndSnXtodti|
GHn|
|jo|g|gg|\}}}|oY|idy|i||f}
Wq|	j
o }to
d|GHqwqwqXqto	dGHnd}
nPqwW|
djodSn|SdS(s Connect to the given host and port and return a socket
        instance.

        timeout states the number of seconds to wait for the
        connection to be established.

        In case no connection is possible, None is returned.

    iis
 error: %ss received %ss timeoutiN(thostthostnametip_cachethas_keyt
gethostbynameterrortNonetsockettAF_INETtSOCK_STREAMtstsetblockingt
connect_extDAYTIME_PORTtrctwhyt_debugterrnot	errorcodetEINPROGRESStselectttimeouttrtwte(RtportR*RRRR)R"R(RRRRR#R,R$R-RR+((Rt_connectwsL	


	
!

	

cCsQ||ggg|\}}}|o|i|Snto	dGHndSdS(s Read size at most bytes from socket.

        timeout defines the amount of time to wait for data to become
        available. In case this time is exceeded, None is returned.

    s
 read timeoutN(
R)RR*R+R,R-trecvtsizeR%R(RR1R*R)R-R+R,((Rt_reads	!	icCs2to	dGHnx|D]}
to
d|
GHnt|
t|}|ot|dd}|djoqn||}	|}|ito
d|	GHny||	}	Wntj
o
qnX|	ddjoqnPqqWtd||	d||	d	|	d
|	d|	dd
|fS(s Scans the given (NIST) daytime servers and returns a tuple:

        (DateTime instance representing the current UTC day time,
        ticks value of the time when the day time information was
        received)

        daytime_servers must be a list of servers providing the
        daytime protocol. They can be given by name or IP.

        timeout is used as timeout when connecting to each server.  It
        must be given in seconds. The total timeout depends on the
        number of servers listed in daytime_servers.

    sContacting NIST servers...sTrying server: %sif0.5s read %siis*could not get accurate daytime informationiiiif0.001N(R%tdaytime_serversRR/R"R*RR2tdataRtstripRRt	timestamptcloseRR
RtDateTimeFromMJDtTime(R3R*R5RR8R9RR6RRRR4((Rt_get_daytimes4	

	

		if0.0i
c
Cs|ptoyyt|tjotnt\}}|}||i}||}	||	}|i||||	SWqtj
o!|djo
tdqqXn||tS(s Returns the current UTC time as DateTime instance.

        Works must like the standard DateTime.now(), but tries to use
        the NIST time servers as time reference -- not only the
        computer's builtin clock.

        Note that the contructor may take several seconds to return in
        case no calibration was performed (see calibrate()). With
        calibration information, the computer's clock is used as
        reference and the offset to NIST time is compensated by the
        contructor.

        In case the NIST service is not reachable, the contructor
        falls back to using either the calibrated or uncalibrated
        computer's clock.

        Setting nist_lookup to false (default) will cause the
        contructor to prefer the calibrated CPU time over the
        expensive Internet queries. If it is true, then Internet
        lookups are always tried first before using the local clock. A
        value of 2 will cause an Error to be raised in case the NIST
        servers are not reachable.

        The constructor will use the NIST information for auto
        calibration, unless an explicit call to calibrate() takes care
        of this.

    is!could not connect to NIST serversN(tnist_lookuptcalibratingRt_diffst
_min_diffst_update_calibrationR:tnistR6tutctimetlocaltsecondstdiffRtadjtappendtDateTimeDeltaFromSecondsRtcalibration(
R;RRGRAR=R6R@RDRBRE((RRAs !	




cCs|||iS(sa Returns the current local time as DateTime instance.

        Same notes as for utctime().

    N(t	localtimeRAR;tgmticks(R;RIRA((RRI3scCs-ytWntj
odSnXdSdS(s Return 1/0 depending on whether the NIST service is
        currently reachable or not.

        This function is expensive since it actually fetches a daytime
        packet from a NIST server.

    iiN(R:R(((RtonlineCs	cCsg}xQt|D]C}|\}
}|}	|
|	i	||}|i|qWd}x|D]}||}qgW|t|S(s Returns the average offset of the computer's clock to the NIST
        time base in seconds.

        If you add the return value to the return value of
        time.time(), you will have a pretty accurate time base to use
        in your applications.

        Note that due to network latencies and the socket overhead,
        the calculated offset will include a small hopefully constant
        error.

        iterations sets the number of queries done to the NIST time
        base.  The average is taken over all queries.

    iN(tdiffsRt
iterationsRR:R@R6RARBRCRRDRFtsumR(RMRAR:RRLRR6RNRDRBR@((Rttime_offsetSs
	cCs|adadadS(s Sets the calibration to be use by localtime() and utctime().

        This also sets the global calibrated to 1 and disables auto
        calibration.

    iiN(tcalibration_offsetRHt
calibratedR<(RP((Rtset_calibrationrs
icCs:yt|}Wnttfj
onXt|dS(s_ Calibrates the localtime() and gmtime() functions supplied
        in this module (not the standard ones in DateTime !).

        Uses the NIST time service as time base. The computer must
        have an active internet connection to be able to do
        calibration using the NIST servers.

        iterations sets the number of round to be done.

        Note: This function takes a few seconds to complete. For long
        running processes you should recalibrate every now and then
        because the system clock tends to drift (usually more than the
        hardware clock in the computer).

    N(RORMRHR
RRR(RMRH((Rt	calibratescCsQd}||}x|D]}||}qW|t|ag|(ttdS(s Updates the calibration from the last use_last entries in 
        the global _diffs.

        _diffs is being updated with every call to the two current
        time APIs that goes out and gets genuine information from
        NIST.

        After calibration the entries in _diffs are cleared. This
        function is automatically called by utctime() and localtime()
        when needed.

    iN(RNR=tuse_lastRLRDRRHRR(RTR=RLRNRD((RR?scCsgt(dadS(sm Enables and resets the auto calibration for a new round.

        This does not clear possibly available calibration
        information, so the two time APIs will continue to revert to
        the calibrated clock in case no connection to the NIST servers
        is possible.

        Auto calibration is on per default when the module is
        imported.

    iN(R=R<(((Rtreset_auto_calibrationscCs
dadS(s! Turns auto calibration off.
    iN(R<(((Rtdisable_auto_calibrations(
s
time.nist.govstime-a.nist.govstime-b.nist.govstime-nw.nist.govstime-a.timefreq.bldrdoc.govstime-b.timefreq.bldrdoc.govstime-c.timefreq.bldrdoc.govsutcnist.colorado.edusutcnist1.reston.mci.netsnist1.datum.com(s&http://time-a.timefreq.bldrdoc.gov:14/(3t__doc__RR)tDateTimetreR&t
exceptionststringRR%t
getservbynameR"Rt	TIME_PORTR3Rtdaytime_http_serverst
StandardErrorRt_daytimetcompileRRRRR(RR/R2R5R8R9R:RQR<RHR=R>RGRAtgmtimeRItnowRKRORRRSR?RUtenable_auto_calibrationRV(#R3R:RXRVR`RSR)RcR%R&RYRARKR>RIRdR[R]RbRR"R?RRRRRRUR/RR^R2R=RRZRO((Rt?sP			-
`
		9<*2!3		
	

Anon7 - 2021