prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  build_reporting fails if empty string in ignorelist
  The default configuration in the ubuntu 12.04 cobbler 2.6.5 package has the following in `/etc/settings`:
  
  ```
  build_reporting_ignorelist = [""]
  ```
  
  The code that reads this value is in `install_post_report.py`, and the condition that determines whether to send a build report email is:
  
  ```
  for prefix in settings.build_reporting_ignorelist:
    if name.lower().startswith(prefix) == True:
      sendmail = False
  ```
  
  With the default configuration, this check always succeeds, and **mail is not sent**.
  
  Fix the issue by modifying the condition to:
  
  ```
    if prefix != '' and name.lower().startswith(prefix):
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `cobbler/modules/install_post_report.py`
  Content:
  ```
  1 # (c) 2008-2009
  2 # Jeff Schroeder <jeffschroeder@computer.org>
  3 # Michael DeHaan <michael.dehaan AT gmail>
  4 #
  5 # License: GPLv2+
  6 
  7 # Post install trigger for cobbler to
  8 # send out a pretty email report that
  9 # contains target information.
  10 
  11 import distutils.sysconfig
  12 import smtplib
  13 import sys
  14 
  15 plib = distutils.sysconfig.get_python_lib()
  16 mod_path = "%s/cobbler" % plib
  17 sys.path.insert(0, mod_path)
  18 
  19 from cobbler.cexceptions import CX
  20 import cobbler.templar as templar
  21 import utils
  22 
  23 
  24 def register():
  25     # this pure python trigger acts as if it were a legacy shell-trigger, but is much faster.
  26     # the return of this method indicates the trigger type
  27     return "/var/lib/cobbler/triggers/install/post/*"
  28 
  29 
  30 def run(api, args, logger):
  31     # FIXME: make everything use the logger
  32 
  33     settings = api.settings()
  34 
  35     # go no further if this feature is turned off
  36     if not str(settings.build_reporting_enabled).lower() in ["1", "yes", "y", "true"]:
  37         return 0
  38 
  39     objtype = args[0]   # "target" or "profile"
  40     name = args[1]      # name of target or profile
  41     boot_ip = args[2]   # ip or "?"
  42 
  43     if objtype == "system":
  44         target = api.find_system(name)
  45     else:
  46         target = api.find_profile(name)
  47 
  48     # collapse the object down to a rendered datastructure
  49     target = utils.blender(api, False, target)
  50 
  51     if target == {}:
  52         raise CX("failure looking up target")
  53 
  54     to_addr = settings.build_reporting_email
  55     if to_addr == "":
  56         return 0
  57 
  58     # add the ability to specify an MTA for servers that don't run their own
  59     smtp_server = settings.build_reporting_smtp_server
  60     if smtp_server == "":
  61         smtp_server = "localhost"
  62 
  63     # use a custom from address or fall back to a reasonable default
  64     from_addr = settings.build_reporting_sender
  65     if from_addr == "":
  66         from_addr = "cobbler@%s" % settings.server
  67 
  68     subject = settings.build_reporting_subject
  69     if subject == "":
  70         subject = '[Cobbler] install complete '
  71 
  72     to_addr = ",".join(to_addr)
  73     metadata = {
  74         "from_addr": from_addr,
  75         "to_addr": to_addr,
  76         "subject": subject,
  77         "boot_ip": boot_ip
  78     }
  79     metadata.update(target)
  80 
  81     input_template = open("/etc/cobbler/reporting/build_report_email.template")
  82     input_data = input_template.read()
  83     input_template.close()
  84 
  85     message = templar.Templar(api._config).render(input_data, metadata, None)
  86 
  87     sendmail = True
  88     for prefix in settings.build_reporting_ignorelist:
  89         if name.lower().startswith(prefix):
  90             sendmail = False
  91 
  92     if sendmail:
  93         # Send the mail
  94         # FIXME: on error, return non-zero
  95         server_handle = smtplib.SMTP(smtp_server)
  96         server_handle.sendmail(from_addr, to_addr.split(','), message)
  97         server_handle.quit()
  98 
  99     return 0
  100
  ```
  --- 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/cobbler/modules/install_post_report.py b/cobbler/modules/install_post_report.py
  --- a/cobbler/modules/install_post_report.py
  +++ b/cobbler/modules/install_post_report.py
  @@ -86,7 +86,7 @@
   
       sendmail = True
       for prefix in settings.build_reporting_ignorelist:
  -        if name.lower().startswith(prefix):
  +        if prefix != '' and name.lower().startswith(prefix):
               sendmail = False
   
       if sendmail:
  
verification_info: {"golden_diff": "diff --git a/cobbler/modules/install_post_report.py b/cobbler/modules/install_post_report.py\n--- a/cobbler/modules/install_post_report.py\n+++ b/cobbler/modules/install_post_report.py\n@@ -86,7 +86,7 @@\n \n     sendmail = True\n     for prefix in settings.build_reporting_ignorelist:\n-        if name.lower().startswith(prefix):\n+        if prefix != '' and name.lower().startswith(prefix):\n             sendmail = False\n \n     if sendmail:\n", "issue": "build_reporting fails if empty string in ignorelist\nThe default configuration in the ubuntu 12.04 cobbler 2.6.5 package has the following in `/etc/settings`:\n\n```\nbuild_reporting_ignorelist = [\"\"]\n```\n\nThe code that reads this value is in `install_post_report.py`, and the condition that determines whether to send a build report email is:\n\n```\nfor prefix in settings.build_reporting_ignorelist:\n  if name.lower().startswith(prefix) == True:\n    sendmail = False\n```\n\nWith the default configuration, this check always succeeds, and **mail is not sent**.\n\nFix the issue by modifying the condition to:\n\n```\n  if prefix != '' and name.lower().startswith(prefix):\n```\n\n", "before_files": [{"content": "# (c) 2008-2009\n# Jeff Schroeder <jeffschroeder@computer.org>\n# Michael DeHaan <michael.dehaan AT gmail>\n#\n# License: GPLv2+\n\n# Post install trigger for cobbler to\n# send out a pretty email report that\n# contains target information.\n\nimport distutils.sysconfig\nimport smtplib\nimport sys\n\nplib = distutils.sysconfig.get_python_lib()\nmod_path = \"%s/cobbler\" % plib\nsys.path.insert(0, mod_path)\n\nfrom cobbler.cexceptions import CX\nimport cobbler.templar as templar\nimport utils\n\n\ndef register():\n    # this pure python trigger acts as if it were a legacy shell-trigger, but is much faster.\n    # the return of this method indicates the trigger type\n    return \"/var/lib/cobbler/triggers/install/post/*\"\n\n\ndef run(api, args, logger):\n    # FIXME: make everything use the logger\n\n    settings = api.settings()\n\n    # go no further if this feature is turned off\n    if not str(settings.build_reporting_enabled).lower() in [\"1\", \"yes\", \"y\", \"true\"]:\n        return 0\n\n    objtype = args[0]   # \"target\" or \"profile\"\n    name = args[1]      # name of target or profile\n    boot_ip = args[2]   # ip or \"?\"\n\n    if objtype == \"system\":\n        target = api.find_system(name)\n    else:\n        target = api.find_profile(name)\n\n    # collapse the object down to a rendered datastructure\n    target = utils.blender(api, False, target)\n\n    if target == {}:\n        raise CX(\"failure looking up target\")\n\n    to_addr = settings.build_reporting_email\n    if to_addr == \"\":\n        return 0\n\n    # add the ability to specify an MTA for servers that don't run their own\n    smtp_server = settings.build_reporting_smtp_server\n    if smtp_server == \"\":\n        smtp_server = \"localhost\"\n\n    # use a custom from address or fall back to a reasonable default\n    from_addr = settings.build_reporting_sender\n    if from_addr == \"\":\n        from_addr = \"cobbler@%s\" % settings.server\n\n    subject = settings.build_reporting_subject\n    if subject == \"\":\n        subject = '[Cobbler] install complete '\n\n    to_addr = \",\".join(to_addr)\n    metadata = {\n        \"from_addr\": from_addr,\n        \"to_addr\": to_addr,\n        \"subject\": subject,\n        \"boot_ip\": boot_ip\n    }\n    metadata.update(target)\n\n    input_template = open(\"/etc/cobbler/reporting/build_report_email.template\")\n    input_data = input_template.read()\n    input_template.close()\n\n    message = templar.Templar(api._config).render(input_data, metadata, None)\n\n    sendmail = True\n    for prefix in settings.build_reporting_ignorelist:\n        if name.lower().startswith(prefix):\n            sendmail = False\n\n    if sendmail:\n        # Send the mail\n        # FIXME: on error, return non-zero\n        server_handle = smtplib.SMTP(smtp_server)\n        server_handle.sendmail(from_addr, to_addr.split(','), message)\n        server_handle.quit()\n\n    return 0\n", "path": "cobbler/modules/install_post_report.py"}], "after_files": [{"content": "# (c) 2008-2009\n# Jeff Schroeder <jeffschroeder@computer.org>\n# Michael DeHaan <michael.dehaan AT gmail>\n#\n# License: GPLv2+\n\n# Post install trigger for cobbler to\n# send out a pretty email report that\n# contains target information.\n\nimport distutils.sysconfig\nimport smtplib\nimport sys\n\nplib = distutils.sysconfig.get_python_lib()\nmod_path = \"%s/cobbler\" % plib\nsys.path.insert(0, mod_path)\n\nfrom cobbler.cexceptions import CX\nimport cobbler.templar as templar\nimport utils\n\n\ndef register():\n    # this pure python trigger acts as if it were a legacy shell-trigger, but is much faster.\n    # the return of this method indicates the trigger type\n    return \"/var/lib/cobbler/triggers/install/post/*\"\n\n\ndef run(api, args, logger):\n    # FIXME: make everything use the logger\n\n    settings = api.settings()\n\n    # go no further if this feature is turned off\n    if not str(settings.build_reporting_enabled).lower() in [\"1\", \"yes\", \"y\", \"true\"]:\n        return 0\n\n    objtype = args[0]   # \"target\" or \"profile\"\n    name = args[1]      # name of target or profile\n    boot_ip = args[2]   # ip or \"?\"\n\n    if objtype == \"system\":\n        target = api.find_system(name)\n    else:\n        target = api.find_profile(name)\n\n    # collapse the object down to a rendered datastructure\n    target = utils.blender(api, False, target)\n\n    if target == {}:\n        raise CX(\"failure looking up target\")\n\n    to_addr = settings.build_reporting_email\n    if to_addr == \"\":\n        return 0\n\n    # add the ability to specify an MTA for servers that don't run their own\n    smtp_server = settings.build_reporting_smtp_server\n    if smtp_server == \"\":\n        smtp_server = \"localhost\"\n\n    # use a custom from address or fall back to a reasonable default\n    from_addr = settings.build_reporting_sender\n    if from_addr == \"\":\n        from_addr = \"cobbler@%s\" % settings.server\n\n    subject = settings.build_reporting_subject\n    if subject == \"\":\n        subject = '[Cobbler] install complete '\n\n    to_addr = \",\".join(to_addr)\n    metadata = {\n        \"from_addr\": from_addr,\n        \"to_addr\": to_addr,\n        \"subject\": subject,\n        \"boot_ip\": boot_ip\n    }\n    metadata.update(target)\n\n    input_template = open(\"/etc/cobbler/reporting/build_report_email.template\")\n    input_data = input_template.read()\n    input_template.close()\n\n    message = templar.Templar(api._config).render(input_data, metadata, None)\n\n    sendmail = True\n    for prefix in settings.build_reporting_ignorelist:\n        if prefix != '' and name.lower().startswith(prefix):\n            sendmail = False\n\n    if sendmail:\n        # Send the mail\n        # FIXME: on error, return non-zero\n        server_handle = smtplib.SMTP(smtp_server)\n        server_handle.sendmail(from_addr, to_addr.split(','), message)\n        server_handle.quit()\n\n    return 0\n", "path": "cobbler/modules/install_post_report.py"}]}