David Krauth avatar David Krauth committed 98490b5

Incremental update

Comments (0)

Files changed (2)

     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))
 
 
 

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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.