mirror of
https://github.com/openSUSE/osc.git
synced 2025-08-21 22:18:52 +02:00
- raise an appropriate exception if a package is missing and --no-init or --offline is specified
This commit is contained in:
11
osc/fetch.py
11
osc/fetch.py
@@ -10,6 +10,7 @@ from urlgrabber.mirror import MirrorGroup
|
||||
from core import makeurl, streamfile
|
||||
from util import packagequery, cpio
|
||||
import conf
|
||||
import oscerr
|
||||
import tempfile
|
||||
try:
|
||||
from meter import TextMeter
|
||||
@@ -51,7 +52,7 @@ class OscFileGrabber:
|
||||
|
||||
class Fetcher:
|
||||
def __init__(self, cachedir = '/tmp', api_host_options = {}, urllist = [], http_debug = False,
|
||||
cookiejar = None, noinit = False, offline = False, enable_cpio = False):
|
||||
cookiejar = None, offline = False, enable_cpio = False):
|
||||
# set up progress bar callback
|
||||
if sys.stdout.isatty() and TextMeter:
|
||||
self.progress_obj = TextMeter(fo=sys.stdout)
|
||||
@@ -61,7 +62,6 @@ class Fetcher:
|
||||
self.cachedir = cachedir
|
||||
self.urllist = urllist
|
||||
self.http_debug = http_debug
|
||||
self.noinit = noinit
|
||||
self.offline = offline
|
||||
self.cpio = {}
|
||||
self.enable_cpio = enable_cpio
|
||||
@@ -86,9 +86,6 @@ class Fetcher:
|
||||
# for use by the failure callback
|
||||
self.curpac = pac
|
||||
|
||||
if self.noinit or self.offline:
|
||||
return True
|
||||
|
||||
MirrorGroup._join_url = join_url
|
||||
mg = MirrorGroup(self.gr, pac.urllist, failure_callback=(self.failureReport,(),{}))
|
||||
|
||||
@@ -165,8 +162,7 @@ class Fetcher:
|
||||
i.makeurls(self.cachedir, self.urllist)
|
||||
if not os.path.exists(i.fullfilename):
|
||||
if self.offline:
|
||||
print "Missing package '%s' in cache: --offline not possible." % i.fullfilename
|
||||
sys.exit(1)
|
||||
raise oscerr.OscIOError(None, 'Missing package \'%s\' in cache: --offline not possible.' % i.fullfilename)
|
||||
self.dirSetup(i)
|
||||
try:
|
||||
# if there isn't a progress bar, there is no output at all
|
||||
@@ -197,7 +193,6 @@ class Fetcher:
|
||||
archive.read()
|
||||
for hdr in archive:
|
||||
if hdr.filename == '.errors':
|
||||
import oscerr
|
||||
archive.copyin_file(hdr.filename)
|
||||
raise oscerr.APIError('CPIO archive is incomplete (see .errors file)')
|
||||
pac = pkgs[hdr.filename.rsplit('.', 1)[0]]
|
||||
|
Reference in New Issue
Block a user