Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/layman:master commit in: layman/
Date: Thu, 28 Jul 2011 22:02:52
Message-Id: b08a5e4b34e0258e84714bcef16c1d5d09c71b39.dol-sen@gentoo
1 commit: b08a5e4b34e0258e84714bcef16c1d5d09c71b39
2 Author: dol-sen <brian.dolbec <AT> gmail <DOT> com>
3 AuthorDate: Thu Jul 28 21:29:12 2011 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Thu Jul 28 21:29:12 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=b08a5e4b
7
8 fix setting the timestamp from the remote server, bug # 376601.
9
10 ---
11 layman/db.py | 21 ++++++++++++++-------
12 1 files changed, 14 insertions(+), 7 deletions(-)
13
14 diff --git a/layman/db.py b/layman/db.py
15 index bb6fd81..64b54ce 100644
16 --- a/layman/db.py
17 +++ b/layman/db.py
18 @@ -319,7 +319,12 @@ class RemoteDB(DbBase):
19
20 try:
21 connection = opener.open(request)
22 - timestamp = connection.headers['last-modified']
23 + if 'last-modified' in connection.headers.keys():
24 + timestamp = connection.headers['last-modified']
25 + elif 'date' in connection.headers.keys():
26 + timestamp = connection.headers['date']
27 + else:
28 + timestamp = None
29 except urllib2.HTTPError as e:
30 if e.getcode() == 304:
31 self.output.info('Remote list already up to date: %s'
32 @@ -330,15 +335,16 @@ class RemoteDB(DbBase):
33 % str(e))
34 continue
35 except IOError as error:
36 - self.output.warn('Failed to update the overlay list from: '
37 - + url + '\nError was:\n' + str(error))
38 + self.output.warn('RemoteDB.cache(); Failed to update the overlay list from: '
39 + + url + '\nIOError was:\n' + str(error))
40 else:
41 if url.startswith('file://'):
42 quieter = 1
43 else:
44 quieter = 0
45 self.output.info('Fetching new list... %s' % url, 4 + quieter)
46 - self.output.info('Last-modified: %s' % timestamp, 4 + quieter)
47 + if timestamp is not None:
48 + self.output.info('Last-modified: %s' % timestamp, 4 + quieter)
49 # Fetch the remote list
50 olist = connection.read()
51
52 @@ -368,9 +374,10 @@ class RemoteDB(DbBase):
53 out_file.write(olist)
54 out_file.close()
55
56 - out_file = open(tpath, 'w')
57 - out_file.write(timestamp)
58 - out_file.close()
59 + if timestamp is not None:
60 + out_file = open(tpath, 'w')
61 + out_file.write(str(timestamp))
62 + out_file.close()
63
64 has_updates = True