Provide a framework to run any implementation of a ntp time service that follows the interface provided here. Any implementation must provide update method that takes a localport as an argument. Implementers will set a mapping to their functions by calling time_register_method.
To use this module, first make a call to time_updatetime(localport), where localport is a valid UDP port that you can send and receive on (note that this port may not be used depending on the implementation). Then, to get the actual time, call time_gettime() which will return the current time (in seconds). time.repy will attempt to use the update method of any impelemntor included. If none are included or if they all fail an exception is thrown
time_register_method(imp_name,update_method)
Allow an implementation to register its update method with time.repy.
Notes:
- imp_name, the name or unique abbreviation of the implementation update_method, a time update_method
time_updatetime(localport)
Obtains and stores the local time from a subset of NTP servers. Attempts to update the time with each implementation provided until one succeeds or they all fail.
Notes:
- localport is the local port that MAY be used when contacting the NTP server(s). Consider this port a hint and not a rule.
time_settime(currenttime)
Sets a remote time as the current time.
time_gettime()
Gives the current time in seconds by calculating how much time has elapsed since the local time was obtained from an NTP server via the time_updatetime(localport) function.
Notes:
- TimeError is raised when time_updatetime(localport)has not previously been called or when time_updatetime(localport) has any unresolved TimeError exceptions.
?