mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Wrap windows related imports in a try/except to properly handle module loading.
This commit is contained in:
parent
0d3218ec2b
commit
5715e30c38
@ -7,15 +7,22 @@ NOTE: This currently only works with local user accounts, not domain accounts
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
from salt._compat import string_types
|
||||
|
||||
try:
|
||||
import win32net
|
||||
import win32netcon
|
||||
HAS_WIN32NET_MODS = True
|
||||
except ImportError:
|
||||
HAS_WIN32NET_MODS = False
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Set the user module if the kernel is Windows
|
||||
'''
|
||||
return 'user' if salt.utils.is_windows() else False
|
||||
if HAS_WIN32NET_MODS is True and salt.utils.is_windows():
|
||||
return 'user'
|
||||
return False
|
||||
|
||||
|
||||
def add(name,
|
||||
@ -151,6 +158,7 @@ def chprofile(name, profile):
|
||||
return post_info['profile'] == profile
|
||||
return False
|
||||
|
||||
|
||||
def chfullname(name, fullname):
|
||||
'''
|
||||
Change the full name of the user
|
||||
@ -302,6 +310,7 @@ def getent():
|
||||
__context__['user.getent'] = ret
|
||||
return ret
|
||||
|
||||
|
||||
def list_users():
|
||||
'''
|
||||
Return a list of users on Windows
|
||||
|
Loading…
Reference in New Issue
Block a user