mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-06-09 08:41:34 +00:00
AgePolicy: Create the (new) date file automatically
Closes: Debian/britney2#13 Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
190be31014
commit
6de0c3408c
@ -281,13 +281,20 @@ class AgePolicy(BasePolicy):
|
|||||||
"""Parse the dates file"""
|
"""Parse the dates file"""
|
||||||
dates = self._dates
|
dates = self._dates
|
||||||
fallback_filename = os.path.join(self.options.testing, 'Dates')
|
fallback_filename = os.path.join(self.options.testing, 'Dates')
|
||||||
|
using_new_name = False
|
||||||
try:
|
try:
|
||||||
filename = os.path.join(self.options.state_dir, 'age-policy-dates')
|
filename = os.path.join(self.options.state_dir, 'age-policy-dates')
|
||||||
if not os.path.exists(filename) and os.path.exists(fallback_filename):
|
if not os.path.exists(filename) and os.path.exists(fallback_filename):
|
||||||
filename = fallback_filename
|
filename = fallback_filename
|
||||||
|
else:
|
||||||
|
using_new_name = True
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
if os.path.exists(fallback_filename):
|
||||||
filename = fallback_filename
|
filename = fallback_filename
|
||||||
|
else:
|
||||||
|
raise RuntimeError("Please set STATE_DIR in the britney configuration")
|
||||||
|
|
||||||
|
try:
|
||||||
with open(filename, encoding='utf-8') as fd:
|
with open(filename, encoding='utf-8') as fd:
|
||||||
for line in fd:
|
for line in fd:
|
||||||
# <source> <version> <date>
|
# <source> <version> <date>
|
||||||
@ -298,6 +305,13 @@ class AgePolicy(BasePolicy):
|
|||||||
dates[l[0]] = (l[1], int(l[2]))
|
dates[l[0]] = (l[1], int(l[2]))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
except FileNotFoundError:
|
||||||
|
if not using_new_name:
|
||||||
|
# If we using the legacy name, then just give up
|
||||||
|
raise
|
||||||
|
self.log("%s does not appear to exist. Creating it" % filename)
|
||||||
|
with open(filename, mode='wx', encoding='utf-8'):
|
||||||
|
pass
|
||||||
|
|
||||||
def _read_urgencies_file(self, britney):
|
def _read_urgencies_file(self, britney):
|
||||||
urgencies = self._urgencies
|
urgencies = self._urgencies
|
||||||
|
Loading…
x
Reference in New Issue
Block a user