Adjusted osTicket post formatting
This commit is contained in:
parent
aae7c1d543
commit
146244d3fd
1 changed files with 17 additions and 12 deletions
|
|
@ -373,6 +373,16 @@ def osticket_set_drive_result(ticket_id, passed):
|
|||
except:
|
||||
ost_db['Errors'] = True
|
||||
|
||||
def pad_with_dots(s, left_pad=True):
|
||||
"""Replace ' ' padding with '..' for osTicket posts."""
|
||||
s = str(s).replace(' ', '..')
|
||||
if '.' in s:
|
||||
if left_pad:
|
||||
s = '.' + s
|
||||
else:
|
||||
s = s + '.'
|
||||
return s
|
||||
|
||||
def post_drive_results(ticket_number):
|
||||
"""Post drive test results to osTicket."""
|
||||
tested = False
|
||||
|
|
@ -454,22 +464,17 @@ def post_drive_results(ticket_number):
|
|||
for attrib in sorted(ATTRIBUTES['SMART'].keys()):
|
||||
if attrib in s_table:
|
||||
# Pad attributewith dots for osTicket
|
||||
hex_str = '{:>2}'.format(str(hex(int(attrib))).upper()[2:])
|
||||
hex_str = hex_str.replace(' ', '..')
|
||||
if '.' in hex_str:
|
||||
hex_str = '.' + hex_str
|
||||
dec_str = '{:>3}'.format(attrib)
|
||||
dec_str = dec_str.replace(' ', '..')
|
||||
if '.' in dec_str:
|
||||
dec_str = '.' + dec_str
|
||||
report.append('{:>2}/{:>3}: {} {} ({})'.format(
|
||||
hex_str = str(hex(int(attrib))).upper()[2:]
|
||||
hex_str = pad_with_dots('{:>2}'.format(hex_str))
|
||||
dec_str = pad_with_dots('{:>3}'.format(attrib))
|
||||
val_str = '{:<20}'.format(s_table[attrib]['raw']['string'])
|
||||
val_str = pad_with_dots(val_str, left_pad=False)
|
||||
report.append('{:>2}/{:>3}: {} ({})'.format(
|
||||
hex_str,
|
||||
dec_str,
|
||||
s_table[attrib]['raw']['string'],
|
||||
'..'*24+'.',
|
||||
val_str,
|
||||
s_table[attrib]['name'],
|
||||
))
|
||||
report[-1] = report[-1].strip().replace(' ', '.')
|
||||
report[-1] = report[-1].replace('_', ' ')
|
||||
report.append('')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue