| |
@@ -30,12 +30,14 @@
|
| |
import re
|
| |
|
| |
from optparse import OptionParser
|
| |
+ from shlex import quote
|
| |
from textwrap import wrap
|
| |
|
| |
# extra python modules
|
| |
# Used to catch fedora.client.AuthError and fedora.client.ServerError
|
| |
# exceptions
|
| |
import fedora
|
| |
+ import bodhi
|
| |
|
| |
# fedora_cert is optional. It is only used to get the real fas_username, which
|
| |
# is also supplied as a command line option and eventually in a config file.
|
| |
@@ -827,22 +829,31 @@
|
| |
pass
|
| |
|
| |
def send_comment(self, bc, update, comment, karma):
|
| |
- orig_retries = bc.retries
|
| |
- bc.retries = 1
|
| |
- for retry in range(0, self.options.retries + 1):
|
| |
+ # Prepare command for bodhi CLI
|
| |
+ command = "bodhi updates comment --karma {} --user {} {} {}".format(
|
| |
+ karma, self.options.fas_username, update["updateid"], quote(comment)
|
| |
+ )
|
| |
+ res = os.system(command)
|
| |
+ if res != 0:
|
| |
+ # If return code isn't 0, something went wrong, try to explain or workaround some cases
|
| |
+ if res == 1:
|
| |
+ return (False, 'Failed to connect to bodhi, is your internet connection working?')
|
| |
+ # Try to workaround https://github.com/fedora-infra/bodhi/issues/3298
|
| |
+ homedir = os.path.expanduser("~")
|
| |
+ if not homedir:
|
| |
+ # Bail out if we weren't able to get homedir
|
| |
+ return (False, 'Failed to get homedir')
|
| |
+ self.warning("Working around https://github.com/fedora-infra/bodhi/issues/3298 ...")
|
| |
try:
|
| |
- res = bc.comment(update["updateid"], comment, karma=karma)
|
| |
- bc.retries = orig_retries
|
| |
- return (True, res)
|
| |
- except fedora.client.AuthError as e:
|
| |
- self.warning("Authentication error")
|
| |
- bc.password = getpass.getpass('FAS password for %s: ' %
|
| |
- self.options.fas_username)
|
| |
- except fedora.client.ServerError as e:
|
| |
- self.warning("Server error: %s" % str(e))
|
| |
-
|
| |
- bc.retries = orig_retries
|
| |
- return (False, 'too many errors')
|
| |
+ os.remove(homedir + '/.fedora/openidbaseclient-sessions.cache')
|
| |
+ except FileNotFoundError:
|
| |
+ return (False, 'Failed to remove ~/.fedora/openidbaseclient-sessions.cache')
|
| |
+ res = os.system(command)
|
| |
+ if res != 0:
|
| |
+ return (False, 'Failed to submit comment and karma')
|
| |
+ return (True, res)
|
| |
+
|
| |
+ return (True, res)
|
| |
|
| |
|
| |
if __name__ == "__main__":
|
| |
This is a rebased #9 as a local branch so that we can easily collaborate on it.