We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
c7n_mailer lambda error after included slack integration
Hi team,

It appears that deployed lambda mailer is having some problem with the libs, after the last commit that included slack integration. 

After update c7n_mailer lambda I'm seeing this error in the logs:
```
[ERROR] 2018-05-01T00:45:26.698Z f04d1326-4cd8-11e8-9f05-670c91cd10c1 Error starting mailer MailerSqsQueueProcessor().
Error: No module named requests

Traceback (most recent call last):
File "/var/task/c7n_mailer/handle.py", line 46, in start_c7n_mailer
mailer_sqs_queue_processor.run(parallel)
File "/var/task/c7n_mailer/sqs_queue_processor.py", line 126, in run
self.process_sqs_message(sqs_message)
File "/var/task/c7n_mailer/sqs_queue_processor.py", line 170, in process_sqs_message
from .slack_delivery import SlackDelivery
File "/var/task/c7n_mailer/slack_delivery.py", line 17, in <module>
import requests
ImportError: No module named requests
```
 I've had no success even with a fresh install from the repos.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `tools/c7n_mailer/c7n_mailer/deploy.py`
Content:
```
1 # Copyright 2016-2017 Capital One Services, LLC
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from __future__ import absolute_import, division, print_function, unicode_literals
15 
16 import json
17 import os
18 
19 from c7n.mu import (
20     CloudWatchEventSource,
21     LambdaFunction,
22     LambdaManager,
23     PythonPackageArchive)
24 
25 
26 entry_source = """\
27 import logging
28 
29 from c7n_mailer import handle
30 
31 logger = logging.getLogger('custodian.mailer')
32 log_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
33 logging.basicConfig(level=logging.INFO, format=log_format)
34 logging.getLogger('botocore').setLevel(logging.WARNING)
35 
36 def dispatch(event, context):
37     return handle.start_c7n_mailer(logger)
38 """
39 
40 
41 def get_archive(config):
42     archive = PythonPackageArchive(
43         'c7n_mailer', 'ldap3', 'pyasn1', 'jinja2', 'markupsafe', 'ruamel',
44         'redis')
45 
46     template_dir = os.path.abspath(
47         os.path.join(os.path.dirname(__file__), '..', 'msg-templates'))
48 
49     for t in os.listdir(template_dir):
50         with open(os.path.join(template_dir, t)) as fh:
51             archive.add_contents('msg-templates/%s' % t, fh.read())
52 
53     archive.add_contents('config.json', json.dumps(config))
54     archive.add_contents('periodic.py', entry_source)
55 
56     archive.close()
57     return archive
58 
59 
60 def provision(config, session_factory):
61     func_config = dict(
62         name=config.get('lambda_name', 'cloud-custodian-mailer'),
63         description=config.get('lambda_description', 'Cloud Custodian Mailer'),
64         tags=config.get('lambda_tags', {}),
65         handler='periodic.dispatch',
66         runtime=config['runtime'],
67         memory_size=config['memory'],
68         timeout=config['timeout'],
69         role=config['role'],
70         subnets=config['subnets'],
71         security_groups=config['security_groups'],
72         dead_letter_config=config.get('dead_letter_config', {}),
73         events=[
74             CloudWatchEventSource(
75                 {'type': 'periodic',
76                  'schedule': config.get('lambda_schedule', 'rate(5 minutes)')},
77                 session_factory,
78                 prefix="")
79         ])
80 
81     archive = get_archive(config)
82     func = LambdaFunction(func_config, archive)
83     manager = LambdaManager(session_factory)
84     manager.publish(func)
85
```

