Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 174261 Details for
Bug 244997
app-portage/mirrorselect thinks wget doesn't handle ipv6 (patch)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
app-portage/mirrorselect: patch to enable wget ipv6 and remove deprecated warnings
mirrorselect.patch (text/plain), 4.33 KB, created by
Steven Robertson
on 2008-12-04 20:28:47 UTC
(
hide
)
Description:
app-portage/mirrorselect: patch to enable wget ipv6 and remove deprecated warnings
Filename:
MIME Type:
Creator:
Steven Robertson
Created:
2008-12-04 20:28:47 UTC
Size:
4.33 KB
patch
obsolete
>--- mirrorselect.orig 2008-12-04 15:12:44.476083441 -0500 >+++ mirrorselect 2008-12-04 15:21:55.301633180 -0500 >@@ -7,7 +7,7 @@ > __revision__ = '1.3' > > import sys >-import os, time, popen2, re, shutil, signal, shlex, string >+import os, time, subprocess, re, shutil, signal, shlex, string, urllib2 > from HTMLParser import HTMLParser > from optparse import IndentedHelpFormatter, OptionParser > >@@ -243,20 +243,16 @@ > Uses the supplied parser to get a list of urls. > Takes a parser object, url, and filering options. > """ >- >- if fetch == 'wget': >- fetch_cmd = 'wget --quiet -O - ' >- if fetch == 'fetch': >- fetch_cmd = 'fetch -q -o - ' >- if fetch == 'curl': >- fetch_cmd = 'curl -s' >- >- output.write('getlist(): fetching with ' + fetch_cmd + url + '\n', 2) >+ >+ output.write('getlist(): fetching with urllib2.urlopen(%s)\n' % url, 2) > > output.print_info('Downloading a list of mirrors...') > >- parser.feed(os.popen(fetch_cmd+url).read()) >+ url = urllib2.urlopen(url) >+ >+ parser.feed(url.read()) > parser.close() >+ url.close() > > if len(parser.lines) == 0: > output.print_err('Could not get mirror list. Check your internet' >@@ -297,19 +293,18 @@ > output.print_info('Using netselect to choose the top %d mirrors...' \ > % number) > >- host_string = ' '.join(hosts) >- > output.write('\nnetselect(): running "netselect -s%d %s"' % (int(number), >- host_string), 2) >+ ' '.join(hosts)), 2) > >- raw_out, raw_in, raw_err = popen2.popen3('netselect -s%d %s' % \ >- (int(number), host_string)) >- >- del raw_in >+ netselect_sp = subprocess.Popen( ['netselect', '-s%d' % int(number)] + hosts, >+ stdout = subprocess.PIPE, stderr = subprocess.PIPE) > >- output.write('netselect(): raw_err.read: %s' % raw_err.read(), 2) >+ (out, err) = netselect_sp.communicate() >+ >+ if err: >+ output.write('netselect(): raw_err.read: %s' % err, 2) > >- for line in raw_out.readlines(): >+ for line in out.split('\n'): > line = line.split() > if len(line) < 2: > continue >@@ -467,13 +462,15 @@ > fetch_cmd = 'fetch -o /dev/null -q %s' % (url) > if fetch == 'curl': > fetch_cmd = 'curl -o /dev/null -s --retry 1' % (url) >- >+ >+ dev_null = open('/dev/null', 'w') >+ null_fd = dev_null.fileno() > stime = time.time() > delta = 0 >- fetch = popen2.Popen4(fetch_cmd) >+ fetch = subprocess.Popen(fetch_cmd, stdout = null_fd, stderr = null_fd, shell = True) > > while delta < timeout: #while the timeout has not been exceeded... >- if fetch.poll() == -1: #if the process is still running... >+ if fetch.poll() is None: #if the process is still running... > time.sleep(0.001) #avoids a busywait... > delta = time.time() - stime #update the elapsed time > continue #and keep going >@@ -484,7 +481,7 @@ > > if fetch.poll() == -1: #if we timed out, we have to kill wget > output.write('deeptime(): download timed out. killing wget.\n', 2) >- os.kill(fetch.pid, 9) >+ fetch.kill() > > output.write('deeptime(): %s seconds for host %s\n' % (delta, url), 2) > >@@ -573,10 +570,8 @@ > > dialog += ' ' + ' '.join(['"%s" "%s" "OFF"' % host for host in hosts]) > >- mirror_fd = os.popen('%s' % dialog) >- mirrors = mirror_fd.read() >- mirror_fd.close() >- >+ dialog_sp = subprocess.Popen(dialog, stdout = subprocess.PIPE, shell = True) >+ mirrors = dialog_sp.communicate()[0] > self.urls = mirrors.split('\n') > > >@@ -584,20 +579,35 @@ > """ > Determines whether a particular binary is available on the host system. > """ >- return popen2.Popen4('which %s' % name).wait() == 0 >+ dev_null = open('/dev/null', 'w') >+ null_fd = dev_null.fileno() >+ ret = subprocess.Popen( ('which', name), stdout = null_fd, stderr = null_fd ).wait() >+ dev_null.close() >+ return (ret == 0) > > > def handler(signum, frame): > output.print_err('Caught signal %s. Exiting' % signum) > > >+def _wget_supports_ipv6(): >+ """ >+ Determines whether wget was compiled with IPv6 support. The --inet6-only option is only >+ listed in the output of 'wget --help' if wget supports IPv6 downloads. >+ """ >+ >+ wget_sp = subprocess.Popen( ('wget', '--help'), stdout = subprocess.PIPE) >+ (out, err) = wget_sp.communicate() >+ return ('IPv6' in out) >+ >+ > def _select_fetch(): > """ > Determines the propper fetch command, and the status of ipv6 support. > """ > if _have_bin('wget'): > fetch = 'wget' >- ipv6 = False >+ ipv6 = _wget_supports_ipv6() > elif _have_bin('fetch'): > fetch = 'fetch' > ipv6 = True
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 244997
: 174261