refactor script for commenting on launchpad bugs prior to move to project-config
When we move the release tagging scripts to the project-config repository, they will need to have minimal dependencies and shouldn't need to import other local modules. Move the launchpad code needed by launchpad_add_comment.py into the file, and move the file out of the cmds subdirectory to be a regular script instead. Change-Id: Ie004c2a14100611d4b7c1604dcf7f465a6f0246c
This commit is contained in:
parent
cbff5131a6
commit
13e3173bfb
|
@ -18,12 +18,13 @@
|
|||
# under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import os
|
||||
|
||||
import launchpadlib.launchpad
|
||||
import lazr.restfulclient.errors
|
||||
|
||||
from releasetools import launchpadutils
|
||||
|
||||
|
||||
def main():
|
||||
# Parameters
|
||||
|
@ -32,14 +33,33 @@ def main():
|
|||
default='Comment added by add_comment')
|
||||
parser.add_argument('--content', help='The comment content',
|
||||
default='Comment added by add_comment')
|
||||
launchpadutils.add_cli_arguments(parser)
|
||||
lp_grp = parser.add_argument_group('launchpad')
|
||||
lp_grp.add_argument(
|
||||
"--test",
|
||||
action='store_const',
|
||||
dest='lp_service_root',
|
||||
const='staging',
|
||||
default='production',
|
||||
help='Use LP staging server to test',
|
||||
)
|
||||
lp_grp.add_argument(
|
||||
'--credentials-file', '-c',
|
||||
dest='lp_creds_file',
|
||||
default=os.environ.get('LP_CREDS_FILE'),
|
||||
help=('plain-text credentials file, '
|
||||
'defaults to value of $LP_CREDS_FILE'),
|
||||
)
|
||||
parser.add_argument('bugs', type=int, nargs='+',
|
||||
help='Bugs to add comment to')
|
||||
args = parser.parse_args()
|
||||
|
||||
# Connect to Launchpad
|
||||
print("Connecting to Launchpad...")
|
||||
launchpad = launchpadutils.login(args)
|
||||
launchpad = launchpadlib.launchpad.Launchpad.login_with(
|
||||
application_name='openstack-releasing',
|
||||
service_root=args.lp_service_root,
|
||||
credentials_file=args.lp_creds_file,
|
||||
)
|
||||
|
||||
# Add comment
|
||||
for bugid in args.bugs:
|
||||
|
@ -52,3 +72,7 @@ def main():
|
|||
print(" TIMEOUT during save !")
|
||||
except Exception as e:
|
||||
print(" ERROR during save ! (%s)" % e)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -104,7 +104,7 @@ BUGS=$(git log $PREVIOUS..$VERSION | grep "Closes-Bug:" | egrep -o "[0-9]+")
|
|||
if [[ -z "$BUGS" ]]; then
|
||||
echo "No bugs found $PREVIOUS .. $VERSION"
|
||||
else
|
||||
add-comment \
|
||||
$TOOLSDIR/launchpad_add_comment.py \
|
||||
--subject="Fix included in $REPO $VERSION" \
|
||||
--content="This issue was fixed in the $REPO $VERSION $RELEASETYPE." \
|
||||
$BUGS
|
||||
|
|
|
@ -33,5 +33,4 @@ console_scripts =
|
|||
milestone-close = releasetools.cmds.milestone_close:main
|
||||
milestones-create = releasetools.cmds.milestones_create:main
|
||||
launchpad-login = releasetools.cmds.launchpad_login:main
|
||||
add-comment = releasetools.cmds.add_comment:main
|
||||
send-mail = releasetools.cmds.mail:main
|
Loading…
Reference in New Issue