Path: `tools/c7n_mailer/setup.py`
Content:
```
1 # Copyright 2015-2017 Capital One Services, LLC
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from __future__ import absolute_import, division, print_function, unicode_literals
15 
16 from setuptools import setup, find_packages
17 import os
18 
19 requires = ["Jinja2", "boto3", "jsonschema", "ruamel.yaml<0.15", "datadog"]
20 try:
21     from concurrent import futures
22 except ImportError:
23     # The backport has SyntaxErrors under py36, so avoid installing it.
24     # https://github.com/agronholm/pythonfutures/issues/41
25     requires += ['futures']
26 
27 description = ""
28 if os.path.exists('README.md'):
29     description = open('README.md').read()
30 
31 setup(
32     name="c7n_mailer",
33     version='0.3.1',
34     description="Cloud Custodian - Reference Mailer",
35     long_description=description,
36     classifiers=[
37         "Topic :: System :: Systems Administration",
38         "Topic :: System :: Distributed Computing"
39     ],
40     url="https://github.com/capitalone/cloud-custodian",
41     license="Apache-2.0",
42     packages=find_packages('c7n_mailer'),
43     entry_points={
44         'console_scripts': [
45             'c7n-mailer = c7n_mailer.cli:main',
46             'c7n-mailer-replay = c7n_mailer.replay:main'
47         ]
48     },
49     install_requires=requires,
50 )
51
```
--- 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()

