prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Windows agent connection error
  agent version: 4.4
  OS: Windows 2008 Standard, SP2.
  case: https://datadog.desk.com/agent/case/11902
  - log snippet:
  
  > 2014-06-24 13:45:04 Eastern Daylight Time | ERROR | forwarder(ddagent.pyc:240) | Response: HTTPResponse(_body=None,buffer=None,code=599,effective_url='https://app.datadoghq.com/intake?api_key=#################',error=gaierror(11001, 'getaddrinfo failed'),headers={},reason='Unknown',request=<tornado.httpclient.HTTPRequest object at 0x01212170>,request_time=0.018000125885009766,time_info={})
  > 
  > 2014-06-24 13:45:04 Eastern Daylight Time | WARNING | transaction(transaction.pyc:213) | Transaction 4 in error (5 errors), it will be replayed after 2014-06-24 13:46:34
  > 
  > 2014-06-24 13:45:05 Eastern Daylight Time | INFO | win32.agent(agent.pyc:91) | pup has died. Restarting...
  > 
  > 2014-06-24 13:45:05 Eastern Daylight Time | ERROR | forwarder(ddagent.pyc:240) | Response: HTTPResponse(_body=None,buffer=None,code=599,effective_url='https://app.datadoghq.com/api/v1/series/?api_key=################',error=gaierror(11001, 'getaddrinfo failed`
  - able to TCP connection (80 and 443) to app.datadoghq.com
    EDIT:
    
    > telnet app.datadoghq.com 80
    > telnet app.datadoghq.com 443
  - from agent python shell:
    
    > print socket.getaddrinfo('app.datadoghq.com',443)
    > Traceback (most recent call last):
    > File "shell.py", line 13, in shell
    > File "<string>", line 1, in <module>
    > gaierror: [Errno 11001] getaddrinfo failed
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `setup.py`
  Content:
  ```
  1 import platform
  2 import sys
  3 from config import get_version
  4 from jmxfetch import JMX_FETCH_JAR_NAME
  5 
  6 try:
  7     from setuptools import setup, find_packages
  8 
  9     # required to build the cython extensions
  10     from distutils.extension import Extension #pylint: disable=no-name-in-module
  11 
  12 except ImportError:
  13     from ez_setup import use_setuptools
  14     use_setuptools()
  15     from setuptools import setup, find_packages
  16 
  17 # Extra arguments to pass to the setup function
  18 extra_args = {}
  19 
  20 # Prereqs of the build. Won't get installed when deploying the egg.
  21 setup_requires = [
  22 ]
  23 
  24 # Prereqs of the install. Will install when deploying the egg.
  25 install_requires=[
  26 ]
  27 
  28 if sys.platform == 'win32':
  29     from glob import glob
  30     import py2exe
  31     install_requires.extend([
  32         'tornado==3.0.1',
  33         'pywin32==217',
  34         'wmi==1.4.9',
  35         'simplejson==2.6.1',
  36         'mysql-python==1.2.3',
  37         'pymongo==2.3',
  38         'pg8000',
  39         'python-memcached==1.48',
  40         'adodbapi'
  41         'elementtree',
  42         'pycurl',
  43         'pymysql',
  44         'psutil',
  45         'redis',
  46         'requests',
  47         'httplib2==0.9',
  48     ])
  49 
  50     # Modules to force-include in the exe
  51     include_modules = [
  52         # 3p
  53         'win32service',
  54         'win32serviceutil',
  55         'win32event',
  56         'simplejson',
  57         'adodbapi',
  58         'elementtree.ElementTree',
  59         'pycurl',
  60         'tornado.curl_httpclient',
  61         'pymongo',
  62         'pymysql',
  63         'psutil',
  64         'pg8000',
  65         'redis',
  66         'requests',
  67 
  68         # agent
  69         'checks.services_checks',
  70         'httplib2',
  71 
  72         # pup
  73         'pup',
  74         'pup.pup',
  75         'tornado.websocket',
  76         'tornado.web',
  77         'tornado.ioloop',
  78     ]
  79 
  80     class Target(object):
  81         def __init__(self, **kw):
  82             self.__dict__.update(kw) 
  83             self.version = get_version()
  84             self.company_name = 'Datadog, Inc.'
  85             self.copyright = 'Copyright 2013 Datadog, Inc.'
  86             self.cmdline_style = 'pywin32'
  87 
  88     agent_svc = Target(name='Datadog Agent', modules='win32.agent', dest_base='ddagent')
  89 
  90     extra_args = {
  91         'options': {
  92             'py2exe': {
  93                 'includes': ','.join(include_modules),
  94                 'optimize': 0,
  95                 'compressed': True,
  96                 'bundle_files': 3,
  97             },
  98         },
  99         'console': ['win32\shell.py'],
  100         'service': [agent_svc],
  101         'windows': [{'script': 'win32\gui.py',
  102                      'dest_base': "agent-manager",
  103                      'uac_info': "requireAdministrator", # The manager needs to be administrator to stop/start the service
  104                      'icon_resources': [(1, r"packaging\datadog-agent\win32\install_files\dd_agent_win_256.ico")],
  105                      }],
  106         'data_files': [
  107             ("Microsoft.VC90.CRT", glob(r'C:\Python27\redist\*.*')),
  108             ('pup', glob('pup/pup.html')),
  109             ('pup', glob('pup/status.html')),
  110             ('pup/static', glob('pup/static/*.*')),
  111             ('jmxfetch', glob('checks/libs/%s' % JMX_FETCH_JAR_NAME)),
  112         ],
  113     }
  114 
  115 setup(
  116     name='datadog-agent',
  117     version=get_version(),
  118     description="DevOps' best friend",
  119     author='DataDog',
  120     author_email='dev@datadoghq.com',
  121     url='http://www.datadoghq.com',
  122     install_requires=install_requires,
  123     setup_requires=setup_requires,
  124     packages=find_packages(exclude=['ez_setup']),
  125     include_package_data=True,
  126     test_suite='nose.collector',
  127     zip_safe=False,
  128     **extra_args
  129 )
  130
  ```
  --- 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/setup.py b/setup.py
  --- a/setup.py
  +++ b/setup.py
  @@ -94,6 +94,7 @@
                   'optimize': 0,
                   'compressed': True,
                   'bundle_files': 3,
  +                'dll_excludes': [ "IPHLPAPI.DLL", "NSI.dll",  "WINNSI.DLL",  "WTSAPI32.dll"],
               },
           },
           'console': ['win32\shell.py'],
  
