From 9f7530bf0b90cb4d5bcf2032384f05f958584f30 Mon Sep 17 00:00:00 2001 From: Simon Pamies Date: Fri, 10 Jun 2011 21:51:08 +0200 Subject: [PATCH 1/7] Showing dampened values for wind --- .../sailing/web/browser/templates/wind-settings-info.pt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/src/sailing.web/sailing/web/browser/templates/wind-settings-info.pt b/python/src/sailing.web/sailing/web/browser/templates/wind-settings-info.pt index 8d9c392325d..bb3b7a80673 100644 --- a/python/src/sailing.web/sailing/web/browser/templates/wind-settings-info.pt +++ b/python/src/sailing.web/sailing/web/browser/templates/wind-settings-info.pt @@ -22,7 +22,9 @@ ${view.millisToDatetime(track['timepoint'])}  Bearing: ${track['truebearingdeg']}  + Dampened Bearing: ${track['dampenedtruebearingdeg']}  Speed: ${track['knotspeed']}  + Dampened Speed: ${track['dampenedknotspeed']}  LatDeg: ${track.get('latdeg', 'N/A')}  LngDeg: ${track.get('lngdeg', 'N/A')}
@@ -39,7 +41,9 @@ ${view.millisToDatetime(track['timepoint'])}  Bearing: ${track['truebearingdeg']}  + Dampened Bearing: ${track['dampenedtruebearingdeg']}  Speed: ${track['knotspeed']}  + Dampened Speed: ${track['dampenedknotspeed']}  LatDeg: ${track.get('latdeg', 'N/A')}  LngDeg: ${track.get('lngdeg', 'N/A')}
From 0dcc472ca4b27008d1f8a3299d2b12d4146b3197 Mon Sep 17 00:00:00 2001 From: Simon Pamies Date: Fri, 10 Jun 2011 22:08:58 +0200 Subject: [PATCH 2/7] Fixed configuration handling for collections --- python/src/sailing.db/sailing/db/database.py | 4 ++-- python/templates/db.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/src/sailing.db/sailing/db/database.py b/python/src/sailing.db/sailing/db/database.py index 920627f01fd..51a04e91eb9 100644 --- a/python/src/sailing.db/sailing/db/database.py +++ b/python/src/sailing.db/sailing/db/database.py @@ -36,11 +36,11 @@ def setupDatabases(): databases[dbname] = db connections[dbname] = conn - for collection in d['collections']: + for collection in d['collections'][0].strip().split(' '): collections[collection] = mongokit.Collection(db, collection) collection2connection[collection] = conn - LOG.info('Attached collections: %s' % ', '.join(collections)) + LOG.info('Attached collections to database %s: %s' % (dbname, ', '.join(d['collections']))) def getCollection(collection): """ Return a MongoDB collection by its name """ diff --git a/python/templates/db.ini b/python/templates/db.ini index bc9c0f91737..e48ac879feb 100644 --- a/python/templates/db.ini +++ b/python/templates/db.ini @@ -24,5 +24,5 @@ port = ${conf:mongodb_port} dbname = biography username = password = -collections = competitors +collections = competitor_info From 31eb2791249a0937a1bcfdf32a681d28ea7754a3 Mon Sep 17 00:00:00 2001 From: Simon Pamies Date: Fri, 10 Jun 2011 22:18:37 +0200 Subject: [PATCH 3/7] Reverted change introduced in 3db6fb5eaf4318c94e64a00b6bd806a8e63689d6 - something went terribly wrong there --- .../sailing/web/browser/functions.py | 35 ++----------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/python/src/sailing.web/sailing/web/browser/functions.py b/python/src/sailing.web/sailing/web/browser/functions.py index e5f1eb13365..48f4cde1129 100644 --- a/python/src/sailing.web/sailing/web/browser/functions.py +++ b/python/src/sailing.web/sailing/web/browser/functions.py @@ -29,7 +29,6 @@ threaded_listener = {} def dropDB(context, request): from sailing.db.monitoring import dropDB dropDB() - return HTTPFound(location='/') def startListenerThreads(conf, eventlist): @@ -55,30 +54,6 @@ def startListenerThreads(conf, eventlist): threaded_listener[key] = t t.start() -# addEvent -def configureListener(context, request): - host = request.POST.get('host', 'localhost') - port = request.POST.get('port', '8888') - - lock = threading.Lock() - - view = core.BaseView(context, request) - - conf = URIConfigurator(host, port) - view.session['listener-conf'] = conf - - if request.POST.get('listener-start', None): - conf.setContext(config.ADMIN) dead threads - lstn = threaded_listener.get(key, None) - if lstn and lstn.running is False and lstn.is_alive() is False: - del threaded_listener[key] - - # now there should be only running threads left - if not threaded_listener.has_key(key): - t = provider.LiveDataReceiver(conf.host, conf.port, event['name'], racename) - threaded_listener[key] = t - t.start() - # addEvent def configureListener(context, request): host = request.POST.get('host', 'localhost') @@ -94,7 +69,6 @@ def configureListener(context, request): if request.POST.get('listener-start', None): conf.setContext(config.ADMIN) - if request.POST.get('eventJSONURL'): conf.setCommand(config.ADD_EVENT) conf.setParameters(dict(eventJSONURL=request.POST.get('eventJSONURL'), @@ -166,7 +140,6 @@ def configureListener(context, request): if racename: conf.setCommand(config.STOP_RACE) conf.setParameters(dict(eventname=eventname, racename=racename)) - else: conf.setCommand(config.STOP_EVENT) conf.setParameters(dict(eventname=eventname)) @@ -176,8 +149,6 @@ def configureListener(context, request): del view.session['listener-conf'] view.session.save() - # not using get_ident here because we need to be able - # to get a listener by knowing the event and race key = hash('%s-%s-%s-%s' % (conf.host, conf.port, eventname, racename)) if threaded_listener.has_key(key): threaded_listener[key].running = False @@ -194,7 +165,7 @@ def configureListener(context, request): eventlist = provider.eventConfiguration(conf) if model.EventImpl.queryCount() == 0: - return view.yieldMessage('Seems that there are no events that can be shown! Server not started?') + return view.yieldMessage('Seems that there are no events that can be shown! Listener not started?') # start listener thread if this is not yet active startListenerThreads(conf, eventlist) @@ -216,8 +187,7 @@ def configuredListeners(context, request): out = [] for key, listener in threaded_listener.items(): out.append( {'host': listener.host, 'port': listener.port, - 'eventname': listener.eventname, - 'last_update': listener.last_update and listener.last_update.strftime('%d.%m %H:%M:%S') or '-', + 'eventname': listener.eventname, 'last_update': listener.last_update and listener.last_update.strftime('%d.%m %H:%M:%S') or '-', 'paused' : listener.paused, 'running': listener.running, 'id' : key, 'racename': listener.racename} ) @@ -291,7 +261,6 @@ def mapCompetitors(context, request): data = jsonByUrl(conf) - # sort by current ranks (if available) if data.get('ranks'): data = data['ranks'] data.sort(lambda x,y: cmp(x['rank'], y['rank'])) From ac2dc8cb96a55a1a3e6071505faad8bbca6605c7 Mon Sep 17 00:00:00 2001 From: Simon Pamies Date: Fri, 10 Jun 2011 22:43:32 +0200 Subject: [PATCH 4/7] Added meaningful error message when connection to TraTrac server fails --- .../domain/tractracadapter/impl/RaceTrackerImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/java/com.sap.sailing.domain.tractracadapter/src/com/sap/sailing/domain/tractracadapter/impl/RaceTrackerImpl.java b/java/com.sap.sailing.domain.tractracadapter/src/com/sap/sailing/domain/tractracadapter/impl/RaceTrackerImpl.java index 4dc784b96d0..be6a7ddb11b 100755 --- a/java/com.sap.sailing.domain.tractracadapter/src/com/sap/sailing/domain/tractracadapter/impl/RaceTrackerImpl.java +++ b/java/com.sap.sailing.domain.tractracadapter/src/com/sap/sailing/domain/tractracadapter/impl/RaceTrackerImpl.java @@ -57,6 +57,13 @@ public class RaceTrackerImpl implements Listener, RaceTracker { throws URISyntaxException, MalformedURLException, FileNotFoundException { // Read event data from configuration file tractracEvent = KeyValue.setup(paramURL); + + // can happen that tractrac event is null (occurs when there is no internet connection) + // so lets raise some meaningful exception + if (tractracEvent == null) { + throw new RuntimeException("Connection failed. Could not connect to " + paramURL); + } + // Initialize data controller using live and stored data sources controller = new DataController(liveURI, storedURI, this); // Start live and stored data streams From 3cb085cc8eb72618518c4fff02498b72ab3cee9a Mon Sep 17 00:00:00 2001 From: Simon Pamies Date: Fri, 10 Jun 2011 22:46:06 +0200 Subject: [PATCH 5/7] Minor bugfixes; Added ability to set wind store during connect --- .../src/sailing.connector/sailing/connector/__init__.py | 2 +- python/src/sailing.db/sailing/db/monitoring.py | 3 +++ python/src/sailing.web/sailing/web/browser/functions.py | 4 ++++ .../sailing/web/browser/templates/java-connector.pt | 8 ++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/python/src/sailing.connector/sailing/connector/__init__.py b/python/src/sailing.connector/sailing/connector/__init__.py index a3c45082547..d7f8dcb55b2 100644 --- a/python/src/sailing.connector/sailing/connector/__init__.py +++ b/python/src/sailing.connector/sailing/connector/__init__.py @@ -68,7 +68,7 @@ class URIConfigurator(object): def trigger(self, request=None): if self.do_log is True: log.info('Triggering URI %s' % self.URI()) - return urllib2.urlopen(self.URI()) + return urllib2.urlopen(self.URI()).read() def jsonByUrl(configurator): """ Connects to specified REST service and returns parsed data """ diff --git a/python/src/sailing.db/sailing/db/monitoring.py b/python/src/sailing.db/sailing/db/monitoring.py index c674834bd61..58095813540 100644 --- a/python/src/sailing.db/sailing/db/monitoring.py +++ b/python/src/sailing.db/sailing/db/monitoring.py @@ -1,5 +1,8 @@ from database import databases, collections +import logging +log = logging.getLogger(__name__) + def dbStats(): result = dict() for dbname in databases: diff --git a/python/src/sailing.web/sailing/web/browser/functions.py b/python/src/sailing.web/sailing/web/browser/functions.py index 48f4cde1129..c84138b3811 100644 --- a/python/src/sailing.web/sailing/web/browser/functions.py +++ b/python/src/sailing.web/sailing/web/browser/functions.py @@ -93,6 +93,10 @@ def configureListener(context, request): try: result = conf.trigger() + + if result.find('Exception')>0: + raise Exception, 'Server triggered exception: %s' % result[:550] + except Exception, ex: return view.yieldMessage('Error: %s' % str(ex)) diff --git a/python/src/sailing.web/sailing/web/browser/templates/java-connector.pt b/python/src/sailing.web/sailing/web/browser/templates/java-connector.pt index 9d943663774..a7d04af0d9e 100644 --- a/python/src/sailing.web/sailing/web/browser/templates/java-connector.pt +++ b/python/src/sailing.web/sailing/web/browser/templates/java-connector.pt @@ -53,6 +53,14 @@ When stopping listener it will trigger two methods: If you select a race +
+ Persistent store where to persist wind tracks
+ +
+
  Drop Database before connect