```

diff --git a/tools/c7n_mailer/c7n_mailer/deploy.py b/tools/c7n_mailer/c7n_mailer/deploy.py
--- a/tools/c7n_mailer/c7n_mailer/deploy.py
+++ b/tools/c7n_mailer/c7n_mailer/deploy.py
@@ -41,7 +41,7 @@
 def get_archive(config):
     archive = PythonPackageArchive(
         'c7n_mailer', 'ldap3', 'pyasn1', 'jinja2', 'markupsafe', 'ruamel',
-        'redis')
+        'redis', 'datadog', 'slackclient', 'requests')
 
     template_dir = os.path.abspath(
         os.path.join(os.path.dirname(__file__), '..', 'msg-templates'))
diff --git a/tools/c7n_mailer/setup.py b/tools/c7n_mailer/setup.py
--- a/tools/c7n_mailer/setup.py
+++ b/tools/c7n_mailer/setup.py
@@ -16,7 +16,9 @@
 from setuptools import setup, find_packages
 import os
 
-requires = ["Jinja2", "boto3", "jsonschema", "ruamel.yaml<0.15", "datadog"]
+# *Any* updates here should also go into c7n_mailer/deploy.py for lambda packaging.
+requires = [
+    "Jinja2", "boto3", "jsonschema", "ruamel.yaml<0.15", "datadog", "slackclient", "ldap3"]
 try:
     from concurrent import futures
 except ImportError:

{"golden_diff": "diff --git a/tools/c7n_mailer/c7n_mailer/deploy.py b/tools/c7n_mailer/c7n_mailer/deploy.py\n--- a/tools/c7n_mailer/c7n_mailer/deploy.py\n+++ b/tools/c7n_mailer/c7n_mailer/deploy.py\n@@ -41,7 +41,7 @@\n def get_archive(config):\n     archive = PythonPackageArchive(\n         'c7n_mailer', 'ldap3', 'pyasn1', 'jinja2', 'markupsafe', 'ruamel',\n-        'redis')\n+        'redis', 'datadog', 'slackclient', 'requests')\n \n     template_dir = os.path.abspath(\n         os.path.join(os.path.dirname(__file__), '..', 'msg-templates'))\ndiff --git a/tools/c7n_mailer/setup.py b/tools/c7n_mailer/setup.py\n--- a/tools/c7n_mailer/setup.py\n+++ b/tools/c7n_mailer/setup.py\n@@ -16,7 +16,9 @@\n from setuptools import setup, find_packages\n import os\n \n-requires = [\"Jinja2\", \"boto3\", \"jsonschema\", \"ruamel.yaml<0.15\", \"datadog\"]\n+# *Any* updates here should also go into c7n_mailer/deploy.py for lambda packaging.\n+requires = [\n+    \"Jinja2\", \"boto3\", \"jsonschema\", \"ruamel.yaml<0.15\", \"datadog\", \"slackclient\", \"ldap3\"]\n try:\n     from concurrent import futures\n except ImportError:\n", "issue": "c7n_mailer lambda error after included slack integration\nHi team,\r\n\r\nIt appears that deployed lambda mailer is having some problem with the libs, after the last commit that included slack integration. \r\n\r\nAfter update c7n_mailer lambda I'm seeing this error in the logs:\r\n```\r\n[ERROR] 2018-05-01T00:45:26.698Z f04d1326-4cd8-11e8-9f05-670c91cd10c1 Error starting mailer MailerSqsQueueProcessor().\r\nError: No module named requests\r\n\r\nTraceback (most recent call last):\r\nFile \"/var/task/c7n_mailer/handle.py\", line 46, in start_c7n_mailer\r\nmailer_sqs_queue_processor.run(parallel)\r\nFile \"/var/task/c7n_mailer/sqs_queue_processor.py\", line 126, in run\r\nself.process_sqs_message(sqs_message)\r\nFile \"/var/task/c7n_mailer/sqs_queue_processor.py\", line 170, in process_sqs_message\r\nfrom .slack_delivery import SlackDelivery\r\nFile \"/var/task/c7n_mailer/slack_delivery.py\", line 17, in <module>\r\nimport requests\r\nImportError: No module named requests\r\n```\r\n I've had no success even with a fresh install from the repos.\n", "before_files": [{"content": "# Copyright 2016-2017 Capital One Services, LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport json\nimport os\n\nfrom c7n.mu import (\n    CloudWatchEventSource,\n    LambdaFunction,\n    LambdaManager,\n    PythonPackageArchive)\n\n\nentry_source = \"\"\"\\\nimport logging\n\nfrom c7n_mailer import handle\n\nlogger = logging.getLogger('custodian.mailer')\nlog_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'\nlogging.basicConfig(level=logging.INFO, format=log_format)\nlogging.getLogger('botocore').setLevel(logging.WARNING)\n\ndef dispatch(event, context):\n    return handle.start_c7n_mailer(logger)\n\"\"\"\n\n\ndef get_archive(config):\n    archive = PythonPackageArchive(\n        'c7n_mailer', 'ldap3', 'pyasn1', 'jinja2', 'markupsafe', 'ruamel',\n        'redis')\n\n    template_dir = os.path.abspath(\n        os.path.join(os.path.dirname(__file__), '..', 'msg-templates'))\n\n    for t in os.listdir(template_dir):\n        with open(os.path.join(template_dir, t)) as fh:\n            archive.add_contents('msg-templates/%s' % t, fh.read())\n\n    archive.add_contents('config.json', json.dumps(config))\n    archive.add_contents('periodic.py', entry_source)\n\n    archive.close()\n    return archive\n\n\ndef provision(config, session_factory):\n    func_config = dict(\n        name=config.get('lambda_name', 'cloud-custodian-mailer'),\n        description=config.get('lambda_description', 'Cloud Custodian Mailer'),\n        tags=config.get('lambda_tags', {}),\n        handler='periodic.dispatch',\n        runtime=config['runtime'],\n        memory_size=config['memory'],\n        timeout=config['timeout'],\n        role=config['role'],\n        subnets=config['subnets'],\n        security_groups=config['security_groups'],\n        dead_letter_config=config.get('dead_letter_config', {}),\n        events=[\n            CloudWatchEventSource(\n                {'type': 'periodic',\n                 'schedule': config.get('lambda_schedule', 'rate(5 minutes)')},\n                session_factory,\n                prefix=\"\")\n        ])\n\n    archive = get_archive(config)\n    func = LambdaFunction(func_config, archive)\n    manager = LambdaManager(session_factory)\n    manager.publish(func)\n", "path": "tools/c7n_mailer/c7n_mailer/deploy.py"}, {"content": "# Copyright 2015-2017 Capital One Services, LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nfrom setuptools import setup, find_packages\nimport os\n\nrequires = [\"Jinja2\", \"boto3\", \"jsonschema\", \"ruamel.yaml<0.15\", \"datadog\"]\ntry:\n    from concurrent import futures\nexcept ImportError:\n    # The backport has SyntaxErrors under py36, so avoid installing it.\n    # https://github.com/agronholm/pythonfutures/issues/41\n    requires += ['futures']\n\ndescription = \"\"\nif os.path.exists('README.md'):\n    description = open('README.md').read()\n\nsetup(\n    name=\"c7n_mailer\",\n    version='0.3.1',\n    description=\"Cloud Custodian - Reference Mailer\",\n    long_description=description,\n    classifiers=[\n        \"Topic :: System :: Systems Administration\",\n        \"Topic :: System :: Distributed Computing\"\n    ],\n    url=\"https://github.com/capitalone/cloud-custodian\",\n    license=\"Apache-2.0\",\n    packages=find_packages('c7n_mailer'),\n    entry_points={\n        'console_scripts': [\n            'c7n-mailer = c7n_mailer.cli:main',\n            'c7n-mailer-replay = c7n_mailer.replay:main'\n        ]\n    },\n    install_requires=requires,\n)\n", "path": "tools/c7n_mailer/setup.py"}], "after_files": [{"content": "# Copyright 2016-2017 Capital One Services, LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nimport json\nimport os\n\nfrom c7n.mu import (\n    CloudWatchEventSource,\n    LambdaFunction,\n    LambdaManager,\n    PythonPackageArchive)\n\n\nentry_source = \"\"\"\\\nimport logging\n\nfrom c7n_mailer import handle\n\nlogger = logging.getLogger('custodian.mailer')\nlog_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'\nlogging.basicConfig(level=logging.INFO, format=log_format)\nlogging.getLogger('botocore').setLevel(logging.WARNING)\n\ndef dispatch(event, context):\n    return handle.start_c7n_mailer(logger)\n\"\"\"\n\n\ndef get_archive(config):\n    archive = PythonPackageArchive(\n        'c7n_mailer', 'ldap3', 'pyasn1', 'jinja2', 'markupsafe', 'ruamel',\n        'redis', 'datadog', 'slackclient', 'requests')\n\n    template_dir = os.path.abspath(\n        os.path.join(os.path.dirname(__file__), '..', 'msg-templates'))\n\n    for t in os.listdir(template_dir):\n        with open(os.path.join(template_dir, t)) as fh:\n            archive.add_contents('msg-templates/%s' % t, fh.read())\n\n    archive.add_contents('config.json', json.dumps(config))\n    archive.add_contents('periodic.py', entry_source)\n\n    archive.close()\n    return archive\n\n\ndef provision(config, session_factory):\n    func_config = dict(\n        name=config.get('lambda_name', 'cloud-custodian-mailer'),\n        description=config.get('lambda_description', 'Cloud Custodian Mailer'),\n        tags=config.get('lambda_tags', {}),\n        handler='periodic.dispatch',\n        runtime=config['runtime'],\n        memory_size=config['memory'],\n        timeout=config['timeout'],\n        role=config['role'],\n        subnets=config['subnets'],\n        security_groups=config['security_groups'],\n        dead_letter_config=config.get('dead_letter_config', {}),\n        events=[\n            CloudWatchEventSource(\n                {'type': 'periodic',\n                 'schedule': config.get('lambda_schedule', 'rate(5 minutes)')},\n                session_factory,\n                prefix=\"\")\n        ])\n\n    archive = get_archive(config)\n    func = LambdaFunction(func_config, archive)\n    manager = LambdaManager(session_factory)\n    manager.publish(func)\n", "path": "tools/c7n_mailer/c7n_mailer/deploy.py"}, {"content": "# Copyright 2015-2017 Capital One Services, LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\nfrom setuptools import setup, find_packages\nimport os\n\n# *Any* updates here should also go into c7n_mailer/deploy.py for lambda packaging.\nrequires = [\n    \"Jinja2\", \"boto3\", \"jsonschema\", \"ruamel.yaml<0.15\", \"datadog\", \"slackclient\", \"ldap3\"]\ntry:\n    from concurrent import futures\nexcept ImportError:\n    # The backport has SyntaxErrors under py36, so avoid installing it.\n    # https://github.com/agronholm/pythonfutures/issues/41\n    requires += ['futures']\n\ndescription = \"\"\nif os.path.exists('README.md'):\n    description = open('README.md').read()\n\nsetup(\n    name=\"c7n_mailer\",\n    version='0.3.1',\n    description=\"Cloud Custodian - Reference Mailer\",\n    long_description=description,\n    classifiers=[\n        \"Topic :: System :: Systems Administration\",\n        \"Topic :: System :: Distributed Computing\"\n    ],\n    url=\"https://github.com/capitalone/cloud-custodian\",\n    license=\"Apache-2.0\",\n    packages=find_packages('c7n_mailer'),\n    entry_points={\n        'console_scripts': [\n            'c7n-mailer = c7n_mailer.cli:main',\n            'c7n-mailer-replay = c7n_mailer.replay:main'\n        ]\n    },\n    install_requires=requires,\n)\n", "path": "tools/c7n_mailer/setup.py"}]}