verification_info: {"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -94,6 +94,7 @@\n                 'optimize': 0,\n                 'compressed': True,\n                 'bundle_files': 3,\n+                'dll_excludes': [ \"IPHLPAPI.DLL\", \"NSI.dll\",  \"WINNSI.DLL\",  \"WTSAPI32.dll\"],\n             },\n         },\n         'console': ['win32\\shell.py'],\n", "issue": "Windows agent connection error\nagent version: 4.4\nOS: Windows 2008 Standard, SP2.\ncase: https://datadog.desk.com/agent/case/11902\n- log snippet:\n\n> 2014-06-24 13:45:04 Eastern Daylight Time | ERROR | forwarder(ddagent.pyc:240) | Response: HTTPResponse(_body=None,buffer=None,code=599,effective_url='https://app.datadoghq.com/intake?api_key=#################',error=gaierror(11001, 'getaddrinfo failed'),headers={},reason='Unknown',request=<tornado.httpclient.HTTPRequest object at 0x01212170>,request_time=0.018000125885009766,time_info={})\n> \n> 2014-06-24 13:45:04 Eastern Daylight Time | WARNING | transaction(transaction.pyc:213) | Transaction 4 in error (5 errors), it will be replayed after 2014-06-24 13:46:34\n> \n> 2014-06-24 13:45:05 Eastern Daylight Time | INFO | win32.agent(agent.pyc:91) | pup has died. Restarting...\n> \n> 2014-06-24 13:45:05 Eastern Daylight Time | ERROR | forwarder(ddagent.pyc:240) | Response: HTTPResponse(_body=None,buffer=None,code=599,effective_url='https://app.datadoghq.com/api/v1/series/?api_key=################',error=gaierror(11001, 'getaddrinfo failed`\n- able to TCP connection (80 and 443) to app.datadoghq.com\n  EDIT:\n  \n  > telnet app.datadoghq.com 80\n  > telnet app.datadoghq.com 443\n- from agent python shell:\n  \n  > print socket.getaddrinfo('app.datadoghq.com',443)\n  > Traceback (most recent call last):\n  > File \"shell.py\", line 13, in shell\n  > File \"<string>\", line 1, in <module>\n  > gaierror: [Errno 11001] getaddrinfo failed\n\n", "before_files": [{"content": "import platform\nimport sys\nfrom config import get_version\nfrom jmxfetch import JMX_FETCH_JAR_NAME\n\ntry:\n    from setuptools import setup, find_packages\n\n    # required to build the cython extensions\n    from distutils.extension import Extension #pylint: disable=no-name-in-module\n\nexcept ImportError:\n    from ez_setup import use_setuptools\n    use_setuptools()\n    from setuptools import setup, find_packages\n\n# Extra arguments to pass to the setup function\nextra_args = {}\n\n# Prereqs of the build. Won't get installed when deploying the egg.\nsetup_requires = [\n]\n\n# Prereqs of the install. Will install when deploying the egg.\ninstall_requires=[\n]\n\nif sys.platform == 'win32':\n    from glob import glob\n    import py2exe\n    install_requires.extend([\n        'tornado==3.0.1',\n        'pywin32==217',\n        'wmi==1.4.9',\n        'simplejson==2.6.1',\n        'mysql-python==1.2.3',\n        'pymongo==2.3',\n        'pg8000',\n        'python-memcached==1.48',\n        'adodbapi'\n        'elementtree',\n        'pycurl',\n        'pymysql',\n        'psutil',\n        'redis',\n        'requests',\n        'httplib2==0.9',\n    ])\n\n    # Modules to force-include in the exe\n    include_modules = [\n        # 3p\n        'win32service',\n        'win32serviceutil',\n        'win32event',\n        'simplejson',\n        'adodbapi',\n        'elementtree.ElementTree',\n        'pycurl',\n        'tornado.curl_httpclient',\n        'pymongo',\n        'pymysql',\n        'psutil',\n        'pg8000',\n        'redis',\n        'requests',\n\n        # agent\n        'checks.services_checks',\n        'httplib2',\n\n        # pup\n        'pup',\n        'pup.pup',\n        'tornado.websocket',\n        'tornado.web',\n        'tornado.ioloop',\n    ]\n\n    class Target(object):\n        def __init__(self, **kw):\n            self.__dict__.update(kw) \n            self.version = get_version()\n            self.company_name = 'Datadog, Inc.'\n            self.copyright = 'Copyright 2013 Datadog, Inc.'\n            self.cmdline_style = 'pywin32'\n\n    agent_svc = Target(name='Datadog Agent', modules='win32.agent', dest_base='ddagent')\n\n    extra_args = {\n        'options': {\n            'py2exe': {\n                'includes': ','.join(include_modules),\n                'optimize': 0,\n                'compressed': True,\n                'bundle_files': 3,\n            },\n        },\n        'console': ['win32\\shell.py'],\n        'service': [agent_svc],\n        'windows': [{'script': 'win32\\gui.py',\n                     'dest_base': \"agent-manager\",\n                     'uac_info': \"requireAdministrator\", # The manager needs to be administrator to stop/start the service\n                     'icon_resources': [(1, r\"packaging\\datadog-agent\\win32\\install_files\\dd_agent_win_256.ico\")],\n                     }],\n        'data_files': [\n            (\"Microsoft.VC90.CRT\", glob(r'C:\\Python27\\redist\\*.*')),\n            ('pup', glob('pup/pup.html')),\n            ('pup', glob('pup/status.html')),\n            ('pup/static', glob('pup/static/*.*')),\n            ('jmxfetch', glob('checks/libs/%s' % JMX_FETCH_JAR_NAME)),\n        ],\n    }\n\nsetup(\n    name='datadog-agent',\n    version=get_version(),\n    description=\"DevOps' best friend\",\n    author='DataDog',\n    author_email='dev@datadoghq.com',\n    url='http://www.datadoghq.com',\n    install_requires=install_requires,\n    setup_requires=setup_requires,\n    packages=find_packages(exclude=['ez_setup']),\n    include_package_data=True,\n    test_suite='nose.collector',\n    zip_safe=False,\n    **extra_args\n)\n", "path": "setup.py"}], "after_files": [{"content": "import platform\nimport sys\nfrom config import *\nfrom jmxfetch import JMX_FETCH_JAR_NAME\n\ntry:\n    from setuptools import setup, find_packages\n\n    # required to build the cython extensions\n    from distutils.extension import Extension #pylint: disable=no-name-in-module\n\nexcept ImportError:\n    from ez_setup import use_setuptools\n    use_setuptools()\n    from setuptools import setup, find_packages\n\n# Extra arguments to pass to the setup function\nextra_args = {}\n\n# Prereqs of the build. Won't get installed when deploying the egg.\nsetup_requires = [\n]\n\n# Prereqs of the install. Will install when deploying the egg.\ninstall_requires=[\n]\n\nif sys.platform == 'win32':\n    from glob import glob\n    import py2exe\n    install_requires.extend([\n        'tornado==3.0.1',\n        'pywin32==217',\n        'wmi==1.4.9',\n        'simplejson==2.6.1',\n        'mysql-python==1.2.3',\n        'pymongo==2.3',\n        'pg8000',\n        'python-memcached==1.48',\n        'adodbapi'\n        'elementtree',\n        'pycurl',\n        'pymysql',\n        'psutil',\n        'redis',\n        'requests',\n        'httplib2==0.9',\n    ])\n\n    # Modules to force-include in the exe\n    include_modules = [\n        # 3p\n        'win32service',\n        'win32serviceutil',\n        'win32event',\n        'simplejson',\n        'adodbapi',\n        'elementtree.ElementTree',\n        'pycurl',\n        'tornado.curl_httpclient',\n        'pymongo',\n        'pymysql',\n        'psutil',\n        'pg8000',\n        'redis',\n        'requests',\n\n        # agent\n        'checks.services_checks',\n        'httplib2',\n\n        # pup\n        'pup',\n        'pup.pup',\n        'tornado.websocket',\n        'tornado.web',\n        'tornado.ioloop',\n    ]\n\n    class Target(object):\n        def __init__(self, **kw):\n            self.__dict__.update(kw) \n            self.version = get_version()\n            self.company_name = 'Datadog, Inc.'\n            self.copyright = 'Copyright 2013 Datadog, Inc.'\n            self.cmdline_style = 'pywin32'\n\n    agent_svc = Target(name='Datadog Agent', modules='win32.agent', dest_base='ddagent')\n\n    extra_args = {\n        'options': {\n            'py2exe': {\n                'includes': ','.join(include_modules),\n                'optimize': 0,\n                'compressed': True,\n                'bundle_files': 3,\n                'dll_excludes': [ \"IPHLPAPI.DLL\", \"NSI.dll\",  \"WINNSI.DLL\",  \"WTSAPI32.dll\"],\n            },\n        },\n        'console': ['win32\\shell.py'],\n        'service': [agent_svc],\n        'windows': [{'script': 'win32\\gui.py',\n                     'dest_base': \"agent-manager\",\n                     'uac_info': \"requireAdministrator\", # The manager needs to be administrator to stop/start the service\n                     'icon_resources': [(1, r\"packaging\\datadog-agent\\win32\\install_files\\dd_agent_win_256.ico\")],\n                     }],\n        'data_files': [\n            (\"Microsoft.VC90.CRT\", glob(r'C:\\Python27\\redist\\*.*')),\n            ('pup', glob('pup/pup.html')),\n            ('pup', glob('pup/status.html')),\n            ('pup/static', glob('pup/static/*.*')),\n            ('jmxfetch', glob('checks/libs/%s' % JMX_FETCH_JAR_NAME)),\n        ],\n    }\n\nsetup(\n    name='datadog-agent',\n    version=get_version(),\n    description=\"DevOps' best friend\",\n    author='DataDog',\n    author_email='dev@datadoghq.com',\n    url='http://www.datadoghq.com',\n    install_requires=install_requires,\n    setup_requires=setup_requires,\n    packages=find_packages(exclude=['ez_setup']),\n    include_package_data=True,\n    test_suite='nose.collector',\n    zip_safe=False,\n    **extra_args\n)\n", "path": "setup.py"}]}