mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-07 15:01:34 +00:00
requestsync: some more refactoring
This commit is contained in:
parent
c30c4865a4
commit
5e3e368bb8
14
requestsync
14
requestsync
@ -40,8 +40,8 @@ from ubuntutools.lp.lpapicache import Launchpad, LpApiWrapper, Distribution, Per
|
|||||||
import ubuntutools.common
|
import ubuntutools.common
|
||||||
import ubuntutools.packages
|
import ubuntutools.packages
|
||||||
|
|
||||||
from ubuntutools.requestsync.mail import getDebianSrcPkg
|
from ubuntutools.requestsync.mail import *
|
||||||
from ubuntutools.requestsync.common import getDebianChangelog
|
from ubuntutools.requestsync.common import *
|
||||||
|
|
||||||
def checkNeedsSponsorship(srcpkg):
|
def checkNeedsSponsorship(srcpkg):
|
||||||
"""
|
"""
|
||||||
@ -121,7 +121,7 @@ def checkExistingReports(package):
|
|||||||
def cur_version_component(sourcepkg, release):
|
def cur_version_component(sourcepkg, release):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
src = Distribution('ubuntu').getArchive().getSourcePackage(sourcepkg, release)
|
src = getUbuntuSrcPkg(sourcepkg, release)
|
||||||
return (src.getVersion(), src.getComponent())
|
return (src.getVersion(), src.getComponent())
|
||||||
|
|
||||||
except udtexceptions.PackageNotFoundException:
|
except udtexceptions.PackageNotFoundException:
|
||||||
@ -129,14 +129,6 @@ def cur_version_component(sourcepkg, release):
|
|||||||
print "%s doesn't appear to exist in %s, specify -n for a package not in Ubuntu." % (sourcepkg, release)
|
print "%s doesn't appear to exist in %s, specify -n for a package not in Ubuntu." % (sourcepkg, release)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def raw_input_exit_on_ctrlc(*args, **kwargs):
|
|
||||||
"""A wrapper around raw_input() to exit with a normalized message on Control-C"""
|
|
||||||
try:
|
|
||||||
return raw_input(*args, **kwargs)
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
print 'Abort requested. No sync request filed.'
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def get_email_address():
|
def get_email_address():
|
||||||
'''Get the DEBEMAIL environment variable or give an error.'''
|
'''Get the DEBEMAIL environment variable or give an error.'''
|
||||||
myemailaddr = os.getenv('DEBEMAIL')
|
myemailaddr = os.getenv('DEBEMAIL')
|
||||||
|
@ -23,6 +23,16 @@ import sys
|
|||||||
import urllib2
|
import urllib2
|
||||||
from debian_bundle.changelog import Changelog
|
from debian_bundle.changelog import Changelog
|
||||||
|
|
||||||
|
def raw_input_exit_on_ctrlc(*args, **kwargs):
|
||||||
|
'''
|
||||||
|
A wrapper around raw_input() to exit with a normalized message on Control-C
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
return raw_input(*args, **kwargs)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print 'Abort requested. No sync request filed.'
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def getDebianChangelog(srcpkg, version):
|
def getDebianChangelog(srcpkg, version):
|
||||||
'''
|
'''
|
||||||
Return the new changelog entries upto 'version'.
|
Return the new changelog entries upto 'version'.
|
||||||
|
@ -32,3 +32,9 @@ def getDebianSrcPkg(name, release):
|
|||||||
release = 'sid'
|
release = 'sid'
|
||||||
|
|
||||||
return debian_archive.getSourcePackage(name, release)
|
return debian_archive.getSourcePackage(name, release)
|
||||||
|
|
||||||
|
def getUbuntuSrcPkg(name, release):
|
||||||
|
ubuntu = Distribution('ubuntu')
|
||||||
|
ubuntu_archive = ubuntu.getArchive()
|
||||||
|
|
||||||
|
return ubuntu_archive.getSourcePackage(name, release)
|
||||||
|
@ -19,9 +19,11 @@
|
|||||||
# Please see the /usr/share/common-licenses/GPL-2 file for the full text
|
# Please see the /usr/share/common-licenses/GPL-2 file for the full text
|
||||||
# of the GNU General Public License license.
|
# of the GNU General Public License license.
|
||||||
|
|
||||||
from ..packages import checkIsInDebian
|
import subprocess
|
||||||
from ..lp.udtexceptions import PackageNotFoundException
|
from ..lp.udtexceptions import PackageNotFoundException
|
||||||
|
|
||||||
|
__all__ = ['getDebianSrcPkg', 'getUbuntuSrcPkg']
|
||||||
|
|
||||||
# Simulate the SourcePackage class from lpapiwrapper
|
# Simulate the SourcePackage class from lpapiwrapper
|
||||||
class SourcePackage(object):
|
class SourcePackage(object):
|
||||||
'''
|
'''
|
||||||
@ -41,23 +43,39 @@ class SourcePackage(object):
|
|||||||
def getComponent(self):
|
def getComponent(self):
|
||||||
return self.component
|
return self.component
|
||||||
|
|
||||||
def getDebianSrcPkg(name, release):
|
def rmadison(distro, package, release):
|
||||||
out = checkIsInDebian(name, release)
|
rmadison_cmd = subprocess.Popen(
|
||||||
if not out:
|
['rmadison', '-u', distro, '-a', 'source', '-s', release, package],
|
||||||
raise PackageNotFoundException(
|
stdout = subprocess.PIPE)
|
||||||
"'%s' doesn't appear to exist in Debian '%s'" % \
|
|
||||||
(name, release))
|
rmadison_out = rmadison_cmd.communicate()[0]
|
||||||
|
assert (rmadison_cmd.returncode == 0)
|
||||||
|
|
||||||
# Work-around for a bug in Debians madison.php script not returning
|
# Work-around for a bug in Debians madison.php script not returning
|
||||||
# only the source line
|
# only the source line
|
||||||
for line in out.splitlines():
|
for line in rmadison_out.splitlines():
|
||||||
if line.find('source') > 0:
|
if line.find('source') > 0:
|
||||||
out = line.split('|')
|
return map(lambda x: x.strip(), line.split('|'))
|
||||||
|
|
||||||
version = out[1].strip()
|
return None
|
||||||
|
|
||||||
|
def getSrcPkg(distro, name, release):
|
||||||
|
out = rmadison(distro, name, release)
|
||||||
|
if not out:
|
||||||
|
raise PackageNotFoundException(
|
||||||
|
"'%s' doesn't appear to exist in %s '%s'" % \
|
||||||
|
(name, distro.capitalize(), release))
|
||||||
|
|
||||||
|
version = out[1]
|
||||||
component = 'main'
|
component = 'main'
|
||||||
raw_comp = out[2].split('/')
|
raw_comp = out[2].split('/')
|
||||||
if len(raw_comp) == 2:
|
if len(raw_comp) == 2:
|
||||||
component = raw_comp[1].strip()
|
component = raw_comp[1]
|
||||||
|
|
||||||
return SourcePackage(name, version, component)
|
return SourcePackage(name, version, component)
|
||||||
|
|
||||||
|
def getDebianSrcPkg(name, release):
|
||||||
|
return getSrcPkg('debian', name, release)
|
||||||
|
|
||||||
|
def getUbuntuSrcPkg(name, release):
|
||||||
|
return getSrcPkg('ubuntu', name, release)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user