Explorar el Código

handle queries for days with no data

raylu hace 11 años
padre
commit
f1aaac2533
Se han modificado 1 ficheros con 9 adiciones y 3 borrados
  1. 9 3
      api/server.py

+ 9 - 3
api/server.py

@@ -84,9 +84,15 @@ def get_data(split, query, environ):
 	c = start
 	while c <= end:
 		date_str = c.isoformat()
-		with open(path.join(server_dir, date_str), 'r') as f:
-			stats = fileio.read_stats(f)
-			rval[date_str] = stats
+		try:
+			with open(path.join(server_dir, date_str), 'r') as f:
+				stats = fileio.read_stats(f)
+		except IOError as e:
+			if e.errno == errno.ENOENT:
+				stats = None
+			else:
+				raise
+		rval[date_str] = stats
 		c += datetime.timedelta(days=1)
 	return rval