Permalink
Browse files

Improve logging.

  • Loading branch information...
1 parent 023c467 commit 9dc06ec2a98b872bac56ab77d0d13da6aa21f604 Schuyler Erle committed Jun 16, 2011
Showing with 9 additions and 8 deletions.
  1. +9 −8 geocrawlr.py
View
@@ -1,8 +1,8 @@
import Flickr.API
-import json, time, sys
+import json, time, sys, os
-FLICKR_KEY = ""
-FLICKR_SECRET = ""
+FLICKR_KEY = os.environ["FLICKR_KEY"]
+FLICKR_SECRET = os.environ["FLICKR_SECRET"]
START_PAGE = 1
END_PAGE = 10
@@ -19,7 +19,7 @@
method="flickr.photos.search",
format="json",
nojsoncallback=1,
- #sort="interestingness-desc",
+ sort="interestingness-desc",
page=page,
woe_id=woe_id,
extras="geo",
@@ -32,16 +32,17 @@
response = api.execute_request(request).read()
except Exception, e:
print >>sys.stderr, "Retrying due to:", e
- print >>sys.stderr, "%.1fs elapsed." % (time.time()-start)
try:
- result = json.loads(response)["photos"]
+ result = json.loads(response)
+ result = result["photos"]
+ print >>sys.stderr, "%d results, %.1fs elapsed." % (len(result["photo"]),time.time()-start)
for item in result["photo"]:
try:
print "\t".join(str(item[k]) for k in ("id","woeid","longitude","latitude"))
except Exception, e:
print >>sys.stderr, e
total_pages = min(int(result["pages"]), END_PAGE)
#time.sleep(1.0)
- except:
- pass
+ except Exception, e:
+ print >>sys.stderr, e
page += 1

0 comments on commit 9dc06ec

Please sign in to comment.