summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-10-25 20:21:10 +0000
committerZac Medico <zmedico@gentoo.org>2009-10-25 20:21:10 +0000
commitab60eb150637709d9ae0fb166ed8eebcfa9b43f0 (patch)
treecea7d9be54e5b80c5961b844335d457663c69e7c /bin/repoman
parentupdate documentation on _test_openpty_eof and disable openpty on Solaris agai... (diff)
downloadportage-idfetch-ab60eb150637709d9ae0fb166ed8eebcfa9b43f0.tar.gz
portage-idfetch-ab60eb150637709d9ae0fb166ed8eebcfa9b43f0.tar.bz2
portage-idfetch-ab60eb150637709d9ae0fb166ed8eebcfa9b43f0.zip
Don't set mtime on downloaded metadata.dtd when using python3, since the
rfc822.parsedate() function is not available. Thanks to Arfrever for reporting. svn path=/main/trunk/; revision=14725
Diffstat (limited to 'bin/repoman')
-rwxr-xr-xbin/repoman28
1 files changed, 23 insertions, 5 deletions
diff --git a/bin/repoman b/bin/repoman
index 703d18e4..7dee4fe8 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -25,7 +25,16 @@ import sys
import tempfile
import time
import platform
-import urllib
+
+try:
+ from urllib.request import urlopen as urllib_request_urlopen
+except ImportError:
+ from urllib import urlopen as urllib_request_urlopen
+
+try:
+ from rfc822 import parsedate
+except ImportError:
+ parsedate = None
from io import StringIO
from itertools import chain
@@ -803,10 +812,19 @@ def fetch_metadata_dtd():
"needs to be refetched, doing that now")
print()
try:
- url_f = urllib.urlopen(metadata_dtd_uri)
- last_modified = url_f.info().getdate('last-modified')
- if last_modified is not None:
- last_modified = time.mktime(last_modified)
+ url_f = urllib_request_urlopen(metadata_dtd_uri)
+ msg_info = url_f.info()
+ last_modified = msg_info.get('last-modified')
+ # Date parsing isn't supported in python3 since it has no
+ # equivalent of the rfc822.parsedate() function.
+ # TODO: Convert the last-modified field to locale-independent
+ # format and then use time.strptime() to parse it.
+ if parsedate is None:
+ last_modified = None
+ elif last_modified is not None:
+ last_modified = parsedate(last_modified)
+ if last_modified is not None:
+ last_modified = time.mktime(last_modified)
metadata_dtd_tmp = "%s.%s" % (metadata_dtd, os.getpid())
try: