mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #49434 from dwoz/cleanup_exception_handling
Clean up exception handling on py3
This commit is contained in:
commit
03d97507f6
@ -303,7 +303,7 @@ def shutdown(message=None, timeout=5, force_close=True, reboot=False, # pylint:
|
||||
force_close, reboot)
|
||||
return True
|
||||
except pywintypes.error as exc:
|
||||
(number, context, message) = exc
|
||||
(number, context, message) = exc.args
|
||||
log.error('Failed to shutdown the system')
|
||||
log.error('nbr: {0}'.format(number))
|
||||
log.error('ctx: {0}'.format(context))
|
||||
@ -346,7 +346,7 @@ def shutdown_abort():
|
||||
win32api.AbortSystemShutdown('127.0.0.1')
|
||||
return True
|
||||
except pywintypes.error as exc:
|
||||
(number, context, message) = exc
|
||||
(number, context, message) = exc.args
|
||||
log.error('Failed to abort system shutdown')
|
||||
log.error('nbr: {0}'.format(number))
|
||||
log.error('ctx: {0}'.format(context))
|
||||
@ -485,7 +485,7 @@ def set_computer_desc(desc=None):
|
||||
try:
|
||||
win32net.NetServerSetInfo(None, 101, system_info)
|
||||
except win32net.error as exc:
|
||||
(number, context, message) = exc
|
||||
(number, context, message) = exc.args
|
||||
log.error('Failed to update system')
|
||||
log.error('nbr: {0}'.format(number))
|
||||
log.error('ctx: {0}'.format(context))
|
||||
@ -1016,7 +1016,7 @@ def set_system_date_time(years=None,
|
||||
try:
|
||||
date_time = win32api.GetLocalTime()
|
||||
except win32api.error as exc:
|
||||
(number, context, message) = exc
|
||||
(number, context, message) = exc.args
|
||||
log.error('Failed to get local time')
|
||||
log.error('nbr: {0}'.format(number))
|
||||
log.error('ctx: {0}'.format(context))
|
||||
|
@ -164,7 +164,6 @@ def add(name,
|
||||
try:
|
||||
win32net.NetUserAdd(None, 1, user_info)
|
||||
except win32net.error as exc:
|
||||
(number, context, message) = exc
|
||||
log.error('Failed to create user {0}'.format(name))
|
||||
log.error('nbr: {0}'.format(exc.winerror))
|
||||
log.error('ctx: {0}'.format(exc.funcname))
|
||||
@ -266,7 +265,6 @@ def update(name,
|
||||
try:
|
||||
user_info = win32net.NetUserGetInfo(None, name, 4)
|
||||
except win32net.error as exc:
|
||||
(number, context, message) = exc
|
||||
log.error('Failed to update user {0}'.format(name))
|
||||
log.error('nbr: {0}'.format(exc.winerror))
|
||||
log.error('ctx: {0}'.format(exc.funcname))
|
||||
@ -326,7 +324,6 @@ def update(name,
|
||||
try:
|
||||
win32net.NetUserSetInfo(None, name, 4, user_info)
|
||||
except win32net.error as exc:
|
||||
(number, context, message) = exc
|
||||
log.error('Failed to update user {0}'.format(name))
|
||||
log.error('nbr: {0}'.format(exc.winerror))
|
||||
log.error('ctx: {0}'.format(exc.funcname))
|
||||
@ -415,7 +412,7 @@ def delete(name,
|
||||
sid = getUserSid(name)
|
||||
win32profile.DeleteProfile(sid)
|
||||
except pywintypes.error as exc:
|
||||
(number, context, message) = exc
|
||||
(number, context, message) = exc.args
|
||||
if number == 2: # Profile Folder Not Found
|
||||
pass
|
||||
else:
|
||||
@ -429,7 +426,6 @@ def delete(name,
|
||||
try:
|
||||
win32net.NetUserDel(None, name)
|
||||
except win32net.error as exc:
|
||||
(number, context, message) = exc
|
||||
log.error('Failed to delete user {0}'.format(name))
|
||||
log.error('nbr: {0}'.format(exc.winerror))
|
||||
log.error('ctx: {0}'.format(exc.funcname))
|
||||
|
@ -268,8 +268,8 @@ class UseraddModuleTestWindows(ModuleCase):
|
||||
self._add_group()
|
||||
self.run_function('user.addgroup', [self.user_name, self.group_name])
|
||||
self.assertIn(self.group_name, self.run_function('user.list_groups', [self.user_name]))
|
||||
self.run_function('user.removegroup', [self.group_name])
|
||||
self.assertIn(self.group_name, self.run_function('user.list_groups', [self.user_name]))
|
||||
self.run_function('user.removegroup', [self.user_name, self.group_name])
|
||||
self.assertNotIn(self.group_name, self.run_function('user.list_groups', [self.user_name]))
|
||||
|
||||
def test_user_rename(self):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user