From f0f560a2675ad7be50c1609e1959407343375934 Mon Sep 17 00:00:00 2001 From: Simon Pamies Date: Fri, 10 Jun 2011 22:46:49 +0200 Subject: [PATCH 6/7] Updated todo --- TODO | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index ecb0254d52b..575e76b5fe8 100644 --- a/TODO +++ b/TODO @@ -30,11 +30,9 @@ Simon + Prüfen, warum in der Map Anzeige manchmal ein Competitor doppelt ist + Wind aus der Map löschen wenn der sich geändert hat + Simulator mit Speed = 1 anschmeissen und dann prüfen was passiert -+ Prüfen warum im live leaderbaord manchmal 4 legs angezeigt werden -+ Prüfen warum der Listener thread manchmal nicht richtig gestoppt wird (disconnect sollte auch thread stoppen) -+ Datenbank nicht einfach so löschen (Wind Positionen) -+ Infinity oder große Werte als Ankerindikatoren erkennen und anzeigen können -+ Anzeige Truebearing bei Wind-Informationen ++ Prüfen warum im live leaderbaord manchmal 4 legs angezeigt werden (max ist 2+1) ++ Prüfen warum der Listener thread manchmal nicht richtig gestoppt wird ++ Infinity oder große Werte als Ankerindikatoren anzeigen im UI + MongoDB als Windsource bei addrace oder addevent einstellbar machen + Anzeigen im Leaderboard ob der Wind up oder down ist (competitor.values wäre ein guter platz dafür) + Implementierung Leaderboard auf Basis HTML Designer From 50441cd2e19638a0abd0572bf7f620dc3187247e Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Fri, 10 Jun 2011 23:26:24 +0200 Subject: [PATCH 7/7] switched to Iterator to make differ more widely applicable --- .../com.googlecode.java-diff-utils/src/difflib/DiffUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/com.googlecode.java-diff-utils/src/difflib/DiffUtils.java b/java/com.googlecode.java-diff-utils/src/difflib/DiffUtils.java index eece9d3614a..e09c2306107 100755 --- a/java/com.googlecode.java-diff-utils/src/difflib/DiffUtils.java +++ b/java/com.googlecode.java-diff-utils/src/difflib/DiffUtils.java @@ -39,7 +39,7 @@ public class DiffUtils { * @param revised the revised text * @return the patch describing the difference between the original and revised texts */ - public static Patch diff(List original, List revised) { + public static Patch diff(Iterable original, Iterable revised) { return DiffUtils.diff(original, revised, new MyersDiff()); } @@ -51,7 +51,7 @@ public class DiffUtils { * @param algorithm the given algorithm * @return the patch describing the difference between the original and revised texts */ - public static Patch diff(List original, List revised, DiffAlgorithm algorithm) { + public static Patch diff(Iterable original, Iterable revised, DiffAlgorithm algorithm) { return algorithm.diff(original, revised); }