mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-04-16 12:51:08 +00:00
* String improvements.
This commit is contained in:
parent
75b115a5dd
commit
cd3ec9ba7a
7
buildd
7
buildd
@ -21,6 +21,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# Our modules to import.
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@ -29,6 +30,7 @@ from optparse import OptionGroup
|
||||
from optparse import OptionParser
|
||||
from urllib import urlencode
|
||||
|
||||
# ubuntu-dev-tools modules.
|
||||
sys.path.append("/usr/share/ubuntu-dev-tools/")
|
||||
import common
|
||||
|
||||
@ -59,6 +61,11 @@ optParser.add_option_group(retryRescoreOptions)
|
||||
# Parse our options.
|
||||
(options, args) = optParser.parse_args()
|
||||
|
||||
# 'help' called by itself - show our help.
|
||||
if args[0].lower() in ("help") and len(args) == 1:
|
||||
optParser.print_help()
|
||||
sys.exit(0)
|
||||
|
||||
# Check we have the correct number of arguments.
|
||||
if len(args) < 3:
|
||||
optParser.error("Incorrect number of arguments.")
|
||||
|
25
common.py
25
common.py
@ -2,7 +2,7 @@
|
||||
# common.py - provides functions which are commonly used by the
|
||||
# ubuntu-dev-tools package.
|
||||
#
|
||||
# Copyright (C) 2008 Jonathan Patrick Davies <jpds@ubuntu.com>
|
||||
# Copyright (C) 2008 Jonathan Davies <jpds@ubuntu.com>
|
||||
# Copyright (C) 2008 Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||
#
|
||||
# Some of the functions are based upon code written by Martin Pitt
|
||||
@ -74,12 +74,17 @@ def checkReleaseExists(release):
|
||||
https://launchpad.net/ubuntu/releaseName page on Launchpad.
|
||||
|
||||
If an error is returned; the release does not exist. """
|
||||
release = release.split('-')[0] # remove pocket
|
||||
release = release.split('-')[0] # Remove pocket
|
||||
try:
|
||||
urllib2.urlopen("https://launchpad.net/ubuntu/%s" % release)
|
||||
except urllib2.HTTPError:
|
||||
print >> sys.stderr, "The '%s' release does not appear to exist on " \
|
||||
"Launchpad." % release
|
||||
print >> sys.stderr, "The Ubuntu '%s' release does not appear to " \
|
||||
"exist on Launchpad." % release
|
||||
sys.exit(1)
|
||||
except urllib2.URLError, error: # Other error (NXDOMAIN, ...)
|
||||
(_, reason) = error.reason
|
||||
print >> sys.stderr, "Error while checking for Ubuntu '%s' " \
|
||||
"release on Launchpad: %s." % (release, reason)
|
||||
sys.exit(1)
|
||||
|
||||
def checkSourceExists(package, release):
|
||||
@ -91,6 +96,7 @@ def checkSourceExists(package, release):
|
||||
(release, pocket) = release.split('-', 1)
|
||||
else:
|
||||
pocket = 'release'
|
||||
|
||||
try:
|
||||
page = urllib2.urlopen('https://launchpad.net/ubuntu/+source/' + package).read()
|
||||
|
||||
@ -100,21 +106,18 @@ def checkSourceExists(package, release):
|
||||
print >> sys.stderr, "Unable to find source package '%s' in " \
|
||||
"the %s-%s pocket." % (package, release.capitalize(), pocket)
|
||||
sys.exit(1)
|
||||
|
||||
except urllib2.HTTPError, error: # Raised on 404.
|
||||
if error.code == 404:
|
||||
print >> sys.stderr, "The source package '%s' does not appear to " \
|
||||
"exist in Ubuntu." % package
|
||||
else: # Other error code, probably Launchpad malfunction.
|
||||
print >> sys.stderr, "Error while checking Launchpad for package: " \
|
||||
"%s." % error.code
|
||||
|
||||
print >> sys.stderr, "Error while checking Launchpad for Ubuntu " \
|
||||
"package: %s." % error.code
|
||||
sys.exit(1) # Exit. Error encountered.
|
||||
|
||||
except urllib2.URLError, error: # Other error (NXDOMAIN, ...)
|
||||
(_, reason) = error.reason
|
||||
print >> sys.stderr, "Error while checking Launchpad for package: %s." % \
|
||||
reason
|
||||
print >> sys.stderr, "Error while checking Launchpad for Ubuntu " \
|
||||
"package: %s." % reason
|
||||
sys.exit(1)
|
||||
|
||||
# Get package version.
|
||||
|
@ -49,7 +49,7 @@ def main():
|
||||
|
||||
(options, args) = optParser.parse_args()
|
||||
|
||||
# Parse our options aka Russian roulette time.
|
||||
# Parse our options.
|
||||
if len(args) != 1 and options.lpteam == None:
|
||||
optParser.error("No team has been specified.")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user