Commits

David Krauth committed 98490b5

Incremental update

  • Participants
  • Parent commits 15c1378

Comments (0)

Files changed (2)

File utils/scores.py

     URL        = 'http://www.nfl.com/liveupdate/scorestrip/ss.xml'
     TYPE_CODE  = {
         'R': 'Regular Season',
-        'P': 'Preseason'
+        'P': 'Preseason',
+        'POST': 'Post Season'
     }
     URL_CODE = {
         'R': 'REG',
-        'P': 'PRE'
+        'P': 'PRE',
+        'POST': 'POST'
     }
     
     #---------------------------------------------------------------------------
 
 
 #-------------------------------------------------------------------------------
-def score_strip(playoffs=False, cache_ttl=120, on_cache_updated=None):
-    data = cache.get('nfl_score_strip')
+def score_strip(playoffs=False, cache_ttl=120, on_cache_updated=None, no_cache=False):
+    if no_cache:
+        data = None
+    else:
+        data = cache.get('nfl_score_strip')
+        
     if not data:
         try:
-            data = ScoreStrip(cls.POSTSEASON if playoffs else None).read_data()
-        except:
+            data = ScoreStrip(ScoreStrip.POSTSEASON if playoffs else None).read_data()
+        except Exception, why:
+            raise
             data = False
 
         cache.set('nfl_score_strip', data, cache_ttl)
 
 ################################################################################
 if __name__ == '__main__':
-    pprint(score_strip())
+    import sys
+    pprint(score_strip(len(sys.argv) > 1, no_cache=True))
 
 
 

File views/nfl_views.py

         return shortcuts.render_to_response(
             request,
             'nfl/score_strip.html',
-            dict(score_strip=scores.score_strip())
+            dict(score_strip=scores.score_strip(True))
         )
         
     raise http.Http404