1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00

Always import at the toplevel

This commit is contained in:
Daniel Mach 2022-09-09 11:46:28 +02:00
parent 6d891d7488
commit b511be20ff
30 changed files with 68 additions and 152 deletions

View File

@ -3,6 +3,7 @@
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version.
import glob
import os
import re
import shutil
@ -22,7 +23,9 @@ from .core import get_buildinfo, store_read_project, store_read_package, meta_ex
from .core import get_binarylist, get_binary_file, run_external, return_external, raw_input
from .fetch import Fetcher, OscFileGrabber, verify_pacs
from .meter import create_text_meter
from .util import rpmquery, debquery, archquery
from .util import cpio
from .util import archquery, debquery, packagequery, rpmquery
from .util import repodata
from .util.helper import decode_it
@ -466,8 +469,6 @@ def get_repo(path):
return repositoryDirectory
def get_prefer_pkgs(dirs, wanted_arch, type, cpio):
import glob
from .util import repodata, packagequery
paths = []
repositories = []
@ -888,13 +889,11 @@ def main(apiurl, opts, argv):
else:
print('Using local buildenv file: %s' % os.path.basename(buildenvfile))
if buildenvfile or servicefile:
from .util import cpio
if not cpiodata:
cpiodata = cpio.CpioWrite()
if opts.prefer_pkgs:
print('Scanning the following dirs for local packages: %s' % ', '.join(opts.prefer_pkgs))
from .util import cpio
if not cpiodata:
cpiodata = cpio.CpioWrite()
prefer_pkgs = get_prefer_pkgs(opts.prefer_pkgs, arch, build_type, cpiodata)
@ -1329,7 +1328,6 @@ def main(apiurl, opts, argv):
if i.hdrmd5:
if not i.name.startswith('container:') and i.pacsuffix != 'rpm':
continue
from .util import packagequery
if i.name.startswith('container:'):
hdrmd5 = dgst(i.fullfilename)
else:

View File

