1#!/usr/bin/env python3
2
3"""Generate the system info control of the System menu page."""
4
5import os
6import pwd
7
8from django.shortcuts import render
9
10import chart
11from chart.db.model.table import TableInfo
12from chart.project import settings
13from chart.project import SID
14from chart.products.scos2000.srdb_version_info import get_srdb_version
15from chart.products.scos2000.srdb_version_info import get_srdb_date_implemented
16
17def index(request):
18 """Display system information."""
19 unixuser = pwd.getpwuid(os.getuid())[0]
20
21 # prepare a list of all database connections in actual use
22 dbs = []
23 # primary
24 dbs.append(settings.DATABASES['default'])
25
26 # extend dbs with any connections used by split tables
27 for k,v in settings.DB_SPLIT_TABLES.items():
28 settings.DATABASES[v]['DB_NAME'] = v # ...
29 if settings.DATABASES[v] not in dbs:
30 dbs.append(settings.DATABASES[v])
31
32 srdbs = []
33 for s in SID.all(operational=None):
34 if s.satellite is not None:
35 new_item = {'name': s.name,
36 'srdb_version': None,
37 'srdb_version_date': None,
38 }
39
40 if new_item['srdb_version'] is None:
41 new_item['srdb_version'] = get_srdb_version(s)
42
43 if new_item['srdb_version_date'] is None:
44 new_item['srdb_version_date'] = get_srdb_date_implemented(s)
45
46 srdbs.append(new_item)
47
48 return render(
49 request,
50 'web/sysinfo.html',
51 {
52 'unixuser': unixuser,
53 'dbs': dbs,
54 'version_properties': chart.version_info(),
55 'srdb_versions': srdbs,
56 }
57 )