summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJogi Hofmüller <jogi@mur.at>2011-08-11 12:56:42 +0000
committerJogi Hofmüller <jogi@mur.at>2011-08-11 12:56:42 +0000
commit76c84acf76f8678dedc1b315ed542c11fb6e9515 (patch)
treec71842dc7b16523ae4bab0489a79381bd9eaeb18
parent- found more todos (diff)
- found more todos
- added titles to some <div> tags in dataWidget () - wrote Satellite.cronJob () method for updating TLE file and database - calling MmdSatellite.py invokes cronJob () git-svn-id: https://svn.spreadspace.org/mur.sat@125 7de4ea59-55d0-425e-a1af-a3118ea81d4c
-rw-r--r--tools/mmd/MmdDb.py17
-rw-r--r--tools/mmd/MmdSatellite.py30
2 files changed, 23 insertions, 24 deletions
diff --git a/tools/mmd/MmdDb.py b/tools/mmd/MmdDb.py
index aa6ff03..356bcfe 100644
--- a/tools/mmd/MmdDb.py
+++ b/tools/mmd/MmdDb.py
@@ -133,23 +133,16 @@ class Db:
self.cursor.execute ('SELECT * FROM ssps WHERE timestamp >=? LIMIT 1', (timestamp,))
return self.cursor.fetchone ()
+ def satelliteDeleteObsoleteSSPs (self, timestamp):
+ self.cursor.execute ('DELETE FROM ssps WHERE timestamp >=?', (timestamp,))
+ self.conn.commit ()
+
def close (self):
self.cursor.close ()
self.conn.close ()
if __name__ == "__main__":
- db = Db ()
- print db.sessionFind ('1234567890')
- db.sessionInit ('1234567890', 'jogi@mur.at', '1')
- data = db.sessionFind ('1234567890')
- print data['id'], data['email']
- db.sessionDelete ('1234567890')
- print db.sessionFind ('1234567890')
- print db.userFindId ('1')
- db.userCreate ('1', 'Jogi', 'Hofmüller', 'jogi@mur.at', '', '', '', '')
- print db.userFindId ('1')
- db.userDelete ('1')
-
+ pass
# vim: tw=0 ts=2 expandtab
# EOF
diff --git a/tools/mmd/MmdSatellite.py b/tools/mmd/MmdSatellite.py
index a148f30..0bf4208 100644
--- a/tools/mmd/MmdSatellite.py
+++ b/tools/mmd/MmdSatellite.py
@@ -3,6 +3,7 @@
import ephem
import time
import os
+import sys
from MmdDb import Db
from MmdLocation import Location
@@ -95,11 +96,13 @@ class Satellite:
self.latitude = dms2degdec (sat.sublat.__str__ ())
self.altitude = round (float (sat.elevation.__str__ ()), 1)
- def computeTrajectory (self):
+ def _computeTrajectory (self):
'''
computes 5 hours of future trajectory data, starting at the
latest timestamp found in data base
'''
+ if not self._loadTLE ():
+ return False
sat = ephem.readtle (self._tle[0], self._tle[1], self._tle[2])
graz = ephem.Observer ()
@@ -134,22 +137,25 @@ class Satellite:
return False
return True
+ def cronJob (self):
+ if self._updateTLEFile ():
+ self._updateTrajectory ()
+ return self._computeTrajectory ()
+
+ def _updateTLEFile (self):
+ return False
+
+ def _updateTrajectory (self):
+ self.db.satelliteDeleteObsoleteSSPs (time.strftime ('%s'))
+
if __name__ == "__main__":
satellite = Satellite ()
- minutes = 30
try:
- assert satellite._loadTLE (), 'loading TLE failed'
- print satellite._tle
- assert satellite.computeTrajectory (), 'computing trajectory failed'
- trajectory = satellite.getTrajectoryAsJavaArray ('curves', minutes)
- assert trajectory, 'got not trajectory'
- print trajectory
- t, lon, lat = satellite.getCurrentSSP ()
- assert t, 'loading current SSP failed'
- print lon, lat, time.strftime ('%c', time.gmtime (t))
- print satellite.longitude, satellite.latitude, satellite.altitude
+ assert satellite.cronJob (), 'executing cronjob failed'
except AssertionError as e:
print 'Error: {0}'.format (e)
+ sys.exit (1)
+ sys.exit (0)
# vim: tw=0 ts=2
# EOF