Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions almir/lib/bconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,13 @@ def get_upcoming_jobs(self, days=1):
unparsed_jobs = stdout.split('===================================================================================\n')[1].split('====\n')[0]
except IndexError:
return []

fields = ('level', 'type', 'priority', 'date', 'time', 'name', 'volume')
jobs = []
for line in unparsed_jobs.split('\n'):
if not line.strip():
continue

jobs.append({
'level': line[:14].strip(),
'type': line[14:23].strip(),
'priority': line[23:28].strip(),
'date': line[28:38].strip(),
'time': line[38:44].strip(),
'name': line[47:67].strip(),
'volume': line[67:].strip(),
})
jobs.append(dict(zip(fields, line.split())))

return jobs

Expand Down
2 changes: 1 addition & 1 deletion almir/templates/macros.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<td>{{ job.type }}</td>
<td>{{ job.level }}</td>
<td>{{ job.priority }}</td>
<td>{{ job.date }} {{ job.time }}</td>
<td>{{ job.date.decode('utf-8') }} {{ job.time }}</td>
<td>{{ job.volume }}</td>
</tr>
{% endfor %}
Expand Down
10 changes: 9 additions & 1 deletion almir/tests/test_bconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,22 @@ def test_get_upcoming_jobs(self):
Scheduled Jobs:
Level Type Pri Scheduled Name Volume
===================================================================================
Incremental Backup 10 07-aoû2013 00:12 srv-prdadm-21_BOS DISK_sem-0004
Admin 8 18-Apr-12 20:30 UpdateSlots
Differential Backup 10 18-Mar-12 23:05 BackupClient1 *unknown*
Full Backup 11 18-Mar-12 23:10 BackupCatalog *unknown*
====
""", '')

jobs = b.get_upcoming_jobs()
self.assertEqual(jobs, [{'date': '18-Apr-12',
self.assertEqual(jobs, [{'date': '07-aoû2013',
'level': 'Incremental',
'name': 'srv-prdadm-21_BOS',
'time': '00:12',
'priority': '10',
'type': 'Backup',
'volume': 'DISK_sem-0004'},
{'date': '18-Apr-12',
'level': '',
'name': 'UpdateSlots',
'time': '20:30',
Expand Down