1 |
Author: zmedico |
2 |
Date: 2009-10-25 20:21:10 +0000 (Sun, 25 Oct 2009) |
3 |
New Revision: 14725 |
4 |
|
5 |
Modified: |
6 |
main/trunk/bin/repoman |
7 |
Log: |
8 |
Don't set mtime on downloaded metadata.dtd when using python3, since the |
9 |
rfc822.parsedate() function is not available. Thanks to Arfrever for |
10 |
reporting. |
11 |
|
12 |
|
13 |
Modified: main/trunk/bin/repoman |
14 |
=================================================================== |
15 |
--- main/trunk/bin/repoman 2009-10-24 12:16:59 UTC (rev 14724) |
16 |
+++ main/trunk/bin/repoman 2009-10-25 20:21:10 UTC (rev 14725) |
17 |
@@ -25,8 +25,17 @@ |
18 |
import tempfile |
19 |
import time |
20 |
import platform |
21 |
-import urllib |
22 |
|
23 |
+try: |
24 |
+ from urllib.request import urlopen as urllib_request_urlopen |
25 |
+except ImportError: |
26 |
+ from urllib import urlopen as urllib_request_urlopen |
27 |
+ |
28 |
+try: |
29 |
+ from rfc822 import parsedate |
30 |
+except ImportError: |
31 |
+ parsedate = None |
32 |
+ |
33 |
from io import StringIO |
34 |
from itertools import chain |
35 |
from stat import S_ISDIR, ST_CTIME |
36 |
@@ -803,10 +812,19 @@ |
37 |
"needs to be refetched, doing that now") |
38 |
print() |
39 |
try: |
40 |
- url_f = urllib.urlopen(metadata_dtd_uri) |
41 |
- last_modified = url_f.info().getdate('last-modified') |
42 |
- if last_modified is not None: |
43 |
- last_modified = time.mktime(last_modified) |
44 |
+ url_f = urllib_request_urlopen(metadata_dtd_uri) |
45 |
+ msg_info = url_f.info() |
46 |
+ last_modified = msg_info.get('last-modified') |
47 |
+ # Date parsing isn't supported in python3 since it has no |
48 |
+ # equivalent of the rfc822.parsedate() function. |
49 |
+ # TODO: Convert the last-modified field to locale-independent |
50 |
+ # format and then use time.strptime() to parse it. |
51 |
+ if parsedate is None: |
52 |
+ last_modified = None |
53 |
+ elif last_modified is not None: |
54 |
+ last_modified = parsedate(last_modified) |
55 |
+ if last_modified is not None: |
56 |
+ last_modified = time.mktime(last_modified) |
57 |
|
58 |
metadata_dtd_tmp = "%s.%s" % (metadata_dtd, os.getpid()) |
59 |
try: |