Remove old teststation sections

This commit is contained in:
2Shirt 2022-12-15 22:38:11 -08:00
parent 51a3731124
commit 5048f679ee
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 11 additions and 46 deletions

View file

@ -12,36 +12,6 @@ STAFF = {
'ID': '23', 'ID': '23',
'Name': 'Wizard Kit', 'Name': 'Wizard Kit',
} }
TEST_STATIONS = {
# Domain will be stripped from the FQDN so the initial '.' is included
'Domain': '.1201.com',
'Known Names': {
'anaconda': 'Anaconda',
'ash': 'Ash',
'bender': 'Bender',
'combine': 'Combine',
'control': 'Control',
'cortana': 'Cortana',
'daftpunk': 'DaftPunk',
'data': 'Data',
'deepmind': 'DeepMind',
'diamondback': 'Diamondback',
'glados': 'GLaDOS',
'hal': 'HAL',
'locutus': 'Locutus',
'lore': 'Lore',
'macos-dev': 'macOS-Dev',
'neuromancer': 'Neuromancer',
'sex-robot': 'Sex-Robot',
'shodan': 'Shodan',
'six': 'Six',
'skynet': 'Skynet',
'smith': 'Smith',
'sovereign': 'Sovereign',
'supremo': 'Supremo',
'unicron': 'Unicron',
},
}
if __name__ == '__main__': if __name__ == '__main__':
print("This file is not meant to be called directly.") print("This file is not meant to be called directly.")

View file

@ -3,13 +3,14 @@
import atexit import atexit
import logging import logging
import socket import pathlib
import time import time
import mariadb import mariadb
from wk import std from wk import std
from wk.cfg.osticket import SQL, STAFF, TEST_STATIONS from wk.cfg.hw import TESTSTATION_FILE
from wk.cfg.osticket import SQL, STAFF
# STATIC_VARIABLES # STATIC_VARIABLES
@ -388,23 +389,17 @@ class osTicket(): # pylint: disable=invalid-name
# Functions # Functions
def get_test_station_name(): def get_test_station_name():
"""Get test station name from hostname, returns str. """Get test station name, returns str."""
hostname_file = pathlib.Path(TESTSTATION_FILE)
NOTES: This is quite broad and may include false-positives. # Bail early
If not a test station then an empty string is returned. if not hostname_file.exists():
""" return ''
hostname = socket.getfqdn() if not hostname_file.read_text(encoding='utf-8'):
return ''
# Check if this is a test station
if TEST_STATIONS['Domain'] in hostname:
hostname = hostname.replace(TEST_STATIONS['Domain'], '')
if hostname.lower() in TEST_STATIONS['Known Names']:
hostname = TEST_STATIONS['Known Names'][hostname.lower()]
else:
hostname = ''
# Done # Done
return hostname return hostname_file.read_text(encoding='utf-8').splitlines()[0]
def pad_with_dots(text, pad_right=False): def pad_with_dots(text, pad_right=False):