Permalink
Browse files

Merge "[BUG] beaker-import should fall back to .discinfo if timestamp…

… is not defined in .treeinfo." into release-0.9.0
  • Loading branch information...
p3ck authored and Gerrit Code Review committed Jun 15, 2012
2 parents 22ed66e + ae34dbd commit b75157486b63f92598b27e0a3fbde36b9923b58f
Showing with 13 additions and 5 deletions.
  1. +13 −5 LabController/proxy/src/bkr/labcontroller/distro_import.py
@@ -6,8 +6,6 @@
import getopt
from optparse import OptionParser
import urllib2
-import calendar
-from email.utils import parsedate
import logging
import socket
import copy
@@ -78,14 +76,12 @@ class Parser(object):
"""
url = None
parser = None
- last_modified = None
+ last_modified = 0.0
def parse(self, url):
self.url = url
try:
f = urllib2.urlopen('%s/%s' % (self.url, self.infofile))
- if 'last-modified' in f.headers:
- self.last_modified = calendar.timegm(parsedate(f.headers['last-modified']))
self.parser = ConfigParser.ConfigParser()
self.parser.readfp(f)
f.close()
@@ -97,6 +93,16 @@ def parse(self, url):
raise BX('%s/%s is not parsable: %s' % (self.url,
self.infofile,
e))
+
+ if self.discinfo:
+ try:
+ f = urllib2.urlopen('%s/%s' % (self.url, self.discinfo))
+ self.last_modified = f.read().split("\n")[0]
+ f.close()
+ except urllib2.URLError:
+ pass
+ except urllib2.HTTPError:
+ pass
return True
def get(self, section, key, default=None):
@@ -114,9 +120,11 @@ def __repr__(self):
class Cparser(Parser):
infofile = '.composeinfo'
+ discinfo = None
class Tparser(Parser):
infofile = '.treeinfo'
+ discinfo = '.discinfo'
class TparserRhel5(Tparser):
def get(self, section, key, default=None):

0 comments on commit b751574

Please sign in to comment.