Commit d9dff0e8 authored by Thomas Gambier's avatar Thomas Gambier

[webrunner]: use newest timestamp in equeue.db to get last backup date

in some webrunner, there are 2 keys in equeue.db:

```
>>> print(db.keys())
['/srv/slapgrid/slappart18/bin//runner-importer', '/srv/slapgrid/slappart18/bin/runner-importer']
```

As you can see, the importer script path changed. But we don't care
about this, we always want to have the latest (= the newest) backup date.
parent 58a3efb3
Pipeline #9000 failed with stage
......@@ -41,17 +41,17 @@ def getLatestBackupDate():
equeue_database_copy = os.path.join(temporary_directory, 'equeue.db')
shutil.copyfile(equeue_database, equeue_database_copy)
db = gdbm.open(equeue_database_copy)
# Usually, there is only one callback (so only one key
# in the db), but if there are several:
# Take the "oldest" one (oldest value).
# Usually, there is only one callback (so only one key in the db), but if
# there are several we take the "newest" one. Indeed, sometimes the importer
# script change name those introducing a new key inside the db.
db_keys = db.keys()
if not db_keys:
result = False
else:
last_backup = db[db_keys[-1]]
last_backup = db[db_keys[0]]
for callback in db_keys:
timestamp = float(db[callback])
if timestamp < last_backup:
if timestamp > last_backup:
last_backup = timestamp
result = datetime.datetime.fromtimestamp(last_backup)
db.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment