prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Stop emailing us when there's a paper jam
  ```
  A problem was encountered and reported via ocflib:
  
  An exception occured in an ocfweb periodic function:
  
  Traceback (most recent call last):
    File "/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/caching.py", line 56, in cache_lookup_with_fallback
      raise KeyError('Forcing miss as requested.')
  KeyError: 'Forcing miss as requested.'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/bin/run_periodic_functions.py", line 47, in run_periodic_functions
      pf.update()
    File "/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/caching.py", line 214, in update
      force_miss=True,
    File "/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/caching.py", line 66, in cache_lookup_with_fallback
      result = fallback()
    File "/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/caching.py", line 170, in function_with_timestamp
      return (datetime.now(), self.function())
    File "/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/stats/summary.py", line 68, in printers
      for printer in PRINTERS
    File "/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/stats/summary.py", line 68, in <genexpr>
      for printer in PRINTERS
    File "/usr/share/python/ocfweb/lib/python3.4/site-packages/ocflib/lab/printing.py", line 40, in get_toner
      for oid in (OID_TONER_CUR, OID_TONER_MAX)
    File "/usr/share/python/ocfweb/lib/python3.4/site-packages/ocflib/lab/printing.py", line 40, in <genexpr>
      for oid in (OID_TONER_CUR, OID_TONER_MAX)
    File "/usr/share/python/ocfweb/lib/python3.4/site-packages/ocflib/lab/printing.py", line 30, in _snmp
      'Device {} returned error status: {}'.format(host, err_status),
  OSError: Device deforestation returned error status: 5
  
  
  Periodic function:
    * Key: ('2016.01.20.18.11-gitbf0aae55', 'ocfweb.stats.summary#printers', (), ())
    * Last Update: 2016-01-21 15:48:30.668738 (61.003647 seconds ago)
  
  
    * Period: 60
    * TTL: 120
  
  The background process will now pause for 30 seconds.
  
  
  ====
  Hostname: coma.ocf.berkeley.edu
  Callstack:
      at /usr/share/python/ocfweb/lib/python3.4/site-packages/ocflib/misc/mail.py:59 (send_problem_report)
          by /usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/bin/run_periodic_functions.py:73 (run_periodic_functions)
          by /usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/bin/run_periodic_functions.py:116 (main)
          by /usr/share/python/ocfweb/bin/ocfweb-run-periodic-functions:9 (<module>)
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `ocfweb/stats/summary.py`
  Content:
  ```
  1 from datetime import date
  2 from datetime import datetime
  3 from operator import attrgetter
  4 
  5 from django.shortcuts import render
  6 from ocflib.constants import CURRENT_SEMESTER_START
  7 from ocflib.lab.printing import get_maintkit
  8 from ocflib.lab.printing import get_toner
  9 from ocflib.lab.printing import PRINTERS
  10 from ocflib.lab.stats import list_desktops
  11 from ocflib.lab.stats import staff_in_lab as real_staff_in_lab
  12 from ocflib.lab.stats import STATS_EPOCH
  13 from ocflib.lab.stats import top_staff_alltime as real_top_staff_alltime
  14 from ocflib.lab.stats import top_staff_semester as real_top_staff_semester
  15 from ocflib.lab.stats import users_in_lab_count as real_users_in_lab_count
  16 from ocflib.lab.stats import UtilizationProfile
  17 
  18 from ocfweb.caching import periodic
  19 from ocfweb.stats.daily_graph import get_open_close
  20 
  21 
  22 @periodic(60)
  23 def desktop_profiles():
  24     open_, close = get_open_close(date.today())
  25     now = datetime.today()
  26 
  27     # If the lab has opened, but hasn't closed yet, only count
  28     # statistics until the current time. If the lab isn't open
  29     # yet, then don't count anything, and if it is closed, show
  30     # statistics from when it was open during the day.
  31     if now > open_ and now < close:
  32         end = now
  33     elif now <= open_:
  34         end = open_
  35     else:
  36         end = close
  37 
  38     return sorted(
  39         UtilizationProfile.from_hostnames(list_desktops(), open_, end).values(),
  40         key=attrgetter('hostname'),
  41     )
  42 
  43 
  44 @periodic(30)
  45 def staff_in_lab():
  46     return real_staff_in_lab()
  47 
  48 
  49 @periodic(300)
  50 def top_staff_alltime():
  51     return real_top_staff_alltime()
  52 
  53 
  54 @periodic(300)
  55 def top_staff_semester():
  56     return real_top_staff_semester()
  57 
  58 
  59 @periodic(30)
  60 def users_in_lab_count():
  61     return real_users_in_lab_count()
  62 
  63 
  64 @periodic(60)
  65 def printers():
  66     return sorted(
  67         (printer, get_toner(printer), get_maintkit(printer))
  68         for printer in PRINTERS
  69     )
  70 
  71 
  72 def summary(request):
  73     return render(
  74         request,
  75         'summary.html',
  76         {
  77             'title': 'Lab Statistics',
  78             'desktop_profiles': desktop_profiles(),
  79             'current_semester_start': CURRENT_SEMESTER_START,
  80             'stats_epoch': STATS_EPOCH,
  81             'staff_in_lab': staff_in_lab(),
  82             'top_staff_alltime': top_staff_alltime()[:10],
  83             'top_staff_semester': top_staff_semester()[:10],
  84             'users_in_lab_count': users_in_lab_count(),
  85             'printers': printers(),
  86         },
  87     )
  88
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/ocfweb/stats/summary.py b/ocfweb/stats/summary.py
  --- a/ocfweb/stats/summary.py
  +++ b/ocfweb/stats/summary.py
  @@ -1,3 +1,4 @@
  +import logging
   from datetime import date
   from datetime import datetime
   from operator import attrgetter
  @@ -19,6 +20,9 @@
   from ocfweb.stats.daily_graph import get_open_close
   
   
  +_logger = logging.getLogger(__name__)
  +
  +
   @periodic(60)
   def desktop_profiles():
       open_, close = get_open_close(date.today())
  @@ -63,8 +67,17 @@
   
   @periodic(60)
   def printers():
  +    def silence(f):
  +        def inner(*args, **kwargs):
  +            try:
  +                return f(*args, **kwargs)
  +            except OSError as ex:
  +                _logger.warn('Silencing exception reading printer data: {}'.format(ex))
  +                return None
  +        return inner
  +
       return sorted(
  -        (printer, get_toner(printer), get_maintkit(printer))
  +        (printer, silence(get_toner)(printer), silence(get_maintkit)(printer))
           for printer in PRINTERS
       )
  
verification_info: {"golden_diff": "diff --git a/ocfweb/stats/summary.py b/ocfweb/stats/summary.py\n--- a/ocfweb/stats/summary.py\n+++ b/ocfweb/stats/summary.py\n@@ -1,3 +1,4 @@\n+import logging\n from datetime import date\n from datetime import datetime\n from operator import attrgetter\n@@ -19,6 +20,9 @@\n from ocfweb.stats.daily_graph import get_open_close\n \n \n+_logger = logging.getLogger(__name__)\n+\n+\n @periodic(60)\n def desktop_profiles():\n     open_, close = get_open_close(date.today())\n@@ -63,8 +67,17 @@\n \n @periodic(60)\n def printers():\n+    def silence(f):\n+        def inner(*args, **kwargs):\n+            try:\n+                return f(*args, **kwargs)\n+            except OSError as ex:\n+                _logger.warn('Silencing exception reading printer data: {}'.format(ex))\n+                return None\n+        return inner\n+\n     return sorted(\n-        (printer, get_toner(printer), get_maintkit(printer))\n+        (printer, silence(get_toner)(printer), silence(get_maintkit)(printer))\n         for printer in PRINTERS\n     )\n", "issue": "Stop emailing us when there's a paper jam\n```\nA problem was encountered and reported via ocflib:\n\nAn exception occured in an ocfweb periodic function:\n\nTraceback (most recent call last):\n  File \"/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/caching.py\", line 56, in cache_lookup_with_fallback\n    raise KeyError('Forcing miss as requested.')\nKeyError: 'Forcing miss as requested.'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/bin/run_periodic_functions.py\", line 47, in run_periodic_functions\n    pf.update()\n  File \"/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/caching.py\", line 214, in update\n    force_miss=True,\n  File \"/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/caching.py\", line 66, in cache_lookup_with_fallback\n    result = fallback()\n  File \"/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/caching.py\", line 170, in function_with_timestamp\n    return (datetime.now(), self.function())\n  File \"/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/stats/summary.py\", line 68, in printers\n    for printer in PRINTERS\n  File \"/usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/stats/summary.py\", line 68, in <genexpr>\n    for printer in PRINTERS\n  File \"/usr/share/python/ocfweb/lib/python3.4/site-packages/ocflib/lab/printing.py\", line 40, in get_toner\n    for oid in (OID_TONER_CUR, OID_TONER_MAX)\n  File \"/usr/share/python/ocfweb/lib/python3.4/site-packages/ocflib/lab/printing.py\", line 40, in <genexpr>\n    for oid in (OID_TONER_CUR, OID_TONER_MAX)\n  File \"/usr/share/python/ocfweb/lib/python3.4/site-packages/ocflib/lab/printing.py\", line 30, in _snmp\n    'Device {} returned error status: {}'.format(host, err_status),\nOSError: Device deforestation returned error status: 5\n\n\nPeriodic function:\n  * Key: ('2016.01.20.18.11-gitbf0aae55', 'ocfweb.stats.summary#printers', (), ())\n  * Last Update: 2016-01-21 15:48:30.668738 (61.003647 seconds ago)\n\n\n  * Period: 60\n  * TTL: 120\n\nThe background process will now pause for 30 seconds.\n\n\n====\nHostname: coma.ocf.berkeley.edu\nCallstack:\n    at /usr/share/python/ocfweb/lib/python3.4/site-packages/ocflib/misc/mail.py:59 (send_problem_report)\n        by /usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/bin/run_periodic_functions.py:73 (run_periodic_functions)\n        by /usr/share/python/ocfweb/lib/python3.4/site-packages/ocfweb/bin/run_periodic_functions.py:116 (main)\n        by /usr/share/python/ocfweb/bin/ocfweb-run-periodic-functions:9 (<module>)\n```\n\n", "before_files": [{"content": "from datetime import date\nfrom datetime import datetime\nfrom operator import attrgetter\n\nfrom django.shortcuts import render\nfrom ocflib.constants import CURRENT_SEMESTER_START\nfrom ocflib.lab.printing import get_maintkit\nfrom ocflib.lab.printing import get_toner\nfrom ocflib.lab.printing import PRINTERS\nfrom ocflib.lab.stats import list_desktops\nfrom ocflib.lab.stats import staff_in_lab as real_staff_in_lab\nfrom ocflib.lab.stats import STATS_EPOCH\nfrom ocflib.lab.stats import top_staff_alltime as real_top_staff_alltime\nfrom ocflib.lab.stats import top_staff_semester as real_top_staff_semester\nfrom ocflib.lab.stats import users_in_lab_count as real_users_in_lab_count\nfrom ocflib.lab.stats import UtilizationProfile\n\nfrom ocfweb.caching import periodic\nfrom ocfweb.stats.daily_graph import get_open_close\n\n\n@periodic(60)\ndef desktop_profiles():\n    open_, close = get_open_close(date.today())\n    now = datetime.today()\n\n    # If the lab has opened, but hasn't closed yet, only count\n    # statistics until the current time. If the lab isn't open\n    # yet, then don't count anything, and if it is closed, show\n    # statistics from when it was open during the day.\n    if now > open_ and now < close:\n        end = now\n    elif now <= open_:\n        end = open_\n    else:\n        end = close\n\n    return sorted(\n        UtilizationProfile.from_hostnames(list_desktops(), open_, end).values(),\n        key=attrgetter('hostname'),\n    )\n\n\n@periodic(30)\ndef staff_in_lab():\n    return real_staff_in_lab()\n\n\n@periodic(300)\ndef top_staff_alltime():\n    return real_top_staff_alltime()\n\n\n@periodic(300)\ndef top_staff_semester():\n    return real_top_staff_semester()\n\n\n@periodic(30)\ndef users_in_lab_count():\n    return real_users_in_lab_count()\n\n\n@periodic(60)\ndef printers():\n    return sorted(\n        (printer, get_toner(printer), get_maintkit(printer))\n        for printer in PRINTERS\n    )\n\n\ndef summary(request):\n    return render(\n        request,\n        'summary.html',\n        {\n            'title': 'Lab Statistics',\n            'desktop_profiles': desktop_profiles(),\n            'current_semester_start': CURRENT_SEMESTER_START,\n            'stats_epoch': STATS_EPOCH,\n            'staff_in_lab': staff_in_lab(),\n            'top_staff_alltime': top_staff_alltime()[:10],\n            'top_staff_semester': top_staff_semester()[:10],\n            'users_in_lab_count': users_in_lab_count(),\n            'printers': printers(),\n        },\n    )\n", "path": "ocfweb/stats/summary.py"}], "after_files": [{"content": "import logging\nfrom datetime import date\nfrom datetime import datetime\nfrom operator import attrgetter\n\nfrom django.shortcuts import render\nfrom ocflib.constants import CURRENT_SEMESTER_START\nfrom ocflib.lab.printing import get_maintkit\nfrom ocflib.lab.printing import get_toner\nfrom ocflib.lab.printing import PRINTERS\nfrom ocflib.lab.stats import list_desktops\nfrom ocflib.lab.stats import staff_in_lab as real_staff_in_lab\nfrom ocflib.lab.stats import STATS_EPOCH\nfrom ocflib.lab.stats import top_staff_alltime as real_top_staff_alltime\nfrom ocflib.lab.stats import top_staff_semester as real_top_staff_semester\nfrom ocflib.lab.stats import users_in_lab_count as real_users_in_lab_count\nfrom ocflib.lab.stats import UtilizationProfile\n\nfrom ocfweb.caching import periodic\nfrom ocfweb.stats.daily_graph import get_open_close\n\n\n_logger = logging.getLogger(__name__)\n\n\n@periodic(60)\ndef desktop_profiles():\n    open_, close = get_open_close(date.today())\n    now = datetime.today()\n\n    # If the lab has opened, but hasn't closed yet, only count\n    # statistics until the current time. If the lab isn't open\n    # yet, then don't count anything, and if it is closed, show\n    # statistics from when it was open during the day.\n    if now > open_ and now < close:\n        end = now\n    elif now <= open_:\n        end = open_\n    else:\n        end = close\n\n    return sorted(\n        UtilizationProfile.from_hostnames(list_desktops(), open_, end).values(),\n        key=attrgetter('hostname'),\n    )\n\n\n@periodic(30)\ndef staff_in_lab():\n    return real_staff_in_lab()\n\n\n@periodic(300)\ndef top_staff_alltime():\n    return real_top_staff_alltime()\n\n\n@periodic(300)\ndef top_staff_semester():\n    return real_top_staff_semester()\n\n\n@periodic(30)\ndef users_in_lab_count():\n    return real_users_in_lab_count()\n\n\n@periodic(60)\ndef printers():\n    def silence(f):\n        def inner(*args, **kwargs):\n            try:\n                return f(*args, **kwargs)\n            except OSError as ex:\n                _logger.warn('Silencing exception reading printer data: {}'.format(ex))\n                return None\n        return inner\n\n    return sorted(\n        (printer, silence(get_toner)(printer), silence(get_maintkit)(printer))\n        for printer in PRINTERS\n    )\n\n\ndef summary(request):\n    return render(\n        request,\n        'summary.html',\n        {\n            'title': 'Lab Statistics',\n            'desktop_profiles': desktop_profiles(),\n            'current_semester_start': CURRENT_SEMESTER_START,\n            'stats_epoch': STATS_EPOCH,\n            'staff_in_lab': staff_in_lab(),\n            'top_staff_alltime': top_staff_alltime()[:10],\n            'top_staff_semester': top_staff_semester()[:10],\n            'users_in_lab_count': users_in_lab_count(),\n            'printers': printers(),\n        },\n    )\n", "path": "ocfweb/stats/summary.py"}]}