Skip to content
Browse files

Work around recently-released dataset issues

  • Loading branch information...
1 parent 0d32e97 commit db5ab77c20ab328c4f0a363d75c57e0bf277b844 @danielrichman danielrichman committed Feb 8, 2013
Showing with 12 additions and 2 deletions.
  1. +12 −2 predict.py
View
14 predict.py
@@ -9,6 +9,7 @@
import math
import sys
import os
+import socket
import logging
import traceback
import calendar
@@ -560,9 +561,18 @@ def possible_urls(time, hd):
latest = time
if hd:
- url_format = 'http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd%i%02i%02i/gfs_hd_%02iz'
+ url_format = 'http://{host}:9090/dods/gfs_hd/gfs_hd%i%02i%02i/gfs_hd_%02iz'
else:
- url_format = 'http://nomads.ncep.noaa.gov:9090/dods/gfs/gfs%i%02i%02i/gfs_%02iz'
+ url_format = 'http://{host}:9090/dods/gfs/gfs%i%02i%02i/gfs_%02iz'
+
+ # Often we have issues where one IP address (the DNS resolves to 2 or more)
+ # will have a dataset and the other one won't yet.
+ # This causes "blah is not an available dataset" errors since predict.py
+ # thinks it's OK to use a recent one, and then by chance we end up talking
+ # to a server on a later request that doesn't have it.
+ selected_ip = socket.gethostbyname("nomads.ncep.noaa.gov")
+ log.info("Picked IP: {0}".format(selected_ip))
+ url_format = url_format.format(host=selected_ip)
# Start from the latest, work to the earliest
proposed = latest

0 comments on commit db5ab77

Please sign in to comment.
Something went wrong with that request. Please try again.