We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Don't use Exception.message if you want to work on py3k
Found in https://github.com/conda-forge/staged-recipes/issues/720. Currently exists in 2 places at https://github.com/conda-forge/conda-smithy/blob/6c1856a51832b5a014bb9126467804d75d712029/conda_smithy/cli.py.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `conda_smithy/cli.py`
Content:
```
1 from __future__ import print_function, absolute_import
2 
3 import os
4 import requests
5 import subprocess
6 import sys
7 import time
8 import argparse
9 
10 from conda_build.metadata import MetaData
11 
12 from . import ci_register
13 from . import configure_feedstock
14 from . import lint_recipe
15 from . import __version__
16 
17 
18 PY2 = sys.version_info[0] == 2
19 
20 def generate_feedstock_content(target_directory, source_recipe_dir, meta):
21     recipe_dir = "recipe"
22     target_recipe_dir = os.path.join(target_directory, recipe_dir)
23     if not os.path.exists(target_recipe_dir):
24         os.makedirs(target_recipe_dir)
25     # If there is a source recipe, copy it now to the right dir
26     if source_recipe_dir:
27         configure_feedstock.copytree(source_recipe_dir, target_recipe_dir)
28 
29     forge_yml = os.path.join(target_directory, 'conda-forge.yml')
30     if not os.path.exists(forge_yml):
31         with open(forge_yml, 'w') as fh:
32             fh.write('[]')
33 
34     configure_feedstock.main(target_directory)
35 
36 
37 def init_git_repo(target):
38     subprocess.check_call(['git', 'init'], cwd=target)
39 
40 
41 def create_git_repo(target, msg):
42     init_git_repo(target)
43     subprocess.check_call(['git', 'add', '*'], cwd=target)
44     if sys.platform == "win32":
45         # prevent this:
46         # bash: line 1: ./ci_support/run_docker_build.sh: Permission denied
47         # ./ci_support/run_docker_build.sh returned exit code 126
48         subprocess.check_call(['git', 'update-index', '--chmod=+x', 'ci_support/run_docker_build.sh'], cwd=target)
49     subprocess.check_call(['git', 'commit', '-m', msg], cwd=target)
50 
51 
52 class Subcommand(object):
53     #: The name of the subcommand
54     subcommand = None
55     aliases = []
56     def __init__(self, parser, help=None):
57         if PY2:
58             # aliases not allowed in 2.7 :-(
59             subcommand_parser = parser.add_parser(self.subcommand, help=help)
60         else:
61             subcommand_parser = parser.add_parser(self.subcommand, help=help, aliases=self.aliases)
62 
63         subcommand_parser.set_defaults(subcommand_func=self)
64         self.subcommand_parser = subcommand_parser
65 
66     def __call__(self, args):
67         pass
68 
69 
70 class Init(Subcommand):
71     subcommand = 'init'
72     def __init__(self, parser):
73         # conda-smithy init /path/to/udunits-recipe ./
74 
75         super(Init, self).__init__(parser, "Create a feedstock git repository, which can contain "
76                                            "one conda recipes.")
77         scp = self.subcommand_parser
78         scp.add_argument("recipe_directory", help="The path to the source recipe directory.")
79         scp.add_argument("--feedstock-directory", default='./{package.name}-feedstock',
80                         help="Target directory, where the new feedstock git repository should be "
81                              "created. (Default: './<packagename>-feedstock')")
82         scp.add_argument("--no-git-repo", action='store_true',
83                                        default=False,
84                                        help="Do not init the feedstock as a git repository.")
85 
86     def __call__(self, args):
87         # check some error conditions
88         if args.recipe_directory and not os.path.isdir(args.recipe_directory):
89             raise IOError("The source recipe directory should be the directory of the "
90                           "conda-recipe you want to build a feedstock for. Got {}".format(
91                 args.recipe_directory))
92 
93         # Get some information about the source recipe.
94         if args.recipe_directory:
95             meta = MetaData(args.recipe_directory)
96         else:
97             meta = None
98 
99         feedstock_directory = args.feedstock_directory.format(package=argparse.Namespace(name=meta.name()))
100         msg = 'Initial commit of the {} feedstock.'.format(meta.name())
101 
102         try:
103             generate_feedstock_content(feedstock_directory, args.recipe_directory, meta)
104             if not args.no_git_repo:
105                 create_git_repo(feedstock_directory, msg)
106 
107             print("\nRepository created, please edit conda-forge.yml to configure the upload channels\n"
108                   "and afterwards call 'conda smithy register-github'")
109         except RuntimeError as e:
110             print(e.message)
111 
112 
113 class RegisterGithub(Subcommand):
114     subcommand = 'register-github'
115     def __init__(self, parser):
116         #  conda-smithy register-github ./ --organization=conda-forge
117         super(RegisterGithub, self).__init__(parser, "Register a repo for a feedstock at github.")
118         scp = self.subcommand_parser
119         scp.add_argument("feedstock_directory",
120                          help="The directory of the feedstock git repository.")
121         group = scp.add_mutually_exclusive_group()
122         group.add_argument("--user", help="github username under which to register this repo")
123         group.add_argument("--organization", default="conda-forge",
124                            help="github organisation under which to register this repo")
125         scp.add_argument("--remote-name", default="upstream",
126                                        help="The name of the remote to add to the local repo (default: upstream). "
127                                             "An empty string will disable adding of a remote.")
128 
129     def __call__(self, args):
130         from . import github
131         try:
132             github.create_github_repo(args)
133             print("\nRepository registered at github, now call 'conda smithy register-ci'")
134         except RuntimeError as e:
135             print(e.message)
136 
137 
138 class RegisterCI(Subcommand):
139     subcommand = 'register-ci'
140     def __init__(self, parser):
141         # conda-smithy register-ci ./
142         super(RegisterCI, self).__init__(parser, "Register a feedstock at the CI "
143                                                               "services which do the builds.")
144         scp = self.subcommand_parser
145         scp.add_argument("--feedstock_directory", default=os.getcwd(),
146                          help="The directory of the feedstock git repository.")
147         group = scp.add_mutually_exclusive_group()
148         group.add_argument("--user", help="github username under which to register this repo")
149         group.add_argument("--organization", default="conda-forge",
150                            help="github organisation under which to register this repo")
151 
152     def __call__(self, args):
153         owner = args.user or args.organization
154         repo = os.path.basename(os.path.abspath(args.feedstock_directory))
155 
156         print('CI Summary for {}/{} (can take ~30s):'.format(owner, repo))
157         try:
158             ci_register.add_project_to_travis(owner, repo)
159             ci_register.travis_token_update_conda_forge_config(args.feedstock_directory, owner, repo)
160             time.sleep(1)
161             ci_register.travis_configure(owner, repo)
162             ci_register.add_project_to_circle(owner, repo)
163             ci_register.add_token_to_circle(owner, repo)
164             ci_register.add_project_to_appveyor(owner, repo)
165             ci_register.appveyor_encrypt_binstar_token(args.feedstock_directory, owner, repo)
166             ci_register.appveyor_configure(owner, repo)
167             ci_register.add_conda_linting(owner, repo)
168             print("\nCI services have been enabled enabled. You may wish to regnerate the feedstock.\n"
169                   "Any changes will need commiting to the repo.")
170         except RuntimeError as e:
171             print(e.message)
172 
173 class Regenerate(Subcommand):
174     subcommand = 'regenerate'
175     aliases = ['rerender']
176     def __init__(self, parser):
177         super(Regenerate, self).__init__(parser, "Regenerate / update the CI support files of the "
178                                                "feedstock.")
179         scp = self.subcommand_parser
180         scp.add_argument("--feedstock_directory", default=os.getcwd(),
181                          help="The directory of the feedstock git repository.")
182 
183     def __call__(self, args):
184         try:
185             configure_feedstock.main(args.feedstock_directory)
186             print("\nCI support files regenerated. These need to be pushed to github!")
187         except RuntimeError as e:
188             print(e.message)
189 
190 
191 class RecipeLint(Subcommand):
192     subcommand = 'recipe-lint'
193     def __init__(self, parser):
194         super(RecipeLint, self).__init__(parser, "Lint a single conda recipe.")
195         scp = self.subcommand_parser
196         scp.add_argument("recipe_directory", default=[os.getcwd()], nargs='*')
197 
198     def __call__(self, args):
199         all_good = True
200         for recipe in args.recipe_directory:
201             lint = lint_recipe.main(os.path.join(recipe))
202             if lint:
203                 all_good = False
204                 print('{} has some lint:\n  {}'.format(recipe, '\n  '.join(lint)))
205             else:
206                 print('{} is in fine form'.format(recipe))
207         # Exit code 1 for some lint, 0 for no lint.
208         sys.exit(int(not all_good))
209 
210 
211 
212 def main():
213 
214     parser = argparse.ArgumentParser("a tool to help create, administer and manage feedstocks.")
215     subparser = parser.add_subparsers()
216     # TODO: Consider allowing plugins/extensions using entry_points.
217     # http://reinout.vanrees.org/weblog/2010/01/06/zest-releaser-entry-points.html
218     for subcommand in Subcommand.__subclasses__():
219         subcommand(subparser)
220     # And the alias for rerender
221     if PY2:
222         class Rerender(Regenerate):
223             # A poor-man's alias for regenerate.
224             subcommand = 'rerender'
225         Rerender(subparser)
226 
227     parser.add_argument('--version', action='version',
228                         version=__version__,
229                         help="Show conda-smithy's version, and exit.")
230 
231     if not sys.argv[1:]:
232         args = parser.parse_args(['--help'])
233     else:
234         args = parser.parse_args()
235 
236     args.subcommand_func(args)
237 
238 
239 if __name__ == '__main__':
240     main()
241
```
--- 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/conda_smithy/cli.py b/conda_smithy/cli.py
--- a/conda_smithy/cli.py
+++ b/conda_smithy/cli.py
@@ -107,7 +107,7 @@
             print("\nRepository created, please edit conda-forge.yml to configure the upload channels\n"
                   "and afterwards call 'conda smithy register-github'")
         except RuntimeError as e:
-            print(e.message)
+            print(e)
 
 
 class RegisterGithub(Subcommand):
@@ -132,7 +132,7 @@
             github.create_github_repo(args)
             print("\nRepository registered at github, now call 'conda smithy register-ci'")
         except RuntimeError as e:
-            print(e.message)
+            print(e)
 
 
 class RegisterCI(Subcommand):
@@ -168,7 +168,7 @@
             print("\nCI services have been enabled enabled. You may wish to regnerate the feedstock.\n"
                   "Any changes will need commiting to the repo.")
         except RuntimeError as e:
-            print(e.message)
+            print(e)
 
 class Regenerate(Subcommand):
     subcommand = 'regenerate'
@@ -185,7 +185,7 @@
             configure_feedstock.main(args.feedstock_directory)
             print("\nCI support files regenerated. These need to be pushed to github!")
         except RuntimeError as e:
-            print(e.message)
+            print(e)
 
 
 class RecipeLint(Subcommand):

{"golden_diff": "diff --git a/conda_smithy/cli.py b/conda_smithy/cli.py\n--- a/conda_smithy/cli.py\n+++ b/conda_smithy/cli.py\n@@ -107,7 +107,7 @@\n             print(\"\\nRepository created, please edit conda-forge.yml to configure the upload channels\\n\"\n                   \"and afterwards call 'conda smithy register-github'\")\n         except RuntimeError as e:\n-            print(e.message)\n+            print(e)\n \n \n class RegisterGithub(Subcommand):\n@@ -132,7 +132,7 @@\n             github.create_github_repo(args)\n             print(\"\\nRepository registered at github, now call 'conda smithy register-ci'\")\n         except RuntimeError as e:\n-            print(e.message)\n+            print(e)\n \n \n class RegisterCI(Subcommand):\n@@ -168,7 +168,7 @@\n             print(\"\\nCI services have been enabled enabled. You may wish to regnerate the feedstock.\\n\"\n                   \"Any changes will need commiting to the repo.\")\n         except RuntimeError as e:\n-            print(e.message)\n+            print(e)\n \n class Regenerate(Subcommand):\n     subcommand = 'regenerate'\n@@ -185,7 +185,7 @@\n             configure_feedstock.main(args.feedstock_directory)\n             print(\"\\nCI support files regenerated. These need to be pushed to github!\")\n         except RuntimeError as e:\n-            print(e.message)\n+            print(e)\n \n \n class RecipeLint(Subcommand):\n", "issue": "Don't use Exception.message if you want to work on py3k\nFound in https://github.com/conda-forge/staged-recipes/issues/720. Currently exists in 2 places at https://github.com/conda-forge/conda-smithy/blob/6c1856a51832b5a014bb9126467804d75d712029/conda_smithy/cli.py.\n\n", "before_files": [{"content": "from __future__ import print_function, absolute_import\n\nimport os\nimport requests\nimport subprocess\nimport sys\nimport time\nimport argparse\n\nfrom conda_build.metadata import MetaData\n\nfrom . import ci_register\nfrom . import configure_feedstock\nfrom . import lint_recipe\nfrom . import __version__\n\n\nPY2 = sys.version_info[0] == 2\n\ndef generate_feedstock_content(target_directory, source_recipe_dir, meta):\n    recipe_dir = \"recipe\"\n    target_recipe_dir = os.path.join(target_directory, recipe_dir)\n    if not os.path.exists(target_recipe_dir):\n        os.makedirs(target_recipe_dir)\n    # If there is a source recipe, copy it now to the right dir\n    if source_recipe_dir:\n        configure_feedstock.copytree(source_recipe_dir, target_recipe_dir)\n\n    forge_yml = os.path.join(target_directory, 'conda-forge.yml')\n    if not os.path.exists(forge_yml):\n        with open(forge_yml, 'w') as fh:\n            fh.write('[]')\n\n    configure_feedstock.main(target_directory)\n\n\ndef init_git_repo(target):\n    subprocess.check_call(['git', 'init'], cwd=target)\n\n\ndef create_git_repo(target, msg):\n    init_git_repo(target)\n    subprocess.check_call(['git', 'add', '*'], cwd=target)\n    if sys.platform == \"win32\":\n        # prevent this:\n        # bash: line 1: ./ci_support/run_docker_build.sh: Permission denied\n        # ./ci_support/run_docker_build.sh returned exit code 126\n        subprocess.check_call(['git', 'update-index', '--chmod=+x', 'ci_support/run_docker_build.sh'], cwd=target)\n    subprocess.check_call(['git', 'commit', '-m', msg], cwd=target)\n\n\nclass Subcommand(object):\n    #: The name of the subcommand\n    subcommand = None\n    aliases = []\n    def __init__(self, parser, help=None):\n        if PY2:\n            # aliases not allowed in 2.7 :-(\n            subcommand_parser = parser.add_parser(self.subcommand, help=help)\n        else:\n            subcommand_parser = parser.add_parser(self.subcommand, help=help, aliases=self.aliases)\n\n        subcommand_parser.set_defaults(subcommand_func=self)\n        self.subcommand_parser = subcommand_parser\n\n    def __call__(self, args):\n        pass\n\n\nclass Init(Subcommand):\n    subcommand = 'init'\n    def __init__(self, parser):\n        # conda-smithy init /path/to/udunits-recipe ./\n\n        super(Init, self).__init__(parser, \"Create a feedstock git repository, which can contain \"\n                                           \"one conda recipes.\")\n        scp = self.subcommand_parser\n        scp.add_argument(\"recipe_directory\", help=\"The path to the source recipe directory.\")\n        scp.add_argument(\"--feedstock-directory\", default='./{package.name}-feedstock',\n                        help=\"Target directory, where the new feedstock git repository should be \"\n                             \"created. (Default: './<packagename>-feedstock')\")\n        scp.add_argument(\"--no-git-repo\", action='store_true',\n                                       default=False,\n                                       help=\"Do not init the feedstock as a git repository.\")\n\n    def __call__(self, args):\n        # check some error conditions\n        if args.recipe_directory and not os.path.isdir(args.recipe_directory):\n            raise IOError(\"The source recipe directory should be the directory of the \"\n                          \"conda-recipe you want to build a feedstock for. Got {}\".format(\n                args.recipe_directory))\n\n        # Get some information about the source recipe.\n        if args.recipe_directory:\n            meta = MetaData(args.recipe_directory)\n        else:\n            meta = None\n\n        feedstock_directory = args.feedstock_directory.format(package=argparse.Namespace(name=meta.name()))\n        msg = 'Initial commit of the {} feedstock.'.format(meta.name())\n\n        try:\n            generate_feedstock_content(feedstock_directory, args.recipe_directory, meta)\n            if not args.no_git_repo:\n                create_git_repo(feedstock_directory, msg)\n\n            print(\"\\nRepository created, please edit conda-forge.yml to configure the upload channels\\n\"\n                  \"and afterwards call 'conda smithy register-github'\")\n        except RuntimeError as e:\n            print(e.message)\n\n\nclass RegisterGithub(Subcommand):\n    subcommand = 'register-github'\n    def __init__(self, parser):\n        #  conda-smithy register-github ./ --organization=conda-forge\n        super(RegisterGithub, self).__init__(parser, \"Register a repo for a feedstock at github.\")\n        scp = self.subcommand_parser\n        scp.add_argument(\"feedstock_directory\",\n                         help=\"The directory of the feedstock git repository.\")\n        group = scp.add_mutually_exclusive_group()\n        group.add_argument(\"--user\", help=\"github username under which to register this repo\")\n        group.add_argument(\"--organization\", default=\"conda-forge\",\n                           help=\"github organisation under which to register this repo\")\n        scp.add_argument(\"--remote-name\", default=\"upstream\",\n                                       help=\"The name of the remote to add to the local repo (default: upstream). \"\n                                            \"An empty string will disable adding of a remote.\")\n\n    def __call__(self, args):\n        from . import github\n        try:\n            github.create_github_repo(args)\n            print(\"\\nRepository registered at github, now call 'conda smithy register-ci'\")\n        except RuntimeError as e:\n            print(e.message)\n\n\nclass RegisterCI(Subcommand):\n    subcommand = 'register-ci'\n    def __init__(self, parser):\n        # conda-smithy register-ci ./\n        super(RegisterCI, self).__init__(parser, \"Register a feedstock at the CI \"\n                                                              \"services which do the builds.\")\n        scp = self.subcommand_parser\n        scp.add_argument(\"--feedstock_directory\", default=os.getcwd(),\n                         help=\"The directory of the feedstock git repository.\")\n        group = scp.add_mutually_exclusive_group()\n        group.add_argument(\"--user\", help=\"github username under which to register this repo\")\n        group.add_argument(\"--organization\", default=\"conda-forge\",\n                           help=\"github organisation under which to register this repo\")\n\n    def __call__(self, args):\n        owner = args.user or args.organization\n        repo = os.path.basename(os.path.abspath(args.feedstock_directory))\n\n        print('CI Summary for {}/{} (can take ~30s):'.format(owner, repo))\n        try:\n            ci_register.add_project_to_travis(owner, repo)\n            ci_register.travis_token_update_conda_forge_config(args.feedstock_directory, owner, repo)\n            time.sleep(1)\n            ci_register.travis_configure(owner, repo)\n            ci_register.add_project_to_circle(owner, repo)\n            ci_register.add_token_to_circle(owner, repo)\n            ci_register.add_project_to_appveyor(owner, repo)\n            ci_register.appveyor_encrypt_binstar_token(args.feedstock_directory, owner, repo)\n            ci_register.appveyor_configure(owner, repo)\n            ci_register.add_conda_linting(owner, repo)\n            print(\"\\nCI services have been enabled enabled. You may wish to regnerate the feedstock.\\n\"\n                  \"Any changes will need commiting to the repo.\")\n        except RuntimeError as e:\n            print(e.message)\n\nclass Regenerate(Subcommand):\n    subcommand = 'regenerate'\n    aliases = ['rerender']\n    def __init__(self, parser):\n        super(Regenerate, self).__init__(parser, \"Regenerate / update the CI support files of the \"\n                                               \"feedstock.\")\n        scp = self.subcommand_parser\n        scp.add_argument(\"--feedstock_directory\", default=os.getcwd(),\n                         help=\"The directory of the feedstock git repository.\")\n\n    def __call__(self, args):\n        try:\n            configure_feedstock.main(args.feedstock_directory)\n            print(\"\\nCI support files regenerated. These need to be pushed to github!\")\n        except RuntimeError as e:\n            print(e.message)\n\n\nclass RecipeLint(Subcommand):\n    subcommand = 'recipe-lint'\n    def __init__(self, parser):\n        super(RecipeLint, self).__init__(parser, \"Lint a single conda recipe.\")\n        scp = self.subcommand_parser\n        scp.add_argument(\"recipe_directory\", default=[os.getcwd()], nargs='*')\n\n    def __call__(self, args):\n        all_good = True\n        for recipe in args.recipe_directory:\n            lint = lint_recipe.main(os.path.join(recipe))\n            if lint:\n                all_good = False\n                print('{} has some lint:\\n  {}'.format(recipe, '\\n  '.join(lint)))\n            else:\n                print('{} is in fine form'.format(recipe))\n        # Exit code 1 for some lint, 0 for no lint.\n        sys.exit(int(not all_good))\n\n\n\ndef main():\n\n    parser = argparse.ArgumentParser(\"a tool to help create, administer and manage feedstocks.\")\n    subparser = parser.add_subparsers()\n    # TODO: Consider allowing plugins/extensions using entry_points.\n    # http://reinout.vanrees.org/weblog/2010/01/06/zest-releaser-entry-points.html\n    for subcommand in Subcommand.__subclasses__():\n        subcommand(subparser)\n    # And the alias for rerender\n    if PY2:\n        class Rerender(Regenerate):\n            # A poor-man's alias for regenerate.\n            subcommand = 'rerender'\n        Rerender(subparser)\n\n    parser.add_argument('--version', action='version',\n                        version=__version__,\n                        help=\"Show conda-smithy's version, and exit.\")\n\n    if not sys.argv[1:]:\n        args = parser.parse_args(['--help'])\n    else:\n        args = parser.parse_args()\n\n    args.subcommand_func(args)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "conda_smithy/cli.py"}], "after_files": [{"content": "from __future__ import print_function, absolute_import\n\nimport os\nimport requests\nimport subprocess\nimport sys\nimport time\nimport argparse\n\nfrom conda_build.metadata import MetaData\n\nfrom . import ci_register\nfrom . import configure_feedstock\nfrom . import lint_recipe\nfrom . import __version__\n\n\nPY2 = sys.version_info[0] == 2\n\ndef generate_feedstock_content(target_directory, source_recipe_dir, meta):\n    recipe_dir = \"recipe\"\n    target_recipe_dir = os.path.join(target_directory, recipe_dir)\n    if not os.path.exists(target_recipe_dir):\n        os.makedirs(target_recipe_dir)\n    # If there is a source recipe, copy it now to the right dir\n    if source_recipe_dir:\n        configure_feedstock.copytree(source_recipe_dir, target_recipe_dir)\n\n    forge_yml = os.path.join(target_directory, 'conda-forge.yml')\n    if not os.path.exists(forge_yml):\n        with open(forge_yml, 'w') as fh:\n            fh.write('[]')\n\n    configure_feedstock.main(target_directory)\n\n\ndef init_git_repo(target):\n    subprocess.check_call(['git', 'init'], cwd=target)\n\n\ndef create_git_repo(target, msg):\n    init_git_repo(target)\n    subprocess.check_call(['git', 'add', '*'], cwd=target)\n    if sys.platform == \"win32\":\n        # prevent this:\n        # bash: line 1: ./ci_support/run_docker_build.sh: Permission denied\n        # ./ci_support/run_docker_build.sh returned exit code 126\n        subprocess.check_call(['git', 'update-index', '--chmod=+x', 'ci_support/run_docker_build.sh'], cwd=target)\n    subprocess.check_call(['git', 'commit', '-m', msg], cwd=target)\n\n\nclass Subcommand(object):\n    #: The name of the subcommand\n    subcommand = None\n    aliases = []\n    def __init__(self, parser, help=None):\n        if PY2:\n            # aliases not allowed in 2.7 :-(\n            subcommand_parser = parser.add_parser(self.subcommand, help=help)\n        else:\n            subcommand_parser = parser.add_parser(self.subcommand, help=help, aliases=self.aliases)\n\n        subcommand_parser.set_defaults(subcommand_func=self)\n        self.subcommand_parser = subcommand_parser\n\n    def __call__(self, args):\n        pass\n\n\nclass Init(Subcommand):\n    subcommand = 'init'\n    def __init__(self, parser):\n        # conda-smithy init /path/to/udunits-recipe ./\n\n        super(Init, self).__init__(parser, \"Create a feedstock git repository, which can contain \"\n                                           \"one conda recipes.\")\n        scp = self.subcommand_parser\n        scp.add_argument(\"recipe_directory\", help=\"The path to the source recipe directory.\")\n        scp.add_argument(\"--feedstock-directory\", default='./{package.name}-feedstock',\n                        help=\"Target directory, where the new feedstock git repository should be \"\n                             \"created. (Default: './<packagename>-feedstock')\")\n        scp.add_argument(\"--no-git-repo\", action='store_true',\n                                       default=False,\n                                       help=\"Do not init the feedstock as a git repository.\")\n\n    def __call__(self, args):\n        # check some error conditions\n        if args.recipe_directory and not os.path.isdir(args.recipe_directory):\n            raise IOError(\"The source recipe directory should be the directory of the \"\n                          \"conda-recipe you want to build a feedstock for. Got {}\".format(\n                args.recipe_directory))\n\n        # Get some information about the source recipe.\n        if args.recipe_directory:\n            meta = MetaData(args.recipe_directory)\n        else:\n            meta = None\n\n        feedstock_directory = args.feedstock_directory.format(package=argparse.Namespace(name=meta.name()))\n        msg = 'Initial commit of the {} feedstock.'.format(meta.name())\n\n        try:\n            generate_feedstock_content(feedstock_directory, args.recipe_directory, meta)\n            if not args.no_git_repo:\n                create_git_repo(feedstock_directory, msg)\n\n            print(\"\\nRepository created, please edit conda-forge.yml to configure the upload channels\\n\"\n                  \"and afterwards call 'conda smithy register-github'\")\n        except RuntimeError as e:\n            print(e)\n\n\nclass RegisterGithub(Subcommand):\n    subcommand = 'register-github'\n    def __init__(self, parser):\n        #  conda-smithy register-github ./ --organization=conda-forge\n        super(RegisterGithub, self).__init__(parser, \"Register a repo for a feedstock at github.\")\n        scp = self.subcommand_parser\n        scp.add_argument(\"feedstock_directory\",\n                         help=\"The directory of the feedstock git repository.\")\n        group = scp.add_mutually_exclusive_group()\n        group.add_argument(\"--user\", help=\"github username under which to register this repo\")\n        group.add_argument(\"--organization\", default=\"conda-forge\",\n                           help=\"github organisation under which to register this repo\")\n        scp.add_argument(\"--remote-name\", default=\"upstream\",\n                                       help=\"The name of the remote to add to the local repo (default: upstream). \"\n                                            \"An empty string will disable adding of a remote.\")\n\n    def __call__(self, args):\n        from . import github\n        try:\n            github.create_github_repo(args)\n            print(\"\\nRepository registered at github, now call 'conda smithy register-ci'\")\n        except RuntimeError as e:\n            print(e)\n\n\nclass RegisterCI(Subcommand):\n    subcommand = 'register-ci'\n    def __init__(self, parser):\n        # conda-smithy register-ci ./\n        super(RegisterCI, self).__init__(parser, \"Register a feedstock at the CI \"\n                                                              \"services which do the builds.\")\n        scp = self.subcommand_parser\n        scp.add_argument(\"--feedstock_directory\", default=os.getcwd(),\n                         help=\"The directory of the feedstock git repository.\")\n        group = scp.add_mutually_exclusive_group()\n        group.add_argument(\"--user\", help=\"github username under which to register this repo\")\n        group.add_argument(\"--organization\", default=\"conda-forge\",\n                           help=\"github organisation under which to register this repo\")\n\n    def __call__(self, args):\n        owner = args.user or args.organization\n        repo = os.path.basename(os.path.abspath(args.feedstock_directory))\n\n        print('CI Summary for {}/{} (can take ~30s):'.format(owner, repo))\n        try:\n            ci_register.add_project_to_travis(owner, repo)\n            ci_register.travis_token_update_conda_forge_config(args.feedstock_directory, owner, repo)\n            time.sleep(1)\n            ci_register.travis_configure(owner, repo)\n            ci_register.add_project_to_circle(owner, repo)\n            ci_register.add_token_to_circle(owner, repo)\n            ci_register.add_project_to_appveyor(owner, repo)\n            ci_register.appveyor_encrypt_binstar_token(args.feedstock_directory, owner, repo)\n            ci_register.appveyor_configure(owner, repo)\n            ci_register.add_conda_linting(owner, repo)\n            print(\"\\nCI services have been enabled enabled. You may wish to regnerate the feedstock.\\n\"\n                  \"Any changes will need commiting to the repo.\")\n        except RuntimeError as e:\n            print(e)\n\nclass Regenerate(Subcommand):\n    subcommand = 'regenerate'\n    aliases = ['rerender']\n    def __init__(self, parser):\n        super(Regenerate, self).__init__(parser, \"Regenerate / update the CI support files of the \"\n                                               \"feedstock.\")\n        scp = self.subcommand_parser\n        scp.add_argument(\"--feedstock_directory\", default=os.getcwd(),\n                         help=\"The directory of the feedstock git repository.\")\n\n    def __call__(self, args):\n        try:\n            configure_feedstock.main(args.feedstock_directory)\n            print(\"\\nCI support files regenerated. These need to be pushed to github!\")\n        except RuntimeError as e:\n            print(e)\n\n\nclass RecipeLint(Subcommand):\n    subcommand = 'recipe-lint'\n    def __init__(self, parser):\n        super(RecipeLint, self).__init__(parser, \"Lint a single conda recipe.\")\n        scp = self.subcommand_parser\n        scp.add_argument(\"recipe_directory\", default=[os.getcwd()], nargs='*')\n\n    def __call__(self, args):\n        all_good = True\n        for recipe in args.recipe_directory:\n            lint = lint_recipe.main(os.path.join(recipe))\n            if lint:\n                all_good = False\n                print('{} has some lint:\\n  {}'.format(recipe, '\\n  '.join(lint)))\n            else:\n                print('{} is in fine form'.format(recipe))\n        # Exit code 1 for some lint, 0 for no lint.\n        sys.exit(int(not all_good))\n\n\n\ndef main():\n\n    parser = argparse.ArgumentParser(\"a tool to help create, administer and manage feedstocks.\")\n    subparser = parser.add_subparsers()\n    # TODO: Consider allowing plugins/extensions using entry_points.\n    # http://reinout.vanrees.org/weblog/2010/01/06/zest-releaser-entry-points.html\n    for subcommand in Subcommand.__subclasses__():\n        subcommand(subparser)\n    # And the alias for rerender\n    if PY2:\n        class Rerender(Regenerate):\n            # A poor-man's alias for regenerate.\n            subcommand = 'rerender'\n        Rerender(subparser)\n\n    parser.add_argument('--version', action='version',\n                        version=__version__,\n                        help=\"Show conda-smithy's version, and exit.\")\n\n    if not sys.argv[1:]:\n        args = parser.parse_args(['--help'])\n    else:\n        args = parser.parse_args()\n\n    args.subcommand_func(args)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "conda_smithy/cli.py"}]}