@ -4,22 +4,32 @@
# either version 2, or version 3 (at your option).
import argparse
import getpass
import glob
import importlib.util
import inspect
import os
import re
import subprocess
import sys
import textwrap
import tempfile
import time
import traceback
from functools import cmp_to_key
from operator import itemgetter
from optparse import SUPPRESS_HELP
from urllib.parse import urlsplit
from urllib.error import HTTPError
from . import build as osc_build
from . import cmdln
from . import conf
from . import oscerr
from .core import *
from .util import safewriter
from .grabber import OscFileGrabber
from .meter import create_text_meter
from .util import cpio, rpmquery, safewriter
from .util.helper import _html_escape, format_table
@ -188,7 +198,6 @@ class Osc(cmdln.Cmdln):
self.options.verbose = conf.config['verbose']
self.download_progress = None
if conf.config.get('show_download_progress', False):
from .meter import create_text_meter
self.download_progress = create_text_meter()
def get_api_url(self):
@ -2079,7 +2088,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
repository = opts.repository
if not opts.message:
import textwrap
if package is not None:
footer = textwrap.TextWrapper(width = 66).fill(
'please explain why you like to delete package %s of project %s'
@ -2132,7 +2140,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
devel_package = args[3]
if not opts.message:
import textwrap
footer = textwrap.TextWrapper(width = 66).fill(
'please explain why you like to change the devel project of %s/%s to %s/%s'
% (project, package, devel_project, devel_package))
@ -4353,8 +4360,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
usage:
osc repourls [PROJECT]
"""
import tempfile
def _repo_type(apiurl, project, repo):
if not os.path.exists('/usr/lib/build/queryconfig'):
return None
@ -5480,8 +5485,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
buildlog [REPOSITORY ARCH | BUILDLOGURL]
"""
import osc.build
project = package = repository = arch = None
apiurl = self.get_api_url()
@ -5497,7 +5500,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# no local build with this repo was done
print('failed to guess arch, using hostarch')
repository = args[0]
arch = osc.build.hostarch
arch = osc_build.hostarch
elif len(args) < 2:
self.print_repos()
elif len(args) > 2:
@ -5627,7 +5630,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print_buildlog(apiurl, quote_plus(project), quote_plus(package), quote_plus(repository), quote_plus(arch), offset, strip_time, opts.last, opts.lastsucceeded)
def _find_last_repo_arch(self, repo=None, fatal=True):
import glob
files = glob.glob(os.path.join(os.getcwd(), store, "_buildinfo-*"))
if repo is not None:
files = [f for f in files
@ -5930,11 +5932,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if opts.prefer_pkgs and build_descr_data is None:
raise oscerr.WrongArgs('error: a build description is needed if \'--prefer-pkgs\' is used')
elif opts.prefer_pkgs:
from .build import get_prefer_pkgs
from .util import cpio
print('Scanning the following dirs for local packages: %s' % ', '.join(opts.prefer_pkgs))
cpiodata = cpio.CpioWrite()
prefer_pkgs = get_prefer_pkgs(opts.prefer_pkgs, arch,
prefer_pkgs = osc_build.get_prefer_pkgs(opts.prefer_pkgs, arch,
os.path.splitext(build_descr)[1],
cpiodata)
cpiodata.add(os.path.basename(build_descr.encode()), build_descr_data)
@ -6132,16 +6132,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
def parse_repoarchdescr(self, args, noinit = False, alternative_project = None, ignore_descr = False, vm_type = None, multibuild_package = None):
"""helper to parse the repo, arch and build description from args"""
import osc.build
import glob
import tempfile
arg_arch = arg_repository = arg_descr = None
if len(args) < 3:
# some magic, works only sometimes, but people seem to like it :/
all_archs = []
for mainarch in osc.build.can_also_build:
for mainarch in osc_build.can_also_build:
all_archs.append(mainarch)
for subarch in osc.build.can_also_build.get(mainarch):
for subarch in osc_build.can_also_build.get(mainarch):
all_archs.append(subarch)
for arg in args:
if (arg.endswith('.spec') or arg.endswith('.dsc') or
@ -6152,10 +6149,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
'fissile.yml', 'appimage.yml', '_preinstallimage')):
arg_descr = arg
else:
if (arg == osc.build.hostarch or arg in all_archs) and arg_arch is None:
if (arg == osc_build.hostarch or arg in all_archs) and arg_arch is None:
# it seems to be an architecture in general
arg_arch = arg
if not (arg == osc.build.hostarch or arg in osc.build.can_also_build.get(osc.build.hostarch, [])):
if not (arg == osc_build.hostarch or arg in osc_build.can_also_build.get(osc_build.hostarch, [])):
if not (vm_type == 'qemu' or vm_type == 'emulator'):
print("WARNING: native compile is not possible, a emulator via binfmt misc handler must be configured!")
elif not arg_repository:
@ -6168,15 +6165,15 @@ Please submit there instead, or use --nodevelproject to force direct submission.
else:
arg_repository, arg_arch, arg_descr = args
arg_arch = arg_arch or osc.build.hostarch
self._debug("hostarch: ", osc.build.hostarch)
arg_arch = arg_arch or osc_build.hostarch
self._debug("hostarch: ", osc_build.hostarch)
self._debug("arg_arch: ", arg_arch)
self._debug("arg_repository: ", arg_repository)
self._debug("arg_descr: ", arg_descr)
repositories = []
# store list of repos for potential offline use
repolistfile = os.path.join(os.getcwd(), osc.core.store, "_build_repositories")
repolistfile = os.path.join(os.getcwd(), store, "_build_repositories")
if noinit:
repositories = Repo.fromfile(repolistfile)
else:
@ -6239,7 +6236,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if noinit:
bc_filename = '_buildconfig-%s-%s' % (arg_repository, arg_arch)
if is_package_dir('.'):
bc_filename = os.path.join(os.getcwd(), osc.core.store, bc_filename)
bc_filename = os.path.join(os.getcwd(), store, bc_filename)
else:
bc_filename = os.path.abspath(bc_filename)
if not os.path.isfile(bc_filename):
@ -6475,9 +6472,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# OSC_BUILD_ROOT overrides the setting of build-root.
# OSC_PACKAGECACHEDIR overrides the setting of packagecachedir.
"""
import osc.build
if which(conf.config['build-cmd']) is None:
print('Error: build (\'%s\') command not found' % conf.config['build-cmd'], file=sys.stderr)
print('Install the build package from http://download.opensuse.org/repositories/openSUSE:/Tools/', file=sys.stderr)
@ -6519,9 +6513,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
else:
args = self.parse_repoarchdescr(args, opts.noinit or opts.offline, opts.alternative_project, False, opts.vm_type, opts.multibuild_package)
repo, arch, build_descr = args
prj, pac = osc.build.calculate_prj_pac(opts, build_descr)
prj, pac = osc_build.calculate_prj_pac(opts, build_descr)
apihost = urlsplit(self.get_api_url())[1]
build_root = osc.build.calculate_build_root(apihost, prj, pac, repo,
build_root = osc_build.calculate_build_root(apihost, prj, pac, repo,
arch)
if opts.wipe and not opts.force:
# Confirm delete
@ -6533,7 +6527,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
build_args = ['--root=' + build_root, '--noinit', '--shell']
if opts.wipe:
build_args.append('--wipe')
sys.exit(osc.build.run_build(opts, *build_args))
sys.exit(osc_build.run_build(opts, *build_args))
elif subcmd in ('shell', 'chroot') or opts.shell:
print('--shell in combination with build-type %s is experimental.' % vm_chroot)
print('The semantics may change at any time!')
@ -6577,7 +6571,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print('Building %s for %s/%s' % (args[2], args[0], args[1]))
if not opts.host:
return osc.build.main(self.get_api_url(), opts, args)
return osc_build.main(self.get_api_url(), opts, args)
else:
return self._do_rbuild(subcmd, opts, *args)
@ -7902,9 +7896,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
SRPM is the path of the src.rpm in the local filesystem,
or an URL.
"""
import glob
from .util import rpmquery
if opts.delete_old_files and conf.config['do_package_tracking']:
# IMHO the --delete-old-files option doesn't really fit into our
# package tracking strategy
@ -7917,7 +7908,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print('%s is not a valid link. It must not end with /' % srpm)
sys.exit(1)
print('trying to fetch', srpm)
from .grabber import OscFileGrabber
OscFileGrabber().urlgrab(srpm)
srpm = os.path.basename(srpm)
@ -8922,8 +8912,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
or can be specified via mailaddr environment variable.
"""
from subprocess import Popen
if opts.message and opts.file:
raise oscerr.WrongOptions('\'--message\' and \'--file\' are mutually exclusive')
elif opts.message and opts.just_edit:
@ -8932,7 +8920,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongOptions('\'--file\' and \'--just-edit\' are mutually exclusive')
meego_style = False
if not args:
import glob, re
try:
fn_changelog = glob.glob('*.changes')[0]
fp = open(fn_changelog)
@ -8982,7 +8969,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
cmd_list.extend(args)
vc_export_env(apiurl)
vc = Popen(cmd_list)
vc = subprocess.Popen(cmd_list)
vc.wait()
sys.exit(vc.returncode)
@ -9088,7 +9075,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongArgs('error: read empty value from stdin')
elif opts.no_echo or opts.prompt:
if opts.no_echo:
import getpass
inp = getpass.getpass(prompt_value).strip()
else:
inp = raw_input(prompt_value).strip()
@ -9330,7 +9316,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if os.environ.get('OSC_PLUGIN_FAIL_IGNORE'):
print("%s: %s\n" % (os.path.join(plugin_dir, extfile), e), file=sys.stderr)
else:
import traceback
traceback.print_exc(file=sys.stderr)
print('\n%s: %s' % (os.path.join(plugin_dir, extfile), e), file=sys.stderr)
print("\n Try 'env OSC_PLUGIN_FAIL_IGNORE=1 osc ...'", file=sys.stderr)

View File

@ -36,7 +36,6 @@ The configuration dictionary could look like this:
"""
import bz2
import errno
import getpass
import os

View File

@ -97,9 +97,6 @@ def get_proxy_manager(env):
else:
proxy_url = f"{proxy_purl.scheme}://{proxy_purl.host}"
# import osc.core here to avoid cyclic imports
from . import core
proxy_headers = urllib3.make_headers(
proxy_basic_auth=proxy_purl.auth,
user_agent=f"osc/{__version__}",
@ -167,9 +164,6 @@ def http_request(method, url, headers=None, data=None, file=None):
:param file: Path to a file to send as data in the request body (conflicts with `data`).
"""
# import osc.core here to avoid cyclic imports
from . import core
purl = urllib3.util.parse_url(url)
apiurl = conf.extract_known_apiurl(url)
headers = urllib3.response.HTTPHeaderDict(headers or {})

View File

@ -10,7 +10,12 @@
__store_version__ = '1.0'
import codecs
import datetime
import difflib
import errno
import fnmatch
import glob
import hashlib
import locale
import os
@ -20,6 +25,8 @@ import shlex
import shutil
import subprocess
import sys
import tempfile
import textwrap
import time
from functools import cmp_to_key
from http.client import IncompleteRead
@ -36,6 +43,7 @@ except ImportError:
from . import __version__
from . import conf
from . import meter
from . import oscerr
from .connection import http_request, http_GET, http_POST, http_PUT, http_DELETE
from .util.helper import decode_list, decode_it, raw_input, _html_escape
@ -315,8 +323,6 @@ class Serviceinfo:
raise e
def addVerifyFile(self, serviceinfo_node, filename):
import hashlib
f = open(filename, 'rb')
digest = hashlib.sha256(f.read()).hexdigest()
f.close()
@ -396,8 +402,6 @@ class Serviceinfo:
def _execute(self, dir, old_dir, callmode=None, singleservice=None,
verbose=None):
import tempfile
# cleanup existing generated files
for filename in os.listdir(dir):
if filename.startswith('_service:') or filename.startswith('_service_'):
@ -651,7 +655,6 @@ class Project:
`wc_check` : bool
"""
import fnmatch
self.dir = dir
self.absdir = os.path.abspath(dir)
self.progress_obj = progress_obj
@ -839,7 +842,6 @@ class Project:
store_write_string(self.absdir, '_packages', ET.tostring(self.pac_root, encoding=ET_ENCODING))
def addPackage(self, pac):
import fnmatch
for i in conf.config['exclude_glob']:
if fnmatch.fnmatch(pac, i):
msg = 'invalid package name: \'%s\' (see \'exclude_glob\' config option)' % pac
@ -1759,7 +1761,6 @@ class Package:
file has changed (e.g. update_local_filesmeta() has been
called).
"""
import fnmatch
if self.scm_url:
self.filenamelist = []
self.filelist = []
@ -1984,7 +1985,6 @@ class Package:
return state
def get_diff(self, revision=None, ignoreUnversioned=False):
import tempfile
diff_hdr = b'Index: %s\n'
diff_hdr += b'===================================================================\n'
kept = []
@ -2127,7 +2127,6 @@ rev: %s
def read_meta_from_spec(self, spec = None):
import glob
if spec:
specfile = spec
else:
@ -2303,7 +2302,6 @@ rev: %s
return sinfo.get('srcmd5') != self.srcmd5
def update(self, rev = None, service_files = False, size_limit = None):
import tempfile
rfiles = []
# size_limit is only temporary for this update
old_size_limit = self.size_limit
@ -2893,8 +2891,6 @@ class Request:
def accept_at_in_hours(self, hours):
"""set auto accept_at time"""
import datetime
now = datetime.datetime.utcnow()
now = now + datetime.timedelta(hours=hours)
self.accept_at = now.isoformat() + '+00:00'
@ -3005,7 +3001,6 @@ class Request:
def list_view(self):
"""return "list view" format"""
import textwrap
status = self.state.name
if self.state.name == 'review' and self.state.approver:
status += "(approved)"
@ -3103,8 +3098,6 @@ def shorttime(t):
or Apr 02 2005
depending on whether it is in the current year
"""
import time
if time.gmtime()[0] == time.gmtime(t)[0]:
# same year
return time.strftime('%b %d %H:%M', time.gmtime(t))
@ -3647,8 +3640,6 @@ class metafile:
return self._delegate(**kwargs)
def __init__(self, url, input, change_is_required=False, file_ext='.xml'):
import tempfile
if isinstance(url, self._URLFactory):
self._url_factory = url
else:
@ -3976,7 +3967,6 @@ def show_upstream_rev(apiurl, prj, pac, revision=None, expand=False, linkrev=Non
def read_meta_from_spec(specfile, *args):
import codecs, re
"""
Read tags and sections from spec file. To read out
a tag the passed argument mustn't end with a colon. To
@ -4053,8 +4043,6 @@ def get_default_pager():
return 'more'
def run_pager(message, tmp_suffix=''):
import tempfile, sys
if not message:
return
@ -4091,8 +4079,6 @@ def _editor_command():
return cmd
def _edit_message_open_editor(filename, data, orig_mtime):
# FIXME: import modules globally
import tempfile
editor = _editor_command()
mtime = os.stat(filename).st_mtime
if isinstance(data, str):
@ -4127,7 +4113,6 @@ def edit_message(footer='', template='', templatelen=30):
return edit_text(data, delim, suffix='.diff', template=template)
def edit_text(data='', delim=None, suffix='.txt', template=''):
import tempfile
try:
(fd, filename) = tempfile.mkstemp(prefix='osc-editor', suffix=suffix)
os.close(fd)
@ -4639,7 +4624,6 @@ def get_group_data(apiurl, group, *tags):
def download(url, filename, progress_obj = None, mtime = None):
import tempfile, shutil
global BUFSIZE
o = None
@ -4685,8 +4669,7 @@ def get_binary_file(apiurl, prj, repo, arch,
progress_meter = False):
progress_obj = None
if progress_meter:
from .meter import create_text_meter
progress_obj = create_text_meter()
progress_obj = meter.create_text_meter()
target_filename = target_filename or filename
@ -4711,14 +4694,7 @@ def dgst(file):
#return None
global BUFSIZE
try:
import hashlib
md5 = hashlib
except ImportError:
import md5
md5 = md5
s = md5.md5()
s = hashlib.md5()
f = open(file, 'rb')
while True:
buf = f.read(BUFSIZE)
@ -4760,9 +4736,6 @@ def get_source_file_diff(dir, filename, rev, oldfilename = None, olddir = None,
The variable origfilename is used if filename and oldfilename differ
in their names (for instance if a tempfile is used for filename etc.)
"""
import difflib
global store
if not oldfilename:
@ -5523,7 +5496,6 @@ def copy_pac(src_apiurl, src_project, src_package,
else:
# copy one file after the other
import tempfile
query = {'rev': 'upload'}
xml = show_files_meta(src_apiurl, src_project, src_package,
expand=expand, revision=revision)
@ -6187,7 +6159,6 @@ def print_buildlog(apiurl, prj, package, repository, arch, offset=0, strip_time=
sys.stdout.write(decode_it(data.translate(all_bytes, remove_bytes)))
# to protect us against control characters
import string
all_bytes = bytes.maketrans(b'', b'')
remove_bytes = all_bytes[:8] + all_bytes[14:32] # accept tabs and newlines
@ -6306,7 +6277,6 @@ def get_source_rev(apiurl, project, package, revision=None):
return e
def get_buildhistory(apiurl, prj, package, repository, arch, format = 'text', limit = None):
import time
query = {}
if limit is not None and int(limit) > 0:
query['limit'] = int(limit)
@ -6338,7 +6308,6 @@ def get_buildhistory(apiurl, prj, package, repository, arch, format = 'text', li
return r
def print_jobhistory(apiurl, prj, current_package, repository, arch, format = 'text', limit=20):
import time
query = {}
if current_package:
query['package'] = current_package
@ -6375,8 +6344,6 @@ def print_jobhistory(apiurl, prj, current_package, repository, arch, format = 't
def get_commitlog(apiurl, prj, package, revision, format = 'text', meta = False, deleted = False, revision_upper=None):
import time
query = {}
if deleted:
query['deleted'] = 1
@ -7443,8 +7410,6 @@ def print_request_list(apiurl, project, package = None, states = ('new', 'review
def request_interactive_review(apiurl, request, initial_cmd='', group=None,
ignore_reviews=False, source_buildstatus=False):
"""review the request interactively"""
import tempfile, re
tmpfile = None
def safe_change_request_state(*args, **kwargs):
@ -7688,7 +7653,6 @@ def request_interactive_review(apiurl, request, initial_cmd='', group=None,
def edit_submitrequest(apiurl, project, orequest, new_request=None):
"""edit a submit action from orequest/new_request"""
import tempfile, shutil
actions = orequest.get_actions('submit')
oactions = actions
if new_request is not None:
@ -8088,7 +8052,6 @@ class MultibuildFlavorResolver:
break
if use_globs:
import fnmatch
multibuild_xml = self.get_multibuild_data()
all_flavors = self.parse_multibuild_data(multibuild_xml)
flavors = set()

View File

@ -6,14 +6,17 @@
import os
import re
import shutil
import subprocess
import sys
import tempfile
from urllib.parse import quote_plus
from urllib.request import HTTPError
from . import checker as osc_checker
from . import conf
from . import oscerr
from .core import makeurl, streamfile, dgst
from .core import makeurl, dgst
from .grabber import OscFileGrabber, OscMirrorGroup
from .meter import create_text_meter
from .util import packagequery, cpio
@ -155,7 +158,6 @@ class Fetcher:
os.unlink(tmpfile.name)
def move_package(self, tmpfile, destdir, pac_obj=None):
import shutil
canonname = None
if pac_obj and pac_obj.name.startswith('container:'):
canonname = pac_obj.canonname
@ -324,8 +326,6 @@ def verify_pacs_old(pac_list):
Check all packages in one go, since this takes only 6 seconds on my Athlon 700
instead of 20 when calling 'rpm -K' for each of them.
"""
import subprocess
if not pac_list:
return
@ -403,9 +403,8 @@ def verify_pacs(bi):
print("using keys from", ', '.join(bi.prjkeys))
from . import checker
failed = False
checker = checker.Checker()
checker = osc_checker.Checker()
try:
checker.readkeys(bi.keys)
for pkg in pac_list:

View File

@ -5,7 +5,6 @@
import os
import sys
from urllib.request import HTTPError
from urllib.parse import urlparse
from urllib.parse import unquote

View File

@ -1,14 +1,10 @@
import binascii
import datetime
import errno
import os
import socket
import ssl
import sys
import tempfile
import typing
import urllib3.connection
from cryptography import x509
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization

View File

@ -1,7 +1,7 @@
import os
import re
import subprocess
import tarfile
import sys
from . import packagequery
@ -207,7 +207,6 @@ class ArchQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
if __name__ == '__main__':
import sys
archq = ArchQuery.query(sys.argv[1])
print(archq.name(), archq.version(), archq.release(), archq.arch())
try:

View File

@ -14,7 +14,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import mmap
import os
import stat
import struct

View File

@ -1,6 +1,7 @@
import itertools
import os
import re
import sys
import tarfile
from io import BytesIO
@ -249,7 +250,6 @@ class DebQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
return b'%s_%s_%s.deb' % (name, version, arch)
if __name__ == '__main__':
import sys
try:
debq = DebQuery.query(sys.argv[1])
except DebError as e:

View File

@ -4,6 +4,7 @@
# either version 2, or (at your option) any later version.
import builtins
import html
from .. import oscerr
@ -39,7 +40,6 @@ def decode_it(obj):
def raw_input(*args):
import builtins
func = builtins.input
try:

View File

@ -1,3 +1,5 @@
import sys
from .helper import decode_it
@ -166,7 +168,6 @@ def cmp(a, b):
if __name__ == '__main__':
import sys
try:
pkgq = PackageQuery.query(sys.argv[1])
except PackageError as e:

View File

@ -1,6 +1,7 @@
import os
import re
import struct
import sys
from . import packagequery
from .helper import decode_it
@ -385,7 +386,6 @@ def unpack_string(data, encoding=None):
return data
if __name__ == '__main__':
import sys
try:
rpmq = RpmQuery.query(sys.argv[1])
except RpmError as e:

View File

@ -1,5 +1,6 @@
import os
import sys
import unittest
import osc.core
import osc.oscerr
@ -10,7 +11,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'addfile_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestAddFiles)
class TestAddFiles(OscTestCase):
@ -84,5 +84,4 @@ class TestAddFiles(OscTestCase):
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,5 +1,6 @@
import os
import sys
import unittest
from urllib.error import HTTPError
from xml.etree import ElementTree as ET
@ -12,7 +13,6 @@ from .common import GET, PUT, POST, DELETE, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'commit_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestCommit)
rev_dummy = '<revision rev="repository">\n <srcmd5>empty</srcmd5>\n</revision>'
@ -369,5 +369,4 @@ class TestCommit(OscTestCase):
self._check_status(p, 'bar', ' ')
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -48,5 +48,4 @@ class TestParseRevisionOption(unittest.TestCase):
if __name__ == "__main__":
import unittest
unittest.main()

View File

@ -1,4 +1,5 @@
import os
import unittest
import osc.core
import osc.oscerr
@ -9,7 +10,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'deletefile_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestDeleteFiles)
class TestDeleteFiles(OscTestCase):
@ -206,5 +206,4 @@ class TestDeleteFiles(OscTestCase):
self.assertTrue(ret[1] == exp2)
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,5 +1,6 @@
import os
import re
import unittest
import osc.core
import osc.oscerr
@ -11,7 +12,6 @@ from .common import GET, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'difffile_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestDiffFiles)
class TestDiffFiles(OscTestCase):
@ -336,5 +336,4 @@ Binary file 'binary' has changed.
self.assertEqualMultiline(got, exp)
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,4 +1,5 @@
import os
import unittest
import osc.core
import osc.oscerr
@ -9,7 +10,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_package_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestInitPackage)
class TestInitPackage(OscTestCase):
@ -89,5 +89,4 @@ class TestInitPackage(OscTestCase):
self.assertRaises(osc.oscerr.OscIOError, osc.core.Package.init_package, 'http://localhost', 'osctest', 'testpkg', pac_dir)
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,5 +1,7 @@
import os
import unittest
import osc.conf
import osc.core
import osc.oscerr
@ -9,7 +11,6 @@ from .common import GET, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_project_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestInitProject)
class TestInitProject(OscTestCase):
@ -58,7 +59,6 @@ class TestInitProject(OscTestCase):
disable wc_check (because we didn't disable the package tracking before the Project class
was imported therefore REQ_STOREFILES contains '_packages')
"""
import osc.conf
# disable package tracking
osc.conf.config['do_package_tracking'] = False
prj_dir = os.path.join(self.tmpdir, 'testprj')
@ -71,5 +71,4 @@ class TestInitProject(OscTestCase):
self.assertFalse(os.path.exists(os.path.join(storedir, '_packages')))
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,4 +1,5 @@
import os
import unittest
import osc.core
import osc.oscerr
@ -9,7 +10,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestPackageStatus)
class TestPackageStatus(OscTestCase):
@ -85,5 +85,4 @@ class TestPackageStatus(OscTestCase):
self.assertEqual(exp_st, st)
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,6 +1,7 @@
import os
import re
import sys
import unittest
import osc.commandline
import osc.core
@ -42,7 +43,6 @@ def POST_RDIFF(oldprj, newprj):
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestProjectDiff)
class TestProjectDiff(OscTestCase):
@ -262,5 +262,4 @@ identical: only-in-new
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,4 +1,5 @@
import os
import unittest
import osc.core
import osc.oscerr
@ -9,7 +10,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestProjectStatus)
class TestProjectStatus(OscTestCase):
@ -160,5 +160,4 @@ class TestProjectStatus(OscTestCase):
self.assertTrue(isinstance(p, type(None)))
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,5 +1,7 @@
import os
import shutil
import sys
import unittest
from xml.etree import ElementTree as ET
import osc.core
@ -11,7 +13,6 @@ from .common import GET, PUT, POST, DELETE, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'repairwc_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestRepairWC)
class TestRepairWC(OscTestCase):
@ -214,7 +215,6 @@ class TestRepairWC(OscTestCase):
def test_project_noapiurl(self):
"""the project wc has no _apiurl file"""
import shutil
prj_dir = os.path.join(self.tmpdir, 'prj_noapiurl')
shutil.copytree(os.path.join(self._get_fixtures_dir(), 'prj_noapiurl'), prj_dir)
storedir = os.path.join(prj_dir, osc.core.store)
@ -227,5 +227,4 @@ class TestRepairWC(OscTestCase):
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,4 +1,5 @@
import os
import unittest
from xml.etree import ElementTree as ET
import osc.core
@ -10,7 +11,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'request_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestRequest)
class TestRequest(OscTestCase):
@ -566,5 +566,4 @@ Comment: <no comment>"""
self.assertTrue(len(r.get_actions()) == 8)
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,5 +1,6 @@
import os
import sys
import unittest
import osc.commandline
@ -7,7 +8,6 @@ from .common import GET, OscTestCase
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestResults)
class TestResults(OscTestCase):
@ -51,6 +51,5 @@ class TestResults(OscTestCase):
self.assertEqualMultiline(out, self._get_fixture('result-dirty.xml')+self._get_fixture('result.xml'))
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,4 +1,5 @@
import os
import unittest
import osc.core
import osc.oscerr
@ -9,7 +10,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'revertfile_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestRevertFiles)
class TestRevertFiles(OscTestCase):
@ -96,5 +96,4 @@ class TestRevertFiles(OscTestCase):
self.assertFilesEqual(fname, storefile)
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,4 +1,5 @@
import os
import unittest
import osc.core
import osc.oscerr
@ -9,7 +10,6 @@ from .common import GET, PUT, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'setlinkrev_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestSetLinkRev)
class TestSetLinkRev(OscTestCase):
@ -90,5 +90,4 @@ class TestSetLinkRev(OscTestCase):
osc.core.set_link_rev('http://localhost', 'osctest', 'simple', revision=None)
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -1,5 +1,6 @@
import os
import sys
import unittest
import osc.core
import osc.oscerr
@ -10,7 +11,6 @@ from .common import GET, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'update_fixtures')
def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestUpdate)
class TestUpdate(OscTestCase):
@ -286,5 +286,4 @@ class TestUpdate(OscTestCase):
self._check_digests('testUpdateResumeDeletedFile_files')
if __name__ == '__main__':
import unittest
unittest.main()