mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-26 18:31:10 +00:00
Pull out Python 2 support hacks
This commit is contained in:
parent
bb765237db
commit
301569e809
@ -22,6 +22,7 @@ import glob
|
|||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
@ -39,7 +40,6 @@ from ubuntutools.logger import Logger
|
|||||||
from ubuntutools.misc import (system_distribution, vendor_to_distroinfo,
|
from ubuntutools.misc import (system_distribution, vendor_to_distroinfo,
|
||||||
codename_to_distribution)
|
codename_to_distribution)
|
||||||
from ubuntutools.question import YesNoQuestion
|
from ubuntutools.question import YesNoQuestion
|
||||||
from ubuntutools import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
def error(msg):
|
def error(msg):
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
# that the target distribution is always meant to be Ubuntu Hardy.
|
# that the target distribution is always meant to be Ubuntu Hardy.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import debian.deb822
|
import debian.deb822
|
||||||
@ -40,7 +41,6 @@ import ubuntutools.version
|
|||||||
from ubuntutools.config import UDTConfig
|
from ubuntutools.config import UDTConfig
|
||||||
from ubuntutools.logger import Logger
|
from ubuntutools.logger import Logger
|
||||||
from ubuntutools.question import YesNoQuestion
|
from ubuntutools.question import YesNoQuestion
|
||||||
from ubuntutools import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
class PbuilderDist(object):
|
class PbuilderDist(object):
|
||||||
|
3
setup.py
3
setup.py
@ -4,12 +4,11 @@ from setuptools import setup
|
|||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import codecs
|
|
||||||
|
|
||||||
# look/set what version we have
|
# look/set what version we have
|
||||||
changelog = "debian/changelog"
|
changelog = "debian/changelog"
|
||||||
if os.path.exists(changelog):
|
if os.path.exists(changelog):
|
||||||
head = codecs.open(changelog, 'r', 'utf-8', 'replace').readline()
|
head = open(changelog, 'r', encoding='utf-8').readline()
|
||||||
match = re.compile(r".*\((.*)\).*").match(head)
|
match = re.compile(r".*\((.*)\).*").match(head)
|
||||||
if match:
|
if match:
|
||||||
version = match.group(1)
|
version = match.group(1)
|
||||||
|
@ -27,13 +27,13 @@ import os
|
|||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
from subprocess import call, check_call, Popen, PIPE
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
|
|
||||||
from distro_info import UbuntuDistroInfo, DistroDataOutdated
|
from distro_info import UbuntuDistroInfo, DistroDataOutdated
|
||||||
|
|
||||||
from ubuntutools.config import ubu_email
|
from ubuntutools.config import ubu_email
|
||||||
from ubuntutools.question import YesNoQuestion, EditFile
|
from ubuntutools.question import YesNoQuestion, EditFile
|
||||||
from ubuntutools.subprocess import call, check_call, Popen, PIPE
|
|
||||||
from ubuntutools.update_maintainer import update_maintainer, restore_maintainer
|
from ubuntutools.update_maintainer import update_maintainer, restore_maintainer
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
11
syncpackage
11
syncpackage
@ -20,11 +20,11 @@
|
|||||||
#
|
#
|
||||||
# ##################################################################
|
# ##################################################################
|
||||||
|
|
||||||
import codecs
|
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
import urllib.request
|
import urllib.request
|
||||||
@ -44,13 +44,12 @@ from ubuntutools.requestsync.mail import (
|
|||||||
get_debian_srcpkg as requestsync_mail_get_debian_srcpkg)
|
get_debian_srcpkg as requestsync_mail_get_debian_srcpkg)
|
||||||
from ubuntutools.requestsync.lp import get_debian_srcpkg, get_ubuntu_srcpkg
|
from ubuntutools.requestsync.lp import get_debian_srcpkg, get_ubuntu_srcpkg
|
||||||
from ubuntutools.version import Version
|
from ubuntutools.version import Version
|
||||||
from ubuntutools import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
def remove_signature(dscname):
|
def remove_signature(dscname):
|
||||||
'''Removes the signature from a .dsc file if the .dsc file is signed.'''
|
'''Removes the signature from a .dsc file if the .dsc file is signed.'''
|
||||||
|
|
||||||
dsc_file = codecs.open(dscname, encoding='utf-8')
|
dsc_file = open(dscname, encoding='utf-8')
|
||||||
if dsc_file.readline().strip() == "-----BEGIN PGP SIGNED MESSAGE-----":
|
if dsc_file.readline().strip() == "-----BEGIN PGP SIGNED MESSAGE-----":
|
||||||
unsigned_file = []
|
unsigned_file = []
|
||||||
# search until begin of body found
|
# search until begin of body found
|
||||||
@ -65,7 +64,7 @@ def remove_signature(dscname):
|
|||||||
unsigned_file.append(line)
|
unsigned_file.append(line)
|
||||||
|
|
||||||
dsc_file.close()
|
dsc_file.close()
|
||||||
dsc_file = codecs.open(dscname, "w", encoding='utf-8')
|
dsc_file = open(dscname, "w", encoding='utf-8')
|
||||||
dsc_file.writelines(unsigned_file)
|
dsc_file.writelines(unsigned_file)
|
||||||
dsc_file.close()
|
dsc_file.close()
|
||||||
|
|
||||||
@ -169,7 +168,7 @@ def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror,
|
|||||||
|
|
||||||
# read Debian distribution from debian/changelog if not specified
|
# read Debian distribution from debian/changelog if not specified
|
||||||
if debian_dist is None:
|
if debian_dist is None:
|
||||||
line = codecs.open("debian/changelog", encoding='utf-8').readline()
|
line = open("debian/changelog", encoding='utf-8').readline()
|
||||||
debian_dist = line.split(" ")[2].strip(";")
|
debian_dist = line.split(" ")[2].strip(";")
|
||||||
|
|
||||||
if not fakesync:
|
if not fakesync:
|
||||||
@ -199,7 +198,7 @@ def sync_dsc(src_pkg, debian_dist, release, name, email, bugs, ubuntu_mirror,
|
|||||||
shutil.rmtree(directory, True)
|
shutil.rmtree(directory, True)
|
||||||
|
|
||||||
# write changes file
|
# write changes file
|
||||||
changes_file = codecs.open(changes_filename, "w", encoding='utf-8')
|
changes_file = open(changes_filename, "w", encoding='utf-8')
|
||||||
changes_file.writelines(changes)
|
changes_file.writelines(changes)
|
||||||
changes_file.close()
|
changes_file.close()
|
||||||
|
|
||||||
|
@ -21,10 +21,9 @@
|
|||||||
# ##################################################################
|
# ##################################################################
|
||||||
|
|
||||||
import optparse
|
import optparse
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ubuntutools import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
def extract(iso, path):
|
def extract(iso, path):
|
||||||
command = ['isoinfo', '-R', '-i', iso, '-x', path]
|
command = ['isoinfo', '-R', '-i', iso, '-x', path]
|
||||||
|
@ -35,6 +35,7 @@ import hashlib
|
|||||||
import json
|
import json
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from debian.changelog import Changelog, Version
|
from debian.changelog import Changelog, Version
|
||||||
@ -46,11 +47,6 @@ from ubuntutools.config import UDTConfig
|
|||||||
from ubuntutools.lp.lpapicache import (Launchpad, Distribution,
|
from ubuntutools.lp.lpapicache import (Launchpad, Distribution,
|
||||||
SourcePackagePublishingHistory)
|
SourcePackagePublishingHistory)
|
||||||
from ubuntutools.logger import Logger
|
from ubuntutools.logger import Logger
|
||||||
from ubuntutools import subprocess
|
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
basestring = str
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
class DownloadError(Exception):
|
class DownloadError(Exception):
|
||||||
@ -587,14 +583,14 @@ class FakeSPPH(object):
|
|||||||
if since_version is None:
|
if since_version is None:
|
||||||
return self._changelog
|
return self._changelog
|
||||||
|
|
||||||
if isinstance(since_version, basestring):
|
if isinstance(since_version, str):
|
||||||
since_version = Version(since_version)
|
since_version = Version(since_version)
|
||||||
|
|
||||||
new_entries = []
|
new_entries = []
|
||||||
for block in Changelog(self._changelog):
|
for block in Changelog(self._changelog):
|
||||||
if block.version <= since_version:
|
if block.version <= since_version:
|
||||||
break
|
break
|
||||||
new_entries.append(unicode(block))
|
new_entries.append(str(block))
|
||||||
return u''.join(new_entries)
|
return u''.join(new_entries)
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from ubuntutools.logger import Logger
|
from ubuntutools.logger import Logger
|
||||||
from ubuntutools import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
def _build_preparation(result_directory):
|
def _build_preparation(result_directory):
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
#
|
#
|
||||||
# Based on code written by Jonathan Davies <jpds@ubuntu.com>
|
# Based on code written by Jonathan Davies <jpds@ubuntu.com>
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
# Uncomment for tracing LP API calls
|
# Uncomment for tracing LP API calls
|
||||||
# import httplib2
|
# import httplib2
|
||||||
# httplib2.debuglevel = 1
|
# httplib2.debuglevel = 1
|
||||||
@ -44,27 +42,6 @@ from ubuntutools.lp.udtexceptions import (AlreadyLoggedInError,
|
|||||||
PocketDoesNotExistError,
|
PocketDoesNotExistError,
|
||||||
SeriesNotFoundException)
|
SeriesNotFoundException)
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
basestring = str
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
# Shameless steal from python-six
|
|
||||||
def add_metaclass(metaclass):
|
|
||||||
"""Class decorator for creating a class with a metaclass."""
|
|
||||||
def wrapper(cls):
|
|
||||||
orig_vars = cls.__dict__.copy()
|
|
||||||
slots = orig_vars.get('__slots__')
|
|
||||||
if slots is not None:
|
|
||||||
if isinstance(slots, str):
|
|
||||||
slots = [slots]
|
|
||||||
for slots_var in slots:
|
|
||||||
orig_vars.pop(slots_var)
|
|
||||||
orig_vars.pop('__dict__', None)
|
|
||||||
orig_vars.pop('__weakref__', None)
|
|
||||||
return metaclass(cls.__name__, cls.__bases__, orig_vars)
|
|
||||||
return wrapper
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'Archive',
|
'Archive',
|
||||||
@ -140,15 +117,14 @@ class MetaWrapper(type):
|
|||||||
cls._cache = dict()
|
cls._cache = dict()
|
||||||
|
|
||||||
|
|
||||||
@add_metaclass(MetaWrapper)
|
class BaseWrapper(object, metaclass=MetaWrapper):
|
||||||
class BaseWrapper(object):
|
|
||||||
'''
|
'''
|
||||||
A base class from which other wrapper classes are derived.
|
A base class from which other wrapper classes are derived.
|
||||||
'''
|
'''
|
||||||
resource_type = None # it's a base class after all
|
resource_type = None # it's a base class after all
|
||||||
|
|
||||||
def __new__(cls, data):
|
def __new__(cls, data):
|
||||||
if isinstance(data, basestring) and data.startswith(str(Launchpad._root_uri)):
|
if isinstance(data, str) and data.startswith(str(Launchpad._root_uri)):
|
||||||
# looks like a LP API URL
|
# looks like a LP API URL
|
||||||
# check if it's already cached
|
# check if it's already cached
|
||||||
cached = cls._cache.get(data)
|
cached = cls._cache.get(data)
|
||||||
@ -225,7 +201,7 @@ class Distribution(BaseWrapper):
|
|||||||
'''
|
'''
|
||||||
Fetch the distribution object identified by 'dist' from LP.
|
Fetch the distribution object identified by 'dist' from LP.
|
||||||
'''
|
'''
|
||||||
if not isinstance(dist, basestring):
|
if not isinstance(dist, str):
|
||||||
raise TypeError("Don't know what do with '%r'" % dist)
|
raise TypeError("Don't know what do with '%r'" % dist)
|
||||||
cached = cls._cache.get(dist)
|
cached = cls._cache.get(dist)
|
||||||
if not cached:
|
if not cached:
|
||||||
@ -385,7 +361,7 @@ class Archive(BaseWrapper):
|
|||||||
'''
|
'''
|
||||||
if pocket is None:
|
if pocket is None:
|
||||||
pockets = frozenset(('Proposed', 'Updates', 'Security', 'Release'))
|
pockets = frozenset(('Proposed', 'Updates', 'Security', 'Release'))
|
||||||
elif isinstance(pocket, basestring):
|
elif isinstance(pocket, str):
|
||||||
pockets = frozenset((pocket,))
|
pockets = frozenset((pocket,))
|
||||||
else:
|
else:
|
||||||
pockets = frozenset(pocket)
|
pockets = frozenset(pocket)
|
||||||
@ -593,14 +569,14 @@ class SourcePackagePublishingHistory(BaseWrapper):
|
|||||||
if since_version is None:
|
if since_version is None:
|
||||||
return self._changelog
|
return self._changelog
|
||||||
|
|
||||||
if isinstance(since_version, basestring):
|
if isinstance(since_version, str):
|
||||||
since_version = Version(since_version)
|
since_version = Version(since_version)
|
||||||
|
|
||||||
new_entries = []
|
new_entries = []
|
||||||
for block in Changelog(self._changelog):
|
for block in Changelog(self._changelog):
|
||||||
if block.version <= since_version:
|
if block.version <= since_version:
|
||||||
break
|
break
|
||||||
new_entries.append(unicode(block))
|
new_entries.append(str(block))
|
||||||
return u''.join(new_entries)
|
return u''.join(new_entries)
|
||||||
|
|
||||||
def getBinaries(self):
|
def getBinaries(self):
|
||||||
@ -719,8 +695,7 @@ class MetaPersonTeam(MetaWrapper):
|
|||||||
return cls._me
|
return cls._me
|
||||||
|
|
||||||
|
|
||||||
@add_metaclass(MetaPersonTeam)
|
class PersonTeam(BaseWrapper, metaclass=MetaPersonTeam):
|
||||||
class PersonTeam(BaseWrapper):
|
|
||||||
'''
|
'''
|
||||||
Wrapper class around a LP person or team object.
|
Wrapper class around a LP person or team object.
|
||||||
'''
|
'''
|
||||||
@ -743,7 +718,7 @@ class PersonTeam(BaseWrapper):
|
|||||||
'''
|
'''
|
||||||
Fetch the person or team object identified by 'url' from LP.
|
Fetch the person or team object identified by 'url' from LP.
|
||||||
'''
|
'''
|
||||||
if not isinstance(person_or_team, basestring):
|
if not isinstance(person_or_team, str):
|
||||||
raise TypeError("Don't know what do with '%r'" % person_or_team)
|
raise TypeError("Don't know what do with '%r'" % person_or_team)
|
||||||
cached = cls._cache.get(person_or_team)
|
cached = cls._cache.get(person_or_team)
|
||||||
if not cached:
|
if not cached:
|
||||||
@ -771,9 +746,9 @@ class PersonTeam(BaseWrapper):
|
|||||||
raise TypeError("'%r' is not an Archive object." % archive)
|
raise TypeError("'%r' is not an Archive object." % archive)
|
||||||
if not isinstance(distroseries, DistroSeries):
|
if not isinstance(distroseries, DistroSeries):
|
||||||
raise TypeError("'%r' is not a DistroSeries object." % distroseries)
|
raise TypeError("'%r' is not a DistroSeries object." % distroseries)
|
||||||
if package is not None and not isinstance(package, basestring):
|
if package is not None and not isinstance(package, str):
|
||||||
raise TypeError('A source package name expected.')
|
raise TypeError('A source package name expected.')
|
||||||
if component is not None and not isinstance(component, basestring):
|
if component is not None and not isinstance(component, str):
|
||||||
raise TypeError('A component name expected.')
|
raise TypeError('A component name expected.')
|
||||||
if package is None and component is None:
|
if package is None and component is None:
|
||||||
raise ValueError('Either a source package name or a component has '
|
raise ValueError('Either a source package name or a component has '
|
||||||
|
@ -22,9 +22,8 @@
|
|||||||
#
|
#
|
||||||
# ##################################################################
|
# ##################################################################
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
# Modules.
|
# Modules.
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -32,7 +31,6 @@ import sys
|
|||||||
import distro_info
|
import distro_info
|
||||||
|
|
||||||
from ubuntutools.lp.udtexceptions import PocketDoesNotExistError
|
from ubuntutools.lp.udtexceptions import PocketDoesNotExistError
|
||||||
from ubuntutools.subprocess import Popen, PIPE
|
|
||||||
|
|
||||||
_system_distribution_chain = []
|
_system_distribution_chain = []
|
||||||
|
|
||||||
|
@ -16,20 +16,12 @@
|
|||||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import codecs
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import ubuntutools.subprocess
|
|
||||||
|
|
||||||
if sys.version_info[0] < 3:
|
|
||||||
input = raw_input # noqa, pylint: disable=undefined-variable
|
|
||||||
open = codecs.open
|
|
||||||
|
|
||||||
|
|
||||||
class Question(object):
|
class Question(object):
|
||||||
def __init__(self, options, show_help=True):
|
def __init__(self, options, show_help=True):
|
||||||
@ -143,8 +135,7 @@ class EditFile(object):
|
|||||||
done = False
|
done = False
|
||||||
while not done:
|
while not done:
|
||||||
old_mtime = os.stat(self.filename).st_mtime
|
old_mtime = os.stat(self.filename).st_mtime
|
||||||
ubuntutools.subprocess.check_call(['sensible-editor',
|
subprocess.check_call(['sensible-editor', self.filename])
|
||||||
self.filename])
|
|
||||||
modified = old_mtime != os.stat(self.filename).st_mtime
|
modified = old_mtime != os.stat(self.filename).st_mtime
|
||||||
placeholders_present = False
|
placeholders_present = False
|
||||||
if self.placeholders:
|
if self.placeholders:
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
# 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 __future__ import print_function
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from debian.deb822 import Changes
|
from debian.deb822 import Changes
|
||||||
|
@ -20,13 +20,12 @@
|
|||||||
# 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 __future__ import print_function
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import smtplib
|
import smtplib
|
||||||
import socket
|
import socket
|
||||||
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from debian.changelog import Changelog, Version
|
from debian.changelog import Changelog, Version
|
||||||
@ -36,11 +35,6 @@ from ubuntutools.archive import rmadison, FakeSPPH
|
|||||||
from ubuntutools.lp.udtexceptions import PackageNotFoundException
|
from ubuntutools.lp.udtexceptions import PackageNotFoundException
|
||||||
from ubuntutools.logger import Logger
|
from ubuntutools.logger import Logger
|
||||||
from ubuntutools.question import confirmation_prompt, YesNoQuestion
|
from ubuntutools.question import confirmation_prompt, YesNoQuestion
|
||||||
from ubuntutools import subprocess
|
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
basestring = str
|
|
||||||
unicode = str
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
@ -117,7 +111,7 @@ def get_ubuntu_delta_changelog(srcpkg):
|
|||||||
distribution = block.distributions.split()[0].split('-')[0]
|
distribution = block.distributions.split()[0].split('-')[0]
|
||||||
if debian_info.valid(distribution):
|
if debian_info.valid(distribution):
|
||||||
break
|
break
|
||||||
delta += [unicode(change) for change in block.changes()
|
delta += [str(change) for change in block.changes()
|
||||||
if change.strip()]
|
if change.strip()]
|
||||||
|
|
||||||
return u'\n'.join(delta)
|
return u'\n'.join(delta)
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from ubuntutools import subprocess
|
|
||||||
from ubuntutools.logger import Logger
|
from ubuntutools.logger import Logger
|
||||||
from ubuntutools.sponsor_patch.question import ask_for_manual_fixing
|
from ubuntutools.sponsor_patch.question import ask_for_manual_fixing
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ubuntutools.question import Question, YesNoQuestion
|
from ubuntutools.question import Question, YesNoQuestion
|
||||||
|
@ -15,16 +15,14 @@
|
|||||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import debian.changelog
|
import debian.changelog
|
||||||
import debian.deb822
|
import debian.deb822
|
||||||
|
|
||||||
from ubuntutools import subprocess
|
|
||||||
from ubuntutools.logger import Logger
|
from ubuntutools.logger import Logger
|
||||||
from ubuntutools.question import Question, YesNoQuestion
|
from ubuntutools.question import Question, YesNoQuestion
|
||||||
|
|
||||||
|
@ -15,18 +15,16 @@
|
|||||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from distro_info import UbuntuDistroInfo
|
from distro_info import UbuntuDistroInfo
|
||||||
|
|
||||||
from launchpadlib.launchpad import Launchpad
|
from launchpadlib.launchpad import Launchpad
|
||||||
|
|
||||||
from ubuntutools import subprocess
|
|
||||||
from ubuntutools.logger import Logger
|
from ubuntutools.logger import Logger
|
||||||
from ubuntutools.update_maintainer import (update_maintainer,
|
from ubuntutools.update_maintainer import (update_maintainer,
|
||||||
MaintainerUpdateException)
|
MaintainerUpdateException)
|
||||||
@ -37,9 +35,6 @@ from ubuntutools.sponsor_patch.patch import Patch
|
|||||||
from ubuntutools.sponsor_patch.question import ask_for_manual_fixing
|
from ubuntutools.sponsor_patch.question import ask_for_manual_fixing
|
||||||
from ubuntutools.sponsor_patch.source_package import SourcePackage
|
from ubuntutools.sponsor_patch.source_package import SourcePackage
|
||||||
|
|
||||||
if sys.version_info[0] < 3:
|
|
||||||
range = xrange # noqa, pylint: disable=redefined-builtin,undefined-variable
|
|
||||||
|
|
||||||
|
|
||||||
def is_command_available(command, check_sbin=False):
|
def is_command_available(command, check_sbin=False):
|
||||||
"Is command in $PATH?"
|
"Is command in $PATH?"
|
||||||
|
@ -1,126 +0,0 @@
|
|||||||
"""Drop-in replacement for subprocess with better defaults
|
|
||||||
|
|
||||||
This is an API-compatible replacement for the built-in subprocess
|
|
||||||
module whose defaults better line up with our tastes.
|
|
||||||
|
|
||||||
In particular, it:
|
|
||||||
- Adds support for the restore_signals flag if subprocess itself
|
|
||||||
doesn't support it
|
|
||||||
- Adds support for the encoding flag if subprocess itself doesn't
|
|
||||||
support it
|
|
||||||
- Defaults close_fds to True
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
|
|
||||||
import inspect
|
|
||||||
import codecs
|
|
||||||
import signal
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from subprocess import PIPE, STDOUT, CalledProcessError
|
|
||||||
|
|
||||||
__all__ = ['Popen', 'call', 'check_call', 'check_output', 'CalledProcessError',
|
|
||||||
'PIPE', 'STDOUT']
|
|
||||||
|
|
||||||
|
|
||||||
class Popen(subprocess.Popen):
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
kwargs.setdefault('close_fds', True)
|
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
getargs = inspect.getfullargspec
|
|
||||||
encoding = None
|
|
||||||
else:
|
|
||||||
getargs = inspect.getargspec
|
|
||||||
encoding = kwargs.pop('encoding', None)
|
|
||||||
|
|
||||||
if 'restore_signals' not in getargs(subprocess.Popen.__init__)[0]:
|
|
||||||
given_preexec_fn = kwargs.pop('preexec_fn', None)
|
|
||||||
restore_signals = kwargs.pop('restore_signals', True)
|
|
||||||
|
|
||||||
def preexec_fn():
|
|
||||||
if restore_signals:
|
|
||||||
for sig in ('SIGPIPE', 'SIGXFZ', 'SIGXFSZ'):
|
|
||||||
if hasattr(signal, sig):
|
|
||||||
signal.signal(getattr(signal, sig),
|
|
||||||
signal.SIG_DFL)
|
|
||||||
|
|
||||||
if given_preexec_fn:
|
|
||||||
given_preexec_fn()
|
|
||||||
kwargs['preexec_fn'] = preexec_fn
|
|
||||||
|
|
||||||
subprocess.Popen.__init__(self, *args, **kwargs)
|
|
||||||
if encoding is not None:
|
|
||||||
for channel in ('stdin', 'stdout', 'stderr'):
|
|
||||||
fd = getattr(self, channel)
|
|
||||||
if fd is not None:
|
|
||||||
setattr(self, channel, codecs.EncodedFile(fd, encoding))
|
|
||||||
|
|
||||||
|
|
||||||
# call, check_call, and check_output are copied directly from the
|
|
||||||
# subprocess module shipped with Python 2.7.1-5ubuntu2
|
|
||||||
|
|
||||||
|
|
||||||
def call(*popenargs, **kwargs):
|
|
||||||
"""Run command with arguments. Wait for command to complete, then
|
|
||||||
return the returncode attribute.
|
|
||||||
|
|
||||||
The arguments are the same as for the Popen constructor. Example:
|
|
||||||
|
|
||||||
retcode = call(["ls", "-l"])
|
|
||||||
"""
|
|
||||||
return Popen(*popenargs, **kwargs).wait()
|
|
||||||
|
|
||||||
|
|
||||||
def check_call(*popenargs, **kwargs):
|
|
||||||
"""Run command with arguments. Wait for command to complete. If
|
|
||||||
the exit code was zero then return, otherwise raise
|
|
||||||
CalledProcessError. The CalledProcessError object will have the
|
|
||||||
return code in the returncode attribute.
|
|
||||||
|
|
||||||
The arguments are the same as for the Popen constructor. Example:
|
|
||||||
|
|
||||||
check_call(["ls", "-l"])
|
|
||||||
"""
|
|
||||||
retcode = call(*popenargs, **kwargs)
|
|
||||||
if retcode:
|
|
||||||
cmd = kwargs.get("args")
|
|
||||||
if cmd is None:
|
|
||||||
cmd = popenargs[0]
|
|
||||||
raise CalledProcessError(retcode, cmd)
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def check_output(*popenargs, **kwargs):
|
|
||||||
r"""Run command with arguments and return its output as a byte string.
|
|
||||||
|
|
||||||
If the exit code was non-zero it raises a CalledProcessError. The
|
|
||||||
CalledProcessError object will have the return code in the returncode
|
|
||||||
attribute and output in the output attribute.
|
|
||||||
|
|
||||||
The arguments are the same as for the Popen constructor. Example:
|
|
||||||
|
|
||||||
>>> check_output(["ls", "-l", "/dev/null"])
|
|
||||||
'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
|
|
||||||
|
|
||||||
The stdout argument is not allowed as it is used internally.
|
|
||||||
To capture standard error in the result, use stderr=STDOUT.
|
|
||||||
|
|
||||||
>>> check_output(["/bin/sh", "-c",
|
|
||||||
... "ls -l non_existent_file ; exit 0"],
|
|
||||||
... stderr=STDOUT)
|
|
||||||
'ls: non_existent_file: No such file or directory\n'
|
|
||||||
"""
|
|
||||||
if 'stdout' in kwargs:
|
|
||||||
raise ValueError('stdout argument not allowed, it will be overridden.')
|
|
||||||
process = Popen(stdout=PIPE, *popenargs, **kwargs)
|
|
||||||
output, unused_err = process.communicate()
|
|
||||||
retcode = process.poll()
|
|
||||||
if retcode:
|
|
||||||
cmd = kwargs.get("args")
|
|
||||||
if cmd is None:
|
|
||||||
cmd = popenargs[0]
|
|
||||||
raise CalledProcessError(retcode, cmd, output=output)
|
|
||||||
return output
|
|
@ -21,10 +21,7 @@ import sys
|
|||||||
|
|
||||||
import setup
|
import setup
|
||||||
|
|
||||||
if sys.version_info < (2, 7):
|
import unittest
|
||||||
import unittest2 as unittest
|
|
||||||
else:
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
|
|
||||||
def discover():
|
def discover():
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
|
||||||
import tempfile
|
import tempfile
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
try:
|
try:
|
||||||
@ -64,18 +63,11 @@ class DscVerificationTestCase(unittest.TestCase):
|
|||||||
fn = 'test-data/example_1.0.orig.tar.gz'
|
fn = 'test-data/example_1.0.orig.tar.gz'
|
||||||
with open(fn, 'rb') as f:
|
with open(fn, 'rb') as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
last_byte = chr(data[-1] ^ 8).encode()
|
last_byte = chr(data[-1] ^ 8).encode()
|
||||||
else:
|
|
||||||
last_byte = chr(ord(data[-1]) ^ 8)
|
|
||||||
data = data[:-1] + last_byte
|
data = data[:-1] + last_byte
|
||||||
m = mock.MagicMock(name='open', spec=open)
|
m = mock.MagicMock(name='open', spec=open)
|
||||||
m.return_value = BytesIO(data)
|
m.return_value = BytesIO(data)
|
||||||
if sys.version_info[0] >= 3:
|
with mock.patch('builtins.open', m):
|
||||||
target = 'builtins.open'
|
|
||||||
else:
|
|
||||||
target = '__builtin__.open'
|
|
||||||
with mock.patch(target, m):
|
|
||||||
self.assertFalse(self.dsc.verify_file(fn))
|
self.assertFalse(self.dsc.verify_file(fn))
|
||||||
|
|
||||||
def test_sha1(self):
|
def test_sha1(self):
|
||||||
|
@ -49,15 +49,9 @@ class ConfigTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ConfigTestCase, self).setUp()
|
super(ConfigTestCase, self).setUp()
|
||||||
if sys.version_info[0] < 3:
|
|
||||||
self.assertRegex = self.assertRegexpMatches
|
|
||||||
m = mock.mock_open()
|
m = mock.mock_open()
|
||||||
m.side_effect = self._fake_open
|
m.side_effect = self._fake_open
|
||||||
if sys.version_info[0] >= 3:
|
patcher = mock.patch('builtins.open', m)
|
||||||
target = 'builtins.open'
|
|
||||||
else:
|
|
||||||
target = '__builtin__.open'
|
|
||||||
patcher = mock.patch(target, m)
|
|
||||||
self.addCleanup(patcher.stop)
|
self.addCleanup(patcher.stop)
|
||||||
patcher.start()
|
patcher.start()
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
"""test_flake8.py - Run flake8 check"""
|
"""test_flake8.py - Run flake8 check"""
|
||||||
|
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ubuntutools import subprocess
|
|
||||||
from ubuntutools.test import get_source_files, unittest, unittest_verbosity
|
from ubuntutools.test import get_source_files, unittest, unittest_verbosity
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,10 +18,10 @@ import fcntl
|
|||||||
import os
|
import os
|
||||||
import select
|
import select
|
||||||
import signal
|
import signal
|
||||||
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import setup
|
import setup
|
||||||
from ubuntutools import subprocess
|
|
||||||
from ubuntutools.test import unittest
|
from ubuntutools.test import unittest
|
||||||
|
|
||||||
TIMEOUT = 10
|
TIMEOUT = 10
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ubuntutools.test import get_source_files, unittest, unittest_verbosity
|
from ubuntutools.test import get_source_files, unittest, unittest_verbosity
|
||||||
from ubuntutools import subprocess
|
|
||||||
|
|
||||||
CONFIG = os.path.join(os.path.dirname(__file__), "pylint.conf")
|
CONFIG = os.path.join(os.path.dirname(__file__), "pylint.conf")
|
||||||
|
|
||||||
|
@ -231,15 +231,9 @@ class UpdateMaintainerTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
# pylint: disable=C0103
|
# pylint: disable=C0103
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if sys.version_info[0] < 3:
|
|
||||||
self.assertRegex = self.assertRegexpMatches
|
|
||||||
m = mock.mock_open()
|
m = mock.mock_open()
|
||||||
m.side_effect = self._fake_open
|
m.side_effect = self._fake_open
|
||||||
if sys.version_info[0] >= 3:
|
patcher = mock.patch('builtins.open', m)
|
||||||
target = 'builtins.open'
|
|
||||||
else:
|
|
||||||
target = '__builtin__.open'
|
|
||||||
patcher = mock.patch(target, m)
|
|
||||||
self.addCleanup(patcher.stop)
|
self.addCleanup(patcher.stop)
|
||||||
patcher.start()
|
patcher.start()
|
||||||
m = mock.MagicMock(side_effect=self._fake_isfile)
|
m = mock.MagicMock(side_effect=self._fake_isfile)
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
"""This module is for updating the Maintainer field of an Ubuntu package."""
|
"""This module is for updating the Maintainer field of an Ubuntu package."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
Loading…
x
Reference in New Issue
Block a user