v1.7.1 - Another World (bugfix)

* Avoid crash when running Install SW Bundle outside d7II
* Avoid rare crash when working with NVMe disks
* Avoid replacing osTicket disk checkbox FAILED values
This commit is contained in:
2Shirt 2019-01-15 23:07:08 -07:00
commit e86b06b84d
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
4 changed files with 62 additions and 8 deletions

View file

@ -435,9 +435,17 @@ class DiskObj():
# Check for attributes # Check for attributes
if KEY_NVME in self.smartctl: if KEY_NVME in self.smartctl:
self.nvme_attributes = { self.nvme_attributes = {}
k: {'name': k, 'raw': int(v), 'raw_str': str(v)} for k, v in self.smartctl[KEY_NVME].items():
for k, v in self.smartctl[KEY_NVME].items()} try:
self.nvme_attributes[k] = {
'name': k,
'raw': int(v),
'raw_str': str(v),
}
except Exception:
# TODO: Limit this check
pass
elif KEY_SMART in self.smartctl: elif KEY_SMART in self.smartctl:
for a in self.smartctl[KEY_SMART].get('table', {}): for a in self.smartctl[KEY_SMART].get('table', {}):
try: try:
@ -1101,7 +1109,7 @@ def run_hw_tests(state):
show_results(state) show_results(state)
# Post disk results # Post disk results
if not state.ost.disabled: if _disk_tests_enabled and state.disks and not state.ost.disabled:
print_standard('Posting results to osTicket...') print_standard('Posting results to osTicket...')
for disk in state.disks: for disk in state.disks:
state.ost.post_device_results(disk, state.ticket_id) state.ost.post_device_results(disk, state.ticket_id)

View file

@ -344,6 +344,38 @@ class osTicket():
return type_str return type_str
def get_flag(self, ticket_id, flag_name):
"""Get flag in osTicket."""
flag_value = None
self.connect(silent=True)
# Bail if disabled
if self.disabled:
return
# Build SQL cmd
sql_cmd = "SELECT `{column}` FROM `{Name}`.`{Ticket}`".format(
column=flag_name,
**OSTICKET['Database'],
**OSTICKET['Tables'])
sql_cmd += "WHERE `{Ticket}`.`ticket_id` = {ticket_id}".format(
ticket_id=ticket_id,
**OSTICKET['Tables'])
sql_cmd += ";"
# Run SQL cmd and get value
try:
self.db_cursor.execute(sql_cmd)
for s in self.db_cursor:
flag_value = s[0]
except mariadb.errors.Error:
# Set self.errors to enable warning line on results screen
self.errors = True
# Done
self.disconnect()
return flag_value
def get_ticket_name(self, ticket_id): def get_ticket_name(self, ticket_id):
"""Lookup ticket and return name as str.""" """Lookup ticket and return name as str."""
name = None name = None
@ -451,6 +483,14 @@ class osTicket():
def set_disk_passed(self, ticket_id): def set_disk_passed(self, ticket_id):
"""Mark disk as passed in osTicket.""" """Mark disk as passed in osTicket."""
current_value = self.get_flag(ticket_id, OSTICKET['Disk Flag']['Name'])
# Bail early?
if current_value == OSTICKET['Disk Flag']['Fail']:
print_warning('Not replacing osTicket disk checkbox FAILED value')
return
# Current value != FAILED, set to passed
self.set_flag( self.set_flag(
ticket_id, ticket_id,
OSTICKET['Disk Flag']['Name'], OSTICKET['Disk Flag']['Name'],
@ -458,7 +498,7 @@ class osTicket():
def set_flag(self, ticket_id, flag_name, flag_value): def set_flag(self, ticket_id, flag_name, flag_value):
"""Set flag in osTicket.""" """Set flag in osTicket."""
self.connect() self.connect(silent=True)
# Bail if disabled # Bail if disabled
if self.disabled: if self.disabled:

View file

@ -35,6 +35,8 @@ if __name__ == '__main__':
if answer_ninite and global_vars['OS']['Version'] in ['7']: if answer_ninite and global_vars['OS']['Version'] in ['7']:
# Vista is dead, not going to check for it # Vista is dead, not going to check for it
answer_mse = ask('Install MSE?') answer_mse = ask('Install MSE?')
else:
answer_mse = False
print_info('Installing Programs') print_info('Installing Programs')
if answer_vcr: if answer_vcr:

View file

@ -54,11 +54,15 @@ endif
" 2Shirt Stuff " 2Shirt Stuff
set autoindent " align the new line indent with the previous line set autoindent " align the new line indent with the previous line
set expandtab " insert spaces when hitting TABs set expandtab " insert spaces when hitting TABs
set nowrap " I'd rather manually wrap than manually unwrap
set shiftround " round indent to multiple of 'shiftwidth' set shiftround " round indent to multiple of 'shiftwidth'
set shiftwidth=4 " operation >> indents 4 columns; << unindents 4 columns set shiftwidth=2 " operation >> indents 2 columns; << unindents 2 columns
set softtabstop=4 " insert/delete 4 spaces when hitting a TAB/BACKSPACE set softtabstop=2 " insert/delete 2 spaces when hitting a TAB/BACKSPACE
set tabstop=4 " an hard TAB displays as 4 columns set tabstop=2 " an hard TAB displays as 2 columns
" Python Stuff. " Python Stuff.
au FileType python set textwidth=79 " lines longer than 79 columns will be broken au FileType python set textwidth=79 " lines longer than 79 columns will be broken
" Do wrap stuff
au FileType text set wrap