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