Moved CRASH_SERVER to wk.cfg.main
This commit is contained in:
parent
1997cdcefd
commit
1829c3b2f3
3 changed files with 18 additions and 21 deletions
|
|
@ -24,6 +24,13 @@ TECH_PASSWORD='Abracadabra'
|
||||||
LINUX_TIME_ZONE='America/Denver' # See 'timedatectl list-timezones' for valid values
|
LINUX_TIME_ZONE='America/Denver' # See 'timedatectl list-timezones' for valid values
|
||||||
WINDOWS_TIME_ZONE='Mountain Standard Time' # See 'tzutil /l' for valid values
|
WINDOWS_TIME_ZONE='Mountain Standard Time' # See 'tzutil /l' for valid values
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
CRASH_SERVER = {
|
||||||
|
#'Name': 'CrashServer',
|
||||||
|
#'Url': '',
|
||||||
|
#'User': '',
|
||||||
|
#'Pass': '',
|
||||||
|
}
|
||||||
|
|
||||||
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.")
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,5 @@
|
||||||
# vim: sts=2 sw=2 ts=2
|
# vim: sts=2 sw=2 ts=2
|
||||||
|
|
||||||
|
|
||||||
# SERVER VARIABLES
|
|
||||||
CRASH_SERVER = {
|
|
||||||
#'Name': 'CrashServer',
|
|
||||||
#'Url': '',
|
|
||||||
#'User': '',
|
|
||||||
#'Pass': '',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
print("This file is not meant to be called directly.")
|
|
||||||
|
|
||||||
# vim: sts=2 sw=2 ts=2
|
|
||||||
|
|
||||||
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.")
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from wk.cfg.main import CRASH_SERVER
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from termios import tcflush, TCIOFLUSH
|
from termios import tcflush, TCIOFLUSH
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
@ -277,14 +279,13 @@ def strip_colors(string):
|
||||||
|
|
||||||
|
|
||||||
def upload_debug_report(report, reason='DEBUG'):
|
def upload_debug_report(report, reason='DEBUG'):
|
||||||
"""Upload debug report to CRASH_SERVER as specified in wk.cfg.net."""
|
"""Upload debug report to CRASH_SERVER as specified in wk.cfg.main."""
|
||||||
import pathlib
|
import pathlib
|
||||||
import requests
|
import requests
|
||||||
from wk.cfg.net import CRASH_SERVER as server
|
LOG.info('Uploading debug report to %s', CRASH_SERVER.get('Name', '?'))
|
||||||
LOG.info('Uploading debug report to %s', server.get('Name', '?'))
|
|
||||||
|
|
||||||
# Check if the required server details are available
|
# Check if the required server details are available
|
||||||
if not all(server.get(key, False) for key in ('Name', 'Url', 'User')):
|
if not all(CRASH_SERVER.get(key, False) for key in ('Name', 'Url', 'User')):
|
||||||
msg = 'Server details missing, aborting upload.'
|
msg = 'Server details missing, aborting upload.'
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
print_error(msg)
|
print_error(msg)
|
||||||
|
|
@ -309,12 +310,15 @@ def upload_debug_report(report, reason='DEBUG'):
|
||||||
LOG.debug('filename: %s', filename)
|
LOG.debug('filename: %s', filename)
|
||||||
|
|
||||||
# Upload report
|
# Upload report
|
||||||
url = '{}/{}'.format(server['Url'], filename)
|
url = '{}/{}'.format(CRASH_SERVER['Url'], filename)
|
||||||
response = requests.put(
|
response = requests.put(
|
||||||
url,
|
url,
|
||||||
data=report,
|
data=report,
|
||||||
headers=server.get('Headers', {'X-Requested-With': 'XMLHttpRequest'}),
|
headers=CRASH_SERVER.get(
|
||||||
auth=(server['User'], server.get('Pass', '')),
|
'Headers',
|
||||||
|
{'X-Requested-With': 'XMLHttpRequest'},
|
||||||
|
),
|
||||||
|
auth=(CRASH_SERVER['User'], CRASH_SERVER.get('Pass', '')),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check response
|
# Check response
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue