[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Fix bug that leads to "Failed to get metadata for measurement"
commit f7b8225f006162d358aee7f58803f0bc6c7d3b26
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date: Thu Jan 12 13:28:35 2017 +0000
Fix bug that leads to "Failed to get metadata for measurement"
This happens when the test process dies before it's able to write the
running.pid file.
---
ooni/deck/deck.py | 7 +++----
ooni/measurements.py | 13 ++++++++-----
ooni/ui/web/server.py | 3 ++-
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/ooni/deck/deck.py b/ooni/deck/deck.py
index c57ccb63..7e4faa4e 100644
--- a/ooni/deck/deck.py
+++ b/ooni/deck/deck.py
@@ -1,4 +1,5 @@
import os
+import json
import uuid
import errno
import hashlib
@@ -36,14 +37,12 @@ def options_to_args(options):
for k, v in options.items():
if v is None:
continue
- if v == False or v == 0:
+ if isinstance(v, bool):
continue
if (len(k)) == 1:
args.append('-'+k)
else:
args.append('--'+k)
- if isinstance(v, bool) or isinstance(v, int):
- continue
args.append(v)
return args
@@ -112,7 +111,7 @@ class NGDeck(object):
if self.id is None:
# This happens when you load a deck not from a filepath so we
# use the first 16 characters of the SHA256 hexdigest as an ID
- self.id = hashlib.sha256(deck_data).hexdigest()[:16]
+ self.id = hashlib.sha256(json.dumps(deck_data)).hexdigest()[:16]
if global_options is not None:
self.global_options = normalize_options(global_options)
diff --git a/ooni/measurements.py b/ooni/measurements.py
index 68b5c555..2a4440ad 100644
--- a/ooni/measurements.py
+++ b/ooni/measurements.py
@@ -93,11 +93,14 @@ def get_measurement(measurement_id, compute_size=False):
stale = False
if measurement.child("measurements.njson.progress").exists():
completed = False
- pid = measurement.child("running.pid").open("r").read()
- pid = int(pid)
- if is_process_running(pid):
- running = True
- else:
+ try:
+ pid = measurement.child("running.pid").open("r").read()
+ pid = int(pid)
+ if is_process_running(pid):
+ running = True
+ else:
+ stale = True
+ except IOError:
stale = True
if measurement.child("keep").exists():
diff --git a/ooni/ui/web/server.py b/ooni/ui/web/server.py
index e009cb74..a79c1e19 100644
--- a/ooni/ui/web/server.py
+++ b/ooni/ui/web/server.py
@@ -481,7 +481,8 @@ class WebUIAPI(object):
raise WebUIError(
400, 'Insufficient privileges'
)
- except:
+ except Exception as exc:
+ log.exception(exc)
raise WebUIError(
500, 'Failed to start nettest'
)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits