replace urlgrabber with pycurl
This commit is contained in:
parent
b4c7433cc4
commit
644792ff76
4 changed files with 27 additions and 11 deletions
27
cli/koji
27
cli/koji
|
|
@ -59,14 +59,13 @@ import logging
|
|||
import os
|
||||
import re
|
||||
import pprint
|
||||
import pycurl
|
||||
import random
|
||||
import socket
|
||||
import stat
|
||||
import string
|
||||
import time
|
||||
import traceback
|
||||
import urlgrabber.grabber as grabber
|
||||
import urlgrabber.progress as progress
|
||||
import six.moves.xmlrpc_client
|
||||
try:
|
||||
import libcomps
|
||||
|
|
@ -6820,15 +6819,29 @@ def anon_handle_download_build(options, session, args):
|
|||
url = pathinfo.build(info) + '/' + fname
|
||||
urls.append((url, os.path.basename(fname)))
|
||||
|
||||
if suboptions.quiet:
|
||||
pg = None
|
||||
else:
|
||||
pg = progress.TextMeter()
|
||||
def _progress(download_t, download_d, upload_t, upload_d):
|
||||
if download_t == 0:
|
||||
percent_done = 0.0
|
||||
else:
|
||||
percent_done = float(download_d)/float(download_t)
|
||||
percent_done_str = "%02d%%" % (percent_done * 100)
|
||||
data_done = _format_size(download_d)
|
||||
|
||||
sys.stdout.write("[% -36s] % 4s % 10s\r" % ('='*(int(percent_done * 36)), percent_done_str, data_done))
|
||||
sys.stdout.flush()
|
||||
|
||||
for url, relpath in urls:
|
||||
if '/' in relpath:
|
||||
koji.ensuredir(os.path.dirname(relpath))
|
||||
grabber.urlgrab(url, filename=relpath, progress_obj=pg, text=relpath)
|
||||
print(relpath)
|
||||
c = pycurl.Curl()
|
||||
c.setopt(c.URL, url)
|
||||
c.setopt(c.WRITEDATA, open(relpath, 'wb'))
|
||||
if not suboptions.quiet:
|
||||
c.setopt(c.NOPROGRESS, False)
|
||||
c.setopt(c.XFERINFOFUNCTION, _progress)
|
||||
c.perform()
|
||||
print('')
|
||||
|
||||
|
||||
def anon_handle_download_logs(options, session, args):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue