summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2011-07-07 18:04:14 -0500
committerSol Jerome <sol.jerome@gmail.com>2011-07-07 18:04:14 -0500
commit841cdd56e4ae141f8ba159e8cacc6c70003dd2fb (patch)
tree9a1889970f3900545b0894241112b9c51275ba0b
parent2c6f7918b0e81933cd0c36f44d994a52445e3a7f (diff)
downloadbcfg2-841cdd56e4ae141f8ba159e8cacc6c70003dd2fb.tar.gz
bcfg2-841cdd56e4ae141f8ba159e8cacc6c70003dd2fb.tar.bz2
bcfg2-841cdd56e4ae141f8ba159e8cacc6c70003dd2fb.zip
export.py: Pylint/PEP8 fixes
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
-rwxr-xr-xtools/export.py187
1 files changed, 109 insertions, 78 deletions
diff --git a/tools/export.py b/tools/export.py
index c690ecd73..e4f16330d 100755
--- a/tools/export.py
+++ b/tools/export.py
@@ -19,26 +19,29 @@ except ImportError:
from email.utils import formatdate
# In lieu of a config file
-help_message = '''This script creates a tag in the Bcfg2 git repo and exports a tar file of the code
-at that tag.
+help_message = \
+ """This script creates a tag in the Bcfg2 git repo and exports
+a tar file of the code at that tag.
This script must be run at the top of your git repository.
-'''
+"""
pkgname = 'bcfg2'
ftphost = 'terra.mcs.anl.gov'
ftpdir = '/mcs/ftp/pub/bcfg'
+
def run(command):
return Popen(command, shell=True, stdout=PIPE).communicate()
+
def find_and_replace(f, iftest, rline, startswith=False, dryrun=False):
if dryrun:
- inplace=0
+ inplace = 0
print "*** dry-run: New '%s' will look like this:" % f
else:
- inplace=1
+ inplace = 1
for line in fileinput.input(f, inplace):
if startswith:
if line.startswith(iftest):
@@ -51,74 +54,85 @@ def find_and_replace(f, iftest, rline, startswith=False, dryrun=False):
if dryrun:
print "*** End '%s'" % f
-def main(argv=None):
+
+def main():
# This is where the options are set up
- p = optparse.OptionParser(description = help_message,
- prog = 'export2.py',
- version = '0.1',
- usage = '%prog [-h|--help] [-v|--version] [-n|--dry-run] [-d|--debug]')
- p.add_option('--verbose', '-v',
- action = 'store_true',
- help = 'turns on verbose mode',
- default = False,
- dest = 'verbose')
+ p = optparse.OptionParser(description=help_message,
+ prog=sys.argv[0],
+ version='0.1',
+ usage='%prog [-h|--help] [-v|--version] '
+ '[-n|--dry-run] [-d|--debug]')
+ p.add_option('--verbose', '-v',
+ action='store_true',
+ help='turns on verbose mode',
+ default=False,
+ dest='verbose')
p.add_option('--dry-run', '-n',
- action = 'store_true',
- help = 'run in dry-run mode; no changes will be made to the system',
- default = False,
- dest = 'dryrun')
+ action='store_true',
+ help='run in dry-run mode; '
+ 'no changes will be made to the system',
+ default=False,
+ dest='dryrun')
p.add_option('--debug', '-d',
- action = 'store_true',
- help = 'run in debun mode',
- default = False,
- dest = 'debug')
+ action='store_true',
+ help='run in debun mode',
+ default=False,
+ dest='debug')
p.add_option('--paranoid', '-P',
- action = 'store_true',
- help = 'run in paranoid mode, make changes but do not commit to repository',
- default = False,
- dest = 'paranoid')
- options, arguments = p.parse_args()
-
+ action='store_true',
+ help='run in paranoid mode, '
+ 'make changes but do not commit to repository',
+ default=False,
+ dest='paranoid')
+ options = p.parse_args()[0]
+
if options.debug:
print options
print "What should debug mode do?"
-
+
# py3k compatibility
try:
- version = raw_input("Please enter the Bcfg2 version you are tagging (e.g. 1.0.0): ")
+ version = raw_input("Please enter the Bcfg2 version "
+ "you are tagging (e.g. 1.0.0): ")
name = raw_input("Your name: ")
email = raw_input("Your email: ")
except NameError:
- version = input("Please enter the Bcfg2 version you are tagging (e.g. 1.0.0): ")
+ version = input("Please enter the Bcfg2 version "
+ "you are tagging (e.g. 1.0.0): ")
name = input("Your name: ")
email = input("Your email: ")
-
+
# parse version into Major.Minor.MicroBuild and validate
vkeys = ["major", "minor", "microbuild"]
try:
- version_info = dict(zip(vkeys,version.split(".")))
+ version_info = dict(zip(vkeys, version.split(".")))
version_info["micro"] = version_info["microbuild"][0:1]
version_info["build"] = version_info["microbuild"][1:]
- version_release = "%s.%s.%s" % (version_info['major'], version_info['minor'], version_info['micro'])
-
+ version_release = "%s.%s.%s" % (version_info['major'],
+ version_info['minor'],
+ version_info['micro'])
+
if options.debug:
print "version is %s" % version
print "version_info is %s" % version_info
print "version_release is %s" % version_release
- if not version_info["major"].isdigit() or not version_info["minor"].isdigit() or not version_info["micro"]:
+ if not version_info["major"].isdigit() \
+ or not version_info["minor"].isdigit() \
+ or not version_info["micro"]:
raise VersionError('isdigit() test failed')
if len(version_info["micro"]) > 1:
- raise VersionError('micro must be single digit because IFMinorVersion restrictions in Mac OS X Packaging')
+ raise VersionError('micro must be single digit because '
+ 'IFMinorVersion restrictions in '
+ 'Mac OS X Packaging')
except:
- print """Version must be of the form Major.Minor.MicroBuild,
-where Major and Minor are integers and
+ print """Version must be of the form Major.Minor.MicroBuild,
+where Major and Minor are integers and
Micro is a single digit optionally followed by Build (i.e. pre##)
E.G. 1.2.0pre1 is a valid version.
"""
quit()
-
tarname = '/tmp/%s-%s.tar.gz' % (pkgname, version)
newchangelog = \
@@ -128,13 +142,16 @@ E.G. 1.2.0pre1 is a valid version.
-- %s <%s> %s
-""" % (version_release, version_info['build'], name, email, formatdate(localtime=True))
-
-
+""" % (version_release,
+ version_info['build'],
+ name,
+ email,
+ formatdate(localtime=True))
+
# write out the new debian changelog
if options.dryrun:
- print "*** Add the following to the top of debian/changelog:\n%s" % newchangelog
- print "\n"
+ print("*** Add the following to the top of debian/changelog:\n%s\n"
+ % newchangelog)
else:
try:
with open('debian/changelog', 'r+') as f:
@@ -146,11 +163,13 @@ E.G. 1.2.0pre1 is a valid version.
print "Problem opening debian/changelog"
print help_message
quit()
-
+
# Update redhat directory versions
if options.dryrun:
- print "*** Replace redhat/VERIONS content with '%s'." % version_release
- print "*** Replace redhat/RELEASE content with '%s'." % version_info['build']
+ print("*** Replace redhat/VERIONS content with '%s'."
+ % version_release)
+ print("*** Replace redhat/RELEASE content with '%s'."
+ % version_info['build'])
else:
with open('redhat/VERSION', 'w') as f:
f.write("%s\n" % version_release)
@@ -158,52 +177,55 @@ E.G. 1.2.0pre1 is a valid version.
with open('redhat/RELEASE', 'w') as f:
f.write("0.0%s\n" % version_info['build'])
f.close()
-
+
# update solaris version
find_and_replace('solaris/Makefile', 'VERS=',
- 'VERS=%s-1\n' % version,
+ 'VERS=%s-1\n' % version,
startswith=True,
dryrun=options.dryrun)
find_and_replace('solaris/pkginfo.bcfg2', 'VERSION=',
- 'VERSION="%s"\n' % version,
- startswith=True,
+ 'VERSION="%s"\n' % version,
+ startswith=True,
dryrun=options.dryrun)
find_and_replace('solaris/pkginfo.bcfg2-server', 'VERSION=',
- 'VERSION="%s"\n' % version,
- startswith=True,
+ 'VERSION="%s"\n' % version,
+ startswith=True,
dryrun=options.dryrun)
# set new version in setup.py
- find_and_replace('setup.py', 'version=', ' version="%s",\n' % version,
+ find_and_replace('setup.py', 'version=', ' version="%s",\n' % version,
dryrun=options.dryrun)
# replace version in misc/bcfg2.spec
find_and_replace('misc/bcfg2.spec', 'Version:',
- 'Version: %s\n' % version,
+ 'Version: %s\n' % version,
dryrun=options.dryrun)
# update the version in reports
find_and_replace('src/lib/Server/Reports/reports/templates/base.html',
- 'Bcfg2 Version', ' <span>Bcfg2 Version %s</span>\n' % version,
+ 'Bcfg2 Version',
+ ' <span>Bcfg2 Version %s</span>\n' % version,
dryrun=options.dryrun)
# update the version in the docs
find_and_replace('doc/conf.py', 'version =',
- 'version = \'%s.%s\'\n' % (version_info['major'], version_info['minor']),
- startswith=True,
+ 'version = \'%s.%s\'\n' % (version_info['major'],
+ version_info['minor']),
+ startswith=True,
dryrun=options.dryrun)
find_and_replace('doc/conf.py', 'release =',
- 'release = \'%s\'\n' % (version_release),
- startswith=True,
+ 'release = \'%s\'\n' % (version_release),
+ startswith=True,
dryrun=options.dryrun)
# update osx Makefile
find_and_replace('osx/Makefile', 'BCFGVER =',
- 'BCFGVER = %s\n' % (version),
- startswith=True,
+ 'BCFGVER = %s\n' % (version),
+ startswith=True,
dryrun=options.dryrun)
find_and_replace('osx/Makefile', 'MAJOR =',
- 'MAJOR = %s\n' % (version_info['major']),
- startswith=True,
+ 'MAJOR = %s\n' % (version_info['major']),
+ startswith=True,
dryrun=options.dryrun)
find_and_replace('osx/Makefile', 'MINOR =',
- 'MINOR = %s%s\n' % (version_info['minor'], version_info['micro']),
- startswith=True,
+ 'MINOR = %s%s\n' % (version_info['minor'],
+ version_info['micro']),
+ startswith=True,
dryrun=options.dryrun)
# tag the release
@@ -214,24 +236,33 @@ E.G. 1.2.0pre1 is a valid version.
commando["vcs_commit"] = "git commit -asm 'Version bump to %s'" % version
- # NOTE: This will use the default email address key. If you want to sign the tag
- # using a different key, you will need to set 'signingkey' to the proper
- # value in the [user] section of your git configuration.
- commando["vcs_tag"] = "git tag -s v%s -m 'tagged %s release'" % (version, version)
+ # NOTE: This will use the default email address key. If you want to sign
+ # the tag using a different key, you will need to set 'signingkey'
+ # to the proper value in the [user] section of your git
+ # configuration.
+ commando["vcs_tag"] = "git tag -s v%s -m 'tagged %s release'" % (version,
+ version)
- commando["create_archive"] = "git archive --format=tar --prefix=%s-%s/ v%s | gzip > %s" % \
- (pkgname, version, version, tarname)
+ commando["create_archive"] = \
+ "git archive --format=tar --prefix=%s-%s/ v%s | gzip > %s" \
+ % (pkgname, version, version, tarname)
- commando["gpg_encrypt"] = "gpg --armor --output %s.gpg --detach-sig %s" % (tarname, tarname)
+ commando["gpg_encrypt"] = "gpg --armor --output %s.gpg --detach-sig %s" \
+ % (tarname, tarname)
# upload release to ftp
- commando["scp_archive"] = "scp %s* terra.mcs.anl.gov:/mcs/ftp/pub/bcfg/" % tarname
-
+ commando["scp_archive"] = "scp %s* terra.mcs.anl.gov:/mcs/ftp/pub/bcfg/" \
+ % tarname
+
# Execute the commands
if options.paranoid:
commando_orders = ["vcs_diff"]
else:
- commando_orders = ["vcs_commit","vcs_tag","create_archive","gpg_encrypt","scp_archive"]
+ commando_orders = ["vcs_commit",
+ "vcs_tag",
+ "create_archive",
+ "gpg_encrypt",
+ "scp_archive"]
if options.dryrun:
for cmd in commando_orders: