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:
|
except:
|
||||||
ost_db['Errors'] = True
|
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):
|
def post_drive_results(ticket_number):
|
||||||
"""Post drive test results to osTicket."""
|
"""Post drive test results to osTicket."""
|
||||||
tested = False
|
tested = False
|
||||||
|
|
@ -454,22 +464,17 @@ def post_drive_results(ticket_number):
|
||||||
for attrib in sorted(ATTRIBUTES['SMART'].keys()):
|
for attrib in sorted(ATTRIBUTES['SMART'].keys()):
|
||||||
if attrib in s_table:
|
if attrib in s_table:
|
||||||
# Pad attributewith dots for osTicket
|
# Pad attributewith dots for osTicket
|
||||||
hex_str = '{:>2}'.format(str(hex(int(attrib))).upper()[2:])
|
hex_str = str(hex(int(attrib))).upper()[2:]
|
||||||
hex_str = hex_str.replace(' ', '..')
|
hex_str = pad_with_dots('{:>2}'.format(hex_str))
|
||||||
if '.' in hex_str:
|
dec_str = pad_with_dots('{:>3}'.format(attrib))
|
||||||
hex_str = '.' + hex_str
|
val_str = '{:<20}'.format(s_table[attrib]['raw']['string'])
|
||||||
dec_str = '{:>3}'.format(attrib)
|
val_str = pad_with_dots(val_str, left_pad=False)
|
||||||
dec_str = dec_str.replace(' ', '..')
|
report.append('{:>2}/{:>3}: {} ({})'.format(
|
||||||
if '.' in dec_str:
|
|
||||||
dec_str = '.' + dec_str
|
|
||||||
report.append('{:>2}/{:>3}: {} {} ({})'.format(
|
|
||||||
hex_str,
|
hex_str,
|
||||||
dec_str,
|
dec_str,
|
||||||
s_table[attrib]['raw']['string'],
|
val_str,
|
||||||
'..'*24+'.',
|
|
||||||
s_table[attrib]['name'],
|
s_table[attrib]['name'],
|
||||||
))
|
))
|
||||||
report[-1] = report[-1].strip().replace(' ', '.')
|
|
||||||
report[-1] = report[-1].replace('_', ' ')
|
report[-1] = report[-1].replace('_', ' ')
|
||||||
report.append('')
|
report.append('')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue