We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
 Duplicate parameters for setting the state of request
[Lukas Slebodnik filed this issue in Bugzilla](https://bugzilla.redhat.com/show_bug.cgi?id=1408198):

> Description of problem:
> Acording to the help the state of package can be changed either by parameter --request and also as a last parameter.
>
> I didn't test but whether parameter --request is accepted or has higher priority then the last argument. But such situation is confusing.
> You should decide which way can be used. But there should be just one way.  
> 
> Version-Release number of selected component (if applicable):
> sh$ rpm -q bodhi-client 
> bodhi-client-2.3.3-1.fc26.noarch
> 
> How reproducible:
> Deterministic
> 
> Additional info:
> 1. bodhi updates request --help
> Usage: bodhi updates request [OPTIONS] UPDATE STATE
> 
> Options:
>   --user TEXT
>   --password TEXT
>   --request [testing|stable|unpush|obsolete|revoke]
>                                   Requested repository
>   --staging                       Use the staging bodhi instance
>   --help                          Show this message and exit.
> 
> man bodhi says:
>        bodhi updates request [options] <update> <state>
>           Request  that the given update be changed to the given state. update
>           should be given by update id, and state should be  one  of  testing,
>           stable, unpush, obsolete, or revoke.
>
>
> BTW, if you decide to use state from last parameter then IMHO it would be better to change or der of STATE and UPDATE. It will be simpler to implement bash completion for such order.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `bodhi/client/__init__.py`
Content:
```
1 # This program is free software; you can redistribute it and/or
2 # modify it under the terms of the GNU General Public License
3 # as published by the Free Software Foundation; either version 2
4 # of the License, or (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software
13 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
14 
15 import os
16 import platform
17 import subprocess
18 import sys
19 import traceback
20 
21 import click
22 
23 from bodhi.client import bindings
24 
25 
26 @click.group()
27 @click.version_option(message='%(version)s')
28 def cli():
29     pass
30 
31 
32 @cli.group()
33 def updates():
34     pass
35 
36 
37 @updates.command()
38 @click.argument('builds')
39 @click.option('--user', envvar='USERNAME')
40 @click.option('--password', prompt=True, hide_input=True)
41 @click.option('--type', default='bugfix', help='Update type', required=True,
42               type=click.Choice(['security', 'bugfix',
43                                  'enhancement', 'newpackage']))
44 @click.option('--notes', help='Update description')
45 @click.option('--notes-file', help='Update description from a file')
46 @click.option('--bugs', help='Comma-seperated list of bug numbers', default='')
47 @click.option('--close-bugs', default=True, is_flag=True, help='Automatically close bugs')
48 @click.option('--request', help='Requested repository',
49               type=click.Choice(['testing', 'stable', 'unpush']))
50 @click.option('--autokarma', default=True, is_flag=True, help='Enable karma automatism')
51 @click.option('--stable-karma', type=click.INT, help='Stable karma threshold')
52 @click.option('--unstable-karma', type=click.INT, help='Unstable karma threshold')
53 @click.option('--suggest', help='Post-update user suggestion',
54               type=click.Choice(['logout', 'reboot']))
55 @click.option('--file', help='A text file containing all the update details')
56 @click.option('--staging', help='Use the staging bodhi instance',
57               is_flag=True, default=False)
58 def new(user, password, **kwargs):
59     client = bindings.BodhiClient(username=user, password=password, staging=kwargs['staging'])
60 
61     if kwargs['file'] is None:
62         updates = [kwargs]
63 
64     else:
65         updates = client.parse_file(os.path.abspath(kwargs['file']))
66 
67     if kwargs['notes_file'] is not None:
68         if kwargs['notes'] is None:
69             with open(kwargs['notes_file'], 'r') as fin:
70                 kwargs['notes'] = fin.read()
71 
72         else:
73             click.echo("ERROR: Cannot specify --notes and --notes-file")
74             sys.exit(1)
75 
76     for update in updates:
77         try:
78             resp = client.save(**update)
79             print_resp(resp, client)
80         except bindings.BodhiClientException as e:
81             click.echo(str(e))
82         except Exception as e:
83             traceback.print_exc()
84 
85 
86 @updates.command()
87 @click.option('--updateid', help='Query by update ID (eg: FEDORA-2015-0001)')
88 @click.option('--approved-since', help='Approved after a specific timestamp')
89 @click.option('--modified-since', help='Modified after a specific timestamp')
90 @click.option('--builds', help='Query updates based on builds')
91 @click.option('--bugs', help='A list of bug numbers')
92 @click.option('--critpath', is_flag=True, default=None,
93               help='Query only critical path packages')
94 @click.option('--cves', help='Query by CVE id')
95 @click.option('--packages', help='Query by package name(s)')
96 @click.option('--pushed', is_flag=True, default=None,
97               help='Filter by pushed updates')
98 @click.option('--pushed-since',
99               help='Updates that have been pushed after a certain time')
100 @click.option('--releases', help='Updates for specific releases')
101 @click.option('--locked', help='Updates that are in a locked state')
102 @click.option('--request', help='Updates with a specific request',
103               type=click.Choice(['testing', 'stable', 'unpush']))
104 @click.option('--submitted-since',
105               help='Updates that have been submitted since a certain time')
106 @click.option('--status', help='Filter by update status',
107               type=click.Choice(['pending', 'testing', 'stable', 'obsolete',
108                                  'unpushed', 'processing']))
109 @click.option('--suggest', help='Filter by post-update user suggestion',
110               type=click.Choice(['logout', 'reboot']))
111 @click.option('--type', default=None, help='Filter by update type',
112               type=click.Choice(['newpackage', 'security', 'bugfix', 'enhancement']))
113 @click.option('--user', help='Updates submitted by a specific user')
114 @click.option('--staging', help='Use the staging bodhi instance',
115               is_flag=True, default=False)
116 def query(**kwargs):
117     client = bindings.BodhiClient(staging=kwargs['staging'])
118     resp = client.query(**kwargs)
119     print_resp(resp, client)
120 
121 
122 @updates.command()
123 @click.argument('update')
124 @click.argument('state')
125 @click.option('--user', envvar='USERNAME')
126 @click.option('--password', prompt=True, hide_input=True)
127 @click.option('--request', help='Requested repository',
128               type=click.Choice(['testing', 'stable', 'unpush', 'obsolete', 'revoke']))
129 @click.option('--staging', help='Use the staging bodhi instance',
130               is_flag=True, default=False)
131 def request(update, state, user, password, **kwargs):
132     client = bindings.BodhiClient(username=user, password=password, staging=kwargs['staging'])
133 
134     try:
135         resp = client.request(update, state)
136     except bindings.UpdateNotFound as exc:
137         raise click.BadParameter(unicode(exc), param_hint='UPDATE')
138 
139     print_resp(resp, client)
140 
141 
142 @updates.command()
143 @click.argument('update')
144 @click.argument('text')
145 @click.option('--karma', default=0, type=click.INT, help='The karma for this comment (+1/0/-1)')
146 @click.option('--user', envvar='USERNAME')
147 @click.option('--password', prompt=True, hide_input=True)
148 @click.option('--staging', help='Use the staging bodhi instance',
149               is_flag=True, default=False)
150 def comment(update, text, karma, user, password, **kwargs):
151     client = bindings.BodhiClient(username=user, password=password, staging=kwargs['staging'])
152     print('%r %r %r' % (update, text, karma))
153     resp = client.comment(update, text, karma)
154     print_resp(resp, client)
155 
156 
157 @updates.command()
158 @click.option('--staging', help='Use the staging bodhi instance',
159               is_flag=True, default=False)
160 @click.option('--cves', help='Download update(s) by CVE(s) (comma-separated list)')
161 @click.option('--updateid', help='Download update(s) by ID(s) (comma-separated list)')
162 @click.option('--builds', help='Download update(s) by build NVR(s) (comma-separated list)')
163 def download(**kwargs):
164     client = bindings.BodhiClient(staging=kwargs['staging'])
165     del(kwargs['staging'])
166     # At this point we need to have reduced the kwargs dict to only our
167     # query options (cves, updateid, builds)
168     if not any(kwargs.values()):
169         click.echo("ERROR: must specify at least one of --cves, --updateid, --builds")
170         sys.exit(1)
171 
172     # As the query method doesn't let us construct OR queries, we're
173     # gonna run one query for each option that was passed. The syntax
174     # for this is a bit ugly, sorry.
175     for (attr, value) in kwargs.items():
176         if value:
177             expecteds = len(value.split(','))
178             resp = client.query(**{attr: value})
179             if len(resp.updates) == 0:
180                 click.echo("WARNING: No {0} found!".format(attr))
181             elif len(resp.updates) < expecteds:
182                 click.echo("WARNING: Some {0} not found!".format(attr))
183             # Not sure if we need a check for > expecteds, I don't
184             # *think* that should ever be possible for these opts.
185 
186             for update in resp.updates:
187                 click.echo("Downloading packages from {0}".format(update['title']))
188                 for build in update['builds']:
189                     # subprocess is icky, but koji module doesn't
190                     # expose this in any usable way, and we don't want
191                     # to rewrite it here.
192                     args = ('koji', 'download-build', '--arch=noarch',
193                             '--arch={0}'.format(platform.machine()), build['nvr'])
194                     ret = subprocess.call(args)
195                     if ret:
196                         click.echo("WARNING: download of {0} failed!".format(build['nvr']))
197 
198 
199 @cli.group()
200 def overrides():
201     pass
202 
203 
204 @overrides.command('query')
205 @click.option('--user', default=None,
206               help='Updates submitted by a specific user')
207 @click.option('--staging', help='Use the staging bodhi instance',
208               is_flag=True, default=False)
209 def query_buildroot_overrides(user=None, **kwargs):
210     client = bindings.BodhiClient(staging=kwargs['staging'])
211     resp = client.list_overrides(user=user)
212     print_resp(resp, client)
213 
214 
215 @overrides.command('save')
216 @click.argument('nvr')
217 @click.option('--duration', default=7, type=click.INT,
218               help='Number of days the override should exist.')
219 @click.option('--notes', default="No explanation given...",
220               help='Notes on why this override is in place.')
221 @click.option('--user', envvar='USERNAME')
222 @click.option('--password', prompt=True, hide_input=True)
223 @click.option('--staging', help='Use the staging bodhi instance',
224               is_flag=True, default=False)
225 def save_buildroot_overrides(nvr, duration, notes, user, password, staging):
226     client = bindings.BodhiClient(username=user, password=password, staging=staging)
227     resp = client.save_override(nvr=nvr, duration=duration, notes=notes)
228     print_resp(resp, client)
229 
230 
231 def print_resp(resp, client):
232     if 'updates' in resp:
233         if len(resp.updates) == 1:
234             click.echo(client.update_str(resp.updates[0]))
235         else:
236             for update in resp.updates:
237                 click.echo(client.update_str(update, minimal=True).strip())
238         if 'total' in resp:
239             click.echo('%s updates found (%d shown)' % (
240                 resp.total, len(resp.updates)))
241     elif resp.get('update'):
242         click.echo(client.update_str(resp['update']))
243     elif 'title' in resp:
244         click.echo(client.update_str(resp))
245     elif 'overrides' in resp:
246         if len(resp.overrides) == 1:
247             click.echo(client.override_str(resp.overrides[0]))
248         else:
249             for override in resp.overrides:
250                 click.echo(client.override_str(override).strip())
251         click.echo(
252             '%s overrides found (%d shown)' % (resp.total, len(resp.overrides)))
253     elif 'build' in resp:
254         click.echo(client.override_str(resp))
255     elif 'comment' in resp:
256         click.echo('The following comment was added to %s' % resp.comment['update'].title)
257         click.echo(resp.comment.text)
258     elif 'errors' in resp:
259         for error in resp['errors']:
260             click.echo("ERROR: %s" % error['description'])
261         sys.exit(1)
262     else:
263         click.echo(resp)
264 
265     if resp.get('caveats', None):
266         click.echo('Caveats:')
267         for caveat in resp.caveats:
268             click.echo(caveat.description)
269 
270 
271 if __name__ == '__main__':
272     cli()
273
```
--- 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/bodhi/client/__init__.py b/bodhi/client/__init__.py
--- a/bodhi/client/__init__.py
+++ b/bodhi/client/__init__.py
@@ -124,8 +124,6 @@
 @click.argument('state')
 @click.option('--user', envvar='USERNAME')
 @click.option('--password', prompt=True, hide_input=True)
-@click.option('--request', help='Requested repository',
-              type=click.Choice(['testing', 'stable', 'unpush', 'obsolete', 'revoke']))
 @click.option('--staging', help='Use the staging bodhi instance',
               is_flag=True, default=False)
 def request(update, state, user, password, **kwargs):

{"golden_diff": "diff --git a/bodhi/client/__init__.py b/bodhi/client/__init__.py\n--- a/bodhi/client/__init__.py\n+++ b/bodhi/client/__init__.py\n@@ -124,8 +124,6 @@\n @click.argument('state')\n @click.option('--user', envvar='USERNAME')\n @click.option('--password', prompt=True, hide_input=True)\n-@click.option('--request', help='Requested repository',\n-              type=click.Choice(['testing', 'stable', 'unpush', 'obsolete', 'revoke']))\n @click.option('--staging', help='Use the staging bodhi instance',\n               is_flag=True, default=False)\n def request(update, state, user, password, **kwargs):\n", "issue": " Duplicate parameters for setting the state of request\n[Lukas Slebodnik filed this issue in Bugzilla](https://bugzilla.redhat.com/show_bug.cgi?id=1408198):\r\n\r\n> Description of problem:\r\n> Acording to the help the state of package can be changed either by parameter --request and also as a last parameter.\r\n>\r\n> I didn't test but whether parameter --request is accepted or has higher priority then the last argument. But such situation is confusing.\r\n> You should decide which way can be used. But there should be just one way.  \r\n> \r\n> Version-Release number of selected component (if applicable):\r\n> sh$ rpm -q bodhi-client \r\n> bodhi-client-2.3.3-1.fc26.noarch\r\n> \r\n> How reproducible:\r\n> Deterministic\r\n> \r\n> Additional info:\r\n> 1. bodhi updates request --help\r\n> Usage: bodhi updates request [OPTIONS] UPDATE STATE\r\n> \r\n> Options:\r\n>   --user TEXT\r\n>   --password TEXT\r\n>   --request [testing|stable|unpush|obsolete|revoke]\r\n>                                   Requested repository\r\n>   --staging                       Use the staging bodhi instance\r\n>   --help                          Show this message and exit.\r\n> \r\n> man bodhi says:\r\n>        bodhi updates request [options] <update> <state>\r\n>           Request  that the given update be changed to the given state. update\r\n>           should be given by update id, and state should be  one  of  testing,\r\n>           stable, unpush, obsolete, or revoke.\r\n>\r\n>\r\n> BTW, if you decide to use state from last parameter then IMHO it would be better to change or der of STATE and UPDATE. It will be simpler to implement bash completion for such order.\n", "before_files": [{"content": "# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License\n# as published by the Free Software Foundation; either version 2\n# of the License, or (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n\nimport os\nimport platform\nimport subprocess\nimport sys\nimport traceback\n\nimport click\n\nfrom bodhi.client import bindings\n\n\n@click.group()\n@click.version_option(message='%(version)s')\ndef cli():\n    pass\n\n\n@cli.group()\ndef updates():\n    pass\n\n\n@updates.command()\n@click.argument('builds')\n@click.option('--user', envvar='USERNAME')\n@click.option('--password', prompt=True, hide_input=True)\n@click.option('--type', default='bugfix', help='Update type', required=True,\n              type=click.Choice(['security', 'bugfix',\n                                 'enhancement', 'newpackage']))\n@click.option('--notes', help='Update description')\n@click.option('--notes-file', help='Update description from a file')\n@click.option('--bugs', help='Comma-seperated list of bug numbers', default='')\n@click.option('--close-bugs', default=True, is_flag=True, help='Automatically close bugs')\n@click.option('--request', help='Requested repository',\n              type=click.Choice(['testing', 'stable', 'unpush']))\n@click.option('--autokarma', default=True, is_flag=True, help='Enable karma automatism')\n@click.option('--stable-karma', type=click.INT, help='Stable karma threshold')\n@click.option('--unstable-karma', type=click.INT, help='Unstable karma threshold')\n@click.option('--suggest', help='Post-update user suggestion',\n              type=click.Choice(['logout', 'reboot']))\n@click.option('--file', help='A text file containing all the update details')\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef new(user, password, **kwargs):\n    client = bindings.BodhiClient(username=user, password=password, staging=kwargs['staging'])\n\n    if kwargs['file'] is None:\n        updates = [kwargs]\n\n    else:\n        updates = client.parse_file(os.path.abspath(kwargs['file']))\n\n    if kwargs['notes_file'] is not None:\n        if kwargs['notes'] is None:\n            with open(kwargs['notes_file'], 'r') as fin:\n                kwargs['notes'] = fin.read()\n\n        else:\n            click.echo(\"ERROR: Cannot specify --notes and --notes-file\")\n            sys.exit(1)\n\n    for update in updates:\n        try:\n            resp = client.save(**update)\n            print_resp(resp, client)\n        except bindings.BodhiClientException as e:\n            click.echo(str(e))\n        except Exception as e:\n            traceback.print_exc()\n\n\n@updates.command()\n@click.option('--updateid', help='Query by update ID (eg: FEDORA-2015-0001)')\n@click.option('--approved-since', help='Approved after a specific timestamp')\n@click.option('--modified-since', help='Modified after a specific timestamp')\n@click.option('--builds', help='Query updates based on builds')\n@click.option('--bugs', help='A list of bug numbers')\n@click.option('--critpath', is_flag=True, default=None,\n              help='Query only critical path packages')\n@click.option('--cves', help='Query by CVE id')\n@click.option('--packages', help='Query by package name(s)')\n@click.option('--pushed', is_flag=True, default=None,\n              help='Filter by pushed updates')\n@click.option('--pushed-since',\n              help='Updates that have been pushed after a certain time')\n@click.option('--releases', help='Updates for specific releases')\n@click.option('--locked', help='Updates that are in a locked state')\n@click.option('--request', help='Updates with a specific request',\n              type=click.Choice(['testing', 'stable', 'unpush']))\n@click.option('--submitted-since',\n              help='Updates that have been submitted since a certain time')\n@click.option('--status', help='Filter by update status',\n              type=click.Choice(['pending', 'testing', 'stable', 'obsolete',\n                                 'unpushed', 'processing']))\n@click.option('--suggest', help='Filter by post-update user suggestion',\n              type=click.Choice(['logout', 'reboot']))\n@click.option('--type', default=None, help='Filter by update type',\n              type=click.Choice(['newpackage', 'security', 'bugfix', 'enhancement']))\n@click.option('--user', help='Updates submitted by a specific user')\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef query(**kwargs):\n    client = bindings.BodhiClient(staging=kwargs['staging'])\n    resp = client.query(**kwargs)\n    print_resp(resp, client)\n\n\n@updates.command()\n@click.argument('update')\n@click.argument('state')\n@click.option('--user', envvar='USERNAME')\n@click.option('--password', prompt=True, hide_input=True)\n@click.option('--request', help='Requested repository',\n              type=click.Choice(['testing', 'stable', 'unpush', 'obsolete', 'revoke']))\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef request(update, state, user, password, **kwargs):\n    client = bindings.BodhiClient(username=user, password=password, staging=kwargs['staging'])\n\n    try:\n        resp = client.request(update, state)\n    except bindings.UpdateNotFound as exc:\n        raise click.BadParameter(unicode(exc), param_hint='UPDATE')\n\n    print_resp(resp, client)\n\n\n@updates.command()\n@click.argument('update')\n@click.argument('text')\n@click.option('--karma', default=0, type=click.INT, help='The karma for this comment (+1/0/-1)')\n@click.option('--user', envvar='USERNAME')\n@click.option('--password', prompt=True, hide_input=True)\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef comment(update, text, karma, user, password, **kwargs):\n    client = bindings.BodhiClient(username=user, password=password, staging=kwargs['staging'])\n    print('%r %r %r' % (update, text, karma))\n    resp = client.comment(update, text, karma)\n    print_resp(resp, client)\n\n\n@updates.command()\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\n@click.option('--cves', help='Download update(s) by CVE(s) (comma-separated list)')\n@click.option('--updateid', help='Download update(s) by ID(s) (comma-separated list)')\n@click.option('--builds', help='Download update(s) by build NVR(s) (comma-separated list)')\ndef download(**kwargs):\n    client = bindings.BodhiClient(staging=kwargs['staging'])\n    del(kwargs['staging'])\n    # At this point we need to have reduced the kwargs dict to only our\n    # query options (cves, updateid, builds)\n    if not any(kwargs.values()):\n        click.echo(\"ERROR: must specify at least one of --cves, --updateid, --builds\")\n        sys.exit(1)\n\n    # As the query method doesn't let us construct OR queries, we're\n    # gonna run one query for each option that was passed. The syntax\n    # for this is a bit ugly, sorry.\n    for (attr, value) in kwargs.items():\n        if value:\n            expecteds = len(value.split(','))\n            resp = client.query(**{attr: value})\n            if len(resp.updates) == 0:\n                click.echo(\"WARNING: No {0} found!\".format(attr))\n            elif len(resp.updates) < expecteds:\n                click.echo(\"WARNING: Some {0} not found!\".format(attr))\n            # Not sure if we need a check for > expecteds, I don't\n            # *think* that should ever be possible for these opts.\n\n            for update in resp.updates:\n                click.echo(\"Downloading packages from {0}\".format(update['title']))\n                for build in update['builds']:\n                    # subprocess is icky, but koji module doesn't\n                    # expose this in any usable way, and we don't want\n                    # to rewrite it here.\n                    args = ('koji', 'download-build', '--arch=noarch',\n                            '--arch={0}'.format(platform.machine()), build['nvr'])\n                    ret = subprocess.call(args)\n                    if ret:\n                        click.echo(\"WARNING: download of {0} failed!\".format(build['nvr']))\n\n\n@cli.group()\ndef overrides():\n    pass\n\n\n@overrides.command('query')\n@click.option('--user', default=None,\n              help='Updates submitted by a specific user')\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef query_buildroot_overrides(user=None, **kwargs):\n    client = bindings.BodhiClient(staging=kwargs['staging'])\n    resp = client.list_overrides(user=user)\n    print_resp(resp, client)\n\n\n@overrides.command('save')\n@click.argument('nvr')\n@click.option('--duration', default=7, type=click.INT,\n              help='Number of days the override should exist.')\n@click.option('--notes', default=\"No explanation given...\",\n              help='Notes on why this override is in place.')\n@click.option('--user', envvar='USERNAME')\n@click.option('--password', prompt=True, hide_input=True)\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef save_buildroot_overrides(nvr, duration, notes, user, password, staging):\n    client = bindings.BodhiClient(username=user, password=password, staging=staging)\n    resp = client.save_override(nvr=nvr, duration=duration, notes=notes)\n    print_resp(resp, client)\n\n\ndef print_resp(resp, client):\n    if 'updates' in resp:\n        if len(resp.updates) == 1:\n            click.echo(client.update_str(resp.updates[0]))\n        else:\n            for update in resp.updates:\n                click.echo(client.update_str(update, minimal=True).strip())\n        if 'total' in resp:\n            click.echo('%s updates found (%d shown)' % (\n                resp.total, len(resp.updates)))\n    elif resp.get('update'):\n        click.echo(client.update_str(resp['update']))\n    elif 'title' in resp:\n        click.echo(client.update_str(resp))\n    elif 'overrides' in resp:\n        if len(resp.overrides) == 1:\n            click.echo(client.override_str(resp.overrides[0]))\n        else:\n            for override in resp.overrides:\n                click.echo(client.override_str(override).strip())\n        click.echo(\n            '%s overrides found (%d shown)' % (resp.total, len(resp.overrides)))\n    elif 'build' in resp:\n        click.echo(client.override_str(resp))\n    elif 'comment' in resp:\n        click.echo('The following comment was added to %s' % resp.comment['update'].title)\n        click.echo(resp.comment.text)\n    elif 'errors' in resp:\n        for error in resp['errors']:\n            click.echo(\"ERROR: %s\" % error['description'])\n        sys.exit(1)\n    else:\n        click.echo(resp)\n\n    if resp.get('caveats', None):\n        click.echo('Caveats:')\n        for caveat in resp.caveats:\n            click.echo(caveat.description)\n\n\nif __name__ == '__main__':\n    cli()\n", "path": "bodhi/client/__init__.py"}], "after_files": [{"content": "# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License\n# as published by the Free Software Foundation; either version 2\n# of the License, or (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n\nimport os\nimport platform\nimport subprocess\nimport sys\nimport traceback\n\nimport click\n\nfrom bodhi.client import bindings\n\n\n@click.group()\n@click.version_option(message='%(version)s')\ndef cli():\n    pass\n\n\n@cli.group()\ndef updates():\n    pass\n\n\n@updates.command()\n@click.argument('builds')\n@click.option('--user', envvar='USERNAME')\n@click.option('--password', prompt=True, hide_input=True)\n@click.option('--type', default='bugfix', help='Update type', required=True,\n              type=click.Choice(['security', 'bugfix',\n                                 'enhancement', 'newpackage']))\n@click.option('--notes', help='Update description')\n@click.option('--notes-file', help='Update description from a file')\n@click.option('--bugs', help='Comma-seperated list of bug numbers', default='')\n@click.option('--close-bugs', default=True, is_flag=True, help='Automatically close bugs')\n@click.option('--request', help='Requested repository',\n              type=click.Choice(['testing', 'stable', 'unpush']))\n@click.option('--autokarma', default=True, is_flag=True, help='Enable karma automatism')\n@click.option('--stable-karma', type=click.INT, help='Stable karma threshold')\n@click.option('--unstable-karma', type=click.INT, help='Unstable karma threshold')\n@click.option('--suggest', help='Post-update user suggestion',\n              type=click.Choice(['logout', 'reboot']))\n@click.option('--file', help='A text file containing all the update details')\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef new(user, password, **kwargs):\n    client = bindings.BodhiClient(username=user, password=password, staging=kwargs['staging'])\n\n    if kwargs['file'] is None:\n        updates = [kwargs]\n\n    else:\n        updates = client.parse_file(os.path.abspath(kwargs['file']))\n\n    if kwargs['notes_file'] is not None:\n        if kwargs['notes'] is None:\n            with open(kwargs['notes_file'], 'r') as fin:\n                kwargs['notes'] = fin.read()\n\n        else:\n            click.echo(\"ERROR: Cannot specify --notes and --notes-file\")\n            sys.exit(1)\n\n    for update in updates:\n        try:\n            resp = client.save(**update)\n            print_resp(resp, client)\n        except bindings.BodhiClientException as e:\n            click.echo(str(e))\n        except Exception as e:\n            traceback.print_exc()\n\n\n@updates.command()\n@click.option('--updateid', help='Query by update ID (eg: FEDORA-2015-0001)')\n@click.option('--approved-since', help='Approved after a specific timestamp')\n@click.option('--modified-since', help='Modified after a specific timestamp')\n@click.option('--builds', help='Query updates based on builds')\n@click.option('--bugs', help='A list of bug numbers')\n@click.option('--critpath', is_flag=True, default=None,\n              help='Query only critical path packages')\n@click.option('--cves', help='Query by CVE id')\n@click.option('--packages', help='Query by package name(s)')\n@click.option('--pushed', is_flag=True, default=None,\n              help='Filter by pushed updates')\n@click.option('--pushed-since',\n              help='Updates that have been pushed after a certain time')\n@click.option('--releases', help='Updates for specific releases')\n@click.option('--locked', help='Updates that are in a locked state')\n@click.option('--request', help='Updates with a specific request',\n              type=click.Choice(['testing', 'stable', 'unpush']))\n@click.option('--submitted-since',\n              help='Updates that have been submitted since a certain time')\n@click.option('--status', help='Filter by update status',\n              type=click.Choice(['pending', 'testing', 'stable', 'obsolete',\n                                 'unpushed', 'processing']))\n@click.option('--suggest', help='Filter by post-update user suggestion',\n              type=click.Choice(['logout', 'reboot']))\n@click.option('--type', default=None, help='Filter by update type',\n              type=click.Choice(['newpackage', 'security', 'bugfix', 'enhancement']))\n@click.option('--user', help='Updates submitted by a specific user')\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef query(**kwargs):\n    client = bindings.BodhiClient(staging=kwargs['staging'])\n    resp = client.query(**kwargs)\n    print_resp(resp, client)\n\n\n@updates.command()\n@click.argument('update')\n@click.argument('state')\n@click.option('--user', envvar='USERNAME')\n@click.option('--password', prompt=True, hide_input=True)\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef request(update, state, user, password, **kwargs):\n    client = bindings.BodhiClient(username=user, password=password, staging=kwargs['staging'])\n\n    try:\n        resp = client.request(update, state)\n    except bindings.UpdateNotFound as exc:\n        raise click.BadParameter(unicode(exc), param_hint='UPDATE')\n\n    print_resp(resp, client)\n\n\n@updates.command()\n@click.argument('update')\n@click.argument('text')\n@click.option('--karma', default=0, type=click.INT, help='The karma for this comment (+1/0/-1)')\n@click.option('--user', envvar='USERNAME')\n@click.option('--password', prompt=True, hide_input=True)\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef comment(update, text, karma, user, password, **kwargs):\n    client = bindings.BodhiClient(username=user, password=password, staging=kwargs['staging'])\n    print('%r %r %r' % (update, text, karma))\n    resp = client.comment(update, text, karma)\n    print_resp(resp, client)\n\n\n@updates.command()\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\n@click.option('--cves', help='Download update(s) by CVE(s) (comma-separated list)')\n@click.option('--updateid', help='Download update(s) by ID(s) (comma-separated list)')\n@click.option('--builds', help='Download update(s) by build NVR(s) (comma-separated list)')\ndef download(**kwargs):\n    client = bindings.BodhiClient(staging=kwargs['staging'])\n    del(kwargs['staging'])\n    # At this point we need to have reduced the kwargs dict to only our\n    # query options (cves, updateid, builds)\n    if not any(kwargs.values()):\n        click.echo(\"ERROR: must specify at least one of --cves, --updateid, --builds\")\n        sys.exit(1)\n\n    # As the query method doesn't let us construct OR queries, we're\n    # gonna run one query for each option that was passed. The syntax\n    # for this is a bit ugly, sorry.\n    for (attr, value) in kwargs.items():\n        if value:\n            expecteds = len(value.split(','))\n            resp = client.query(**{attr: value})\n            if len(resp.updates) == 0:\n                click.echo(\"WARNING: No {0} found!\".format(attr))\n            elif len(resp.updates) < expecteds:\n                click.echo(\"WARNING: Some {0} not found!\".format(attr))\n            # Not sure if we need a check for > expecteds, I don't\n            # *think* that should ever be possible for these opts.\n\n            for update in resp.updates:\n                click.echo(\"Downloading packages from {0}\".format(update['title']))\n                for build in update['builds']:\n                    # subprocess is icky, but koji module doesn't\n                    # expose this in any usable way, and we don't want\n                    # to rewrite it here.\n                    args = ('koji', 'download-build', '--arch=noarch',\n                            '--arch={0}'.format(platform.machine()), build['nvr'])\n                    ret = subprocess.call(args)\n                    if ret:\n                        click.echo(\"WARNING: download of {0} failed!\".format(build['nvr']))\n\n\n@cli.group()\ndef overrides():\n    pass\n\n\n@overrides.command('query')\n@click.option('--user', default=None,\n              help='Updates submitted by a specific user')\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef query_buildroot_overrides(user=None, **kwargs):\n    client = bindings.BodhiClient(staging=kwargs['staging'])\n    resp = client.list_overrides(user=user)\n    print_resp(resp, client)\n\n\n@overrides.command('save')\n@click.argument('nvr')\n@click.option('--duration', default=7, type=click.INT,\n              help='Number of days the override should exist.')\n@click.option('--notes', default=\"No explanation given...\",\n              help='Notes on why this override is in place.')\n@click.option('--user', envvar='USERNAME')\n@click.option('--password', prompt=True, hide_input=True)\n@click.option('--staging', help='Use the staging bodhi instance',\n              is_flag=True, default=False)\ndef save_buildroot_overrides(nvr, duration, notes, user, password, staging):\n    client = bindings.BodhiClient(username=user, password=password, staging=staging)\n    resp = client.save_override(nvr=nvr, duration=duration, notes=notes)\n    print_resp(resp, client)\n\n\ndef print_resp(resp, client):\n    if 'updates' in resp:\n        if len(resp.updates) == 1:\n            click.echo(client.update_str(resp.updates[0]))\n        else:\n            for update in resp.updates:\n                click.echo(client.update_str(update, minimal=True).strip())\n        if 'total' in resp:\n            click.echo('%s updates found (%d shown)' % (\n                resp.total, len(resp.updates)))\n    elif resp.get('update'):\n        click.echo(client.update_str(resp['update']))\n    elif 'title' in resp:\n        click.echo(client.update_str(resp))\n    elif 'overrides' in resp:\n        if len(resp.overrides) == 1:\n            click.echo(client.override_str(resp.overrides[0]))\n        else:\n            for override in resp.overrides:\n                click.echo(client.override_str(override).strip())\n        click.echo(\n            '%s overrides found (%d shown)' % (resp.total, len(resp.overrides)))\n    elif 'build' in resp:\n        click.echo(client.override_str(resp))\n    elif 'comment' in resp:\n        click.echo('The following comment was added to %s' % resp.comment['update'].title)\n        click.echo(resp.comment.text)\n    elif 'errors' in resp:\n        for error in resp['errors']:\n            click.echo(\"ERROR: %s\" % error['description'])\n        sys.exit(1)\n    else:\n        click.echo(resp)\n\n    if resp.get('caveats', None):\n        click.echo('Caveats:')\n        for caveat in resp.caveats:\n            click.echo(caveat.description)\n\n\nif __name__ == '__main__':\n    cli()\n", "path": "bodhi/client/__init__.py"}]}