Kaydet (Commit) 273109fd authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

Merge remote-tracking branch 'gitlab_mirror/fix-fetcher' into develop

......@@ -56,6 +56,7 @@ class CLI(inary.ui.UI):
super(CLI, self).__init__(show_debug, show_verbose)
self.warnings = 0
self.errors = 0
self.clean_line="\x1b[K"
def close(self):
util.xterm_title_reset()
......@@ -67,6 +68,7 @@ class CLI(inary.ui.UI):
if err:
sys.stderr.write(str(msg))
else:
msg=self.clean_line+msg+self.clean_line
sys.stdout.write(str(msg))
def formatted_output(self, msg, verbose=False, noln=False, column=":"):
......@@ -180,9 +182,9 @@ class CLI(inary.ui.UI):
if no_expr.search(s):
return False
def display_progress(self, **ka):
""" display progress of any operation """
if ka['operation'] in ["removing", "rebuilding-db"]:
return
......@@ -190,14 +192,13 @@ class CLI(inary.ui.UI):
if not ctx.get_option("no_color"):
complated_background = 'backgroundgreen'
queried_background = 'backgroundyellow'
complated='brightblue'
else:
complated_background = queried_background = complated = "default"
hr_size, hr_symbol = util.human_readable_size(ka["total_size"])
totalsize = '{:.1f} {}'.format(hr_size, hr_symbol)
file_and_totalsize = '{:30.50} ({})'.format(ka['filename'], totalsize)
file_and_totalsize = '{:30.20} ({})'.format(ka['filename'], totalsize)
percentage_and_time = '{:9.2f} % {:9.2f} {} [ {} ]'.format(ka['percent'],
ka['rate'],
ka['symbol'],
......@@ -214,12 +215,9 @@ class CLI(inary.ui.UI):
self.output(out)
lmsg = int( ( len(msg) * ka["percent"] ) / 100 ) + 1
if ka["percent"] == 100:
self.output("\r" + ctx.const.colors[complated] + msg + ctx.const.colors['default'])
else:
self.output("\r" + ctx.const.colors[complated_background] + \
msg[:lmsg] + ctx.const.colors[queried_background] + msg[lmsg:] + \
ctx.const.colors['default'])
self.output("\r".format(lmsg)+ctx.const.colors[complated_background] + \
msg[:lmsg] + ctx.const.colors[queried_background] + msg[lmsg:] + \
ctx.const.colors['default'])
util.xterm_title("{} ( {:.2f} % )".format(ka['filename'], ka['percent']))
else:
......@@ -280,6 +278,22 @@ class CLI(inary.ui.UI):
ctx.log.info(_("Extracted desktop file \"{}\"").format(keywords['desktopfile']))
msg = None
elif event == inary.ui.fetching:
if self.show_verbose:
msg=""
else:
msg="\x1b[K"
msg+=_("Downloading <{} / {}>".format(keywords['which'],keywords['total']))
color="yellow"
elif event == inary.ui.fetched:
if self.show_verbose:
msg=""
else:
msg="\x1b[3A"
msg+=_("Downloaded \"{}\"".format(keywords['name']))
color="green"
else:
msg = None
......
......@@ -80,7 +80,7 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment
try:
repository.update_repos([name])
except (inary.errors.Error, IOError) as e:
ctx.ui.warning(_("{0} repository could not be reached: {1}").format(name, e))
ctx.ui.info(_("Error: {0} repository could not be reached: \n{1}").format(name, e), color="red")
self.warn_and_remove(_("Removing {0} from system.").format(name), name)
else:
ctx.ui.warning(_("Couldn't trust \"{0}\" repository. It is deactivated.").format(name))
......
......@@ -171,7 +171,7 @@ class RepoDB(lazydb.LazyDB):
index_path = os.path.splitext(index_path)[0]
if not os.path.exists(index_path):
ctx.ui.warning(_("{} repository needs to be updated").format(repo_name))
#ctx.ui.warning(_("{} repository needs to be updated").format(repo_name))
return xmlext.newDocument("INARY")
try:
......
......@@ -143,10 +143,12 @@ class File:
inary.fetcher.fetch_url(uri, transfer_dir, ctx.ui.Progress, tmpfile)
else:
# copy to transfer dir
ctx.ui.info(_("Copying \"{}\" to transfer dir").format(uri.get_uri()), verbose=True)
shutil.copy(uri.get_uri(), localfile)
inary.fetcher.fetch_from_locale(uri.get_uri(), transfer_dir, destfile=localfile)
else:
localfile = uri.get_uri() # TODO: use a special function here?
if localfile.startswith("file:///"):
localfile=localfile[7:]
if not os.path.exists(localfile):
raise IOError(_("File \"{}\" not found.").format(localfile))
if not os.access(localfile, os.W_OK):
......@@ -259,7 +261,7 @@ class File:
except KeyboardInterrupt:
raise
except IOError: # FIXME: what exception could we catch here, replace with that.
ctx.ui.error(NoSignatureFound(uri))
ctx.ui.warning(NoSignatureFound(uri))
return True
ret, out, err = inary.util.run_batch('gpg --verify ' + sigfilename)
......
......@@ -94,7 +94,7 @@ def install_pkg_names(A, reinstall=False, extra=False):
paths = []
extra_paths = {}
for x in order:
ctx.ui.info(_("Downloading {} / {}").format(order.index(x) + 1, len(order)), color="yellow")
ctx.ui.notify(ui.fetching, which=order.index(x) + 1, total=len(order))
install_op = atomicoperations.Install.from_name(x)
paths.append(install_op.package_fname)
if x in extra_packages or (extra and x in A):
......@@ -103,6 +103,7 @@ def install_pkg_names(A, reinstall=False, extra=False):
installdb.installed_extra.remove(x)
with open(os.path.join(ctx.config.info_dir(), ctx.const.installed_extra), "w") as ie_file:
ie_file.write("\n".join(installdb.installed_extra) + ("\n" if installdb.installed_extra else ""))
ctx.ui.notify(ui.fetched, name=x)
# fetch to be installed packages but do not install them.
if ctx.get_option('fetch_only'):
......
......@@ -66,6 +66,8 @@ class Package:
if url.is_remote_file():
self.fetch_remote_file(url)
else:
ctx.ui.info(_("Getting package file \"{}\" from locale.").format(url.filename()))
try:
self.impl = archive.ArchiveZip(self.filepath, 'zip', mode)
......
......@@ -15,7 +15,7 @@
#
(installed, upgraded, removed, installing, removing, configuring, configured, extracting,
downloading, packagestogo, updatingrepo, cached, desktopfile) = list(range(13))
downloading, packagestogo, updatingrepo, cached, desktopfile, fetching, fetched) = list(range(15))
class UI(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment