Include test-station name in osTicket posts

* Only added if the hostname is a known test-station
* Addresses issue #96
This commit is contained in:
2Shirt 2019-05-16 13:35:15 -06:00
parent f879c97e53
commit 6b159cc6d4
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 28 additions and 2 deletions

View file

@ -189,11 +189,14 @@ class osTicket():
def generate_report(self, dev, ticket_id, ticket_name):
"""Generate device report for osTicket, returns list."""
report = []
report = ['']
results = self.get_device_overall_results(dev)
test_station = TEST_STATIONS.get(get_hostname().lower(), '')
# Header
report.append('[Report for ticket #{} {}]'.format(ticket_id, ticket_name))
if test_station:
report[0] += '[Test-Station: {}] '.format(test_station)
report[0] += '[Report for ticket #{} {}]'.format(ticket_id, ticket_name)
if results['Full Diag']:
report.append(
'{Dev Type} hardware diagnostic tests: {Status}'.format(**results))
@ -584,6 +587,13 @@ class osTicket():
# Functions
def get_hostname():
"""Get hostname, returns str."""
cmd = ['hostnamectl', '--static']
result = run_program(cmd, check=False, encoding='utf-8', errors='ignore')
return result.stdout.strip()
def pad_with_dots(s, pad_right=False):
"""Replace space padding with dots, returns str."""
s = str(s).replace(' ', '..')

View file

@ -26,6 +26,22 @@ OSTICKET = {
'Ticket': 'ost_ticket',
},
}
TEST_STATIONS = {
'bender': 'Bender',
'combine': 'Combine',
'control': 'Control',
'cortana': 'Cortana',
'data': 'Data',
'glados': 'GLaDOS',
'locutus': 'Locutus',
'lore': 'Lore',
'sex-robot': 'Sex-Robot',
'shodan': 'Shodan',
'six': 'Six',
'skynet': 'Skynet',
'supremo': 'Supremo',
'unicron': 'Unicron',
}
if __name__ == '__main__':
print("This file is not meant to be called directly.")