Discussion:
[OTAS-Planning]A Brief Question on Time?
Brian Butcher
2005-10-08 11:16:04 UTC
Permalink
I know this is way off topic on this list; but can anyone help?

I am trying to design software which will not be system dependent. Is
time.time() available on Windows? The Python documentation for the time
module is ambiguous.

( It's fairly important that peers in the OTAS system do not pass stale
hypocentral data around, and it's equally important that no client attempts
to reload hypocentral data that it has previously discarded because it is
outdated. )

Brian
Ben Middleton
2005-10-08 11:40:10 UTC
Permalink
I'd be surprised if it wasn't but...
what if the system clock is set wrongly? e.g. if I set my machine's
system clock to Jan 1 2020, I might end up discarding all data because
I think it is outdated. OTAS would need to take this into account in
some way; can we refer to some external timesource instead of (or in
addition to) the system clock? perhaps
http://tf.nist.gov/service/its.htm might be helpful
Post by Brian Butcher
I know this is way off topic on this list; but can anyone help?
I am trying to design software which will not be system dependent. Is
time.time() available on Windows? The Python documentation for the time
module is ambiguous.
( It's fairly important that peers in the OTAS system do not pass stale
hypocentral data around, and it's equally important that no client attempts
to reload hypocentral data that it has previously discarded because it is
outdated. )
Brian
-------------------------------------------------------
Power Architecture Resource Center: Free content, downloads,
discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
OTAS-Planning mailing list
https://lists.sourceforge.net/lists/listinfo/otas-planning
Brian Butcher
2005-10-08 12:11:58 UTC
Permalink
Post by Ben Middleton
OTAS would need to take this into account in
some way; can we refer to some external timesource instead of (or in
addition to) the system clock? perhaps
http://tf.nist.gov/service/its.htm might be helpful
This is already done for any client running ntpd

Brian

Apologies for two seperate messages
Charles Martin
2005-10-08 16:11:32 UTC
Permalink
rather than depend on an externality, we could query an NTP time
source directly,. here's a code frag that does SNTP; we wouldn't need
full NTP because we're not trying to skew the onboard clock, just get
our own time hack.

import socket
import struct
import sys
import time

TIME1970 = 2208988800L # Thanks to F.Lundh

client = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
data = '\x1b' + 47 * '\0'
client.sendto( data, ( sys.argv[1], 123 ))
data, address = client.recvfrom( 1024 )
if data:
print 'Response received from:', address
t = struct.unpack( '!12I', data )[10]
t -= TIME1970
print '\tTime=%s' % time.ctime(t)


http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117211
Post by Brian Butcher
Post by Ben Middleton
OTAS would need to take this into account in
some way; can we refer to some external timesource instead of (or in
addition to) the system clock? perhaps
http://tf.nist.gov/service/its.htm might be helpful
This is already done for any client running ntpd
Brian
Apologies for two seperate messages
-------------------------------------------------------
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
OTAS-Planning mailing list
https://lists.sourceforge.net/lists/listinfo/otas-planning
--
"Ever notice that 'what the hell' is always the right decision?" --
Marilyn Monroe
"The first requirement of survival is to become worthy of it." -- Wretchard

Charles R Martin
_____________________
***@gmail.com

Loading...