diff options
author | Jogi Hofmüller <jogi@mur.at> | 2011-08-11 12:56:42 +0000 |
---|---|---|
committer | Jogi Hofmüller <jogi@mur.at> | 2011-08-11 12:56:42 +0000 |
commit | 76c84acf76f8678dedc1b315ed542c11fb6e9515 (patch) | |
tree | c71842dc7b16523ae4bab0489a79381bd9eaeb18 /tools/mmd/MmdSatellite.py | |
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
Diffstat (limited to 'tools/mmd/MmdSatellite.py')
-rw-r--r-- | tools/mmd/MmdSatellite.py | 30 |
1 files changed, 18 insertions, 12 deletions
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 |