diff --git a/gpoa/.pylintrc b/gpoa/.pylintrc index 43a2f95..9cd836e 100644 --- a/gpoa/.pylintrc +++ b/gpoa/.pylintrc @@ -134,7 +134,10 @@ disable=print-statement, deprecated-sys-function, exception-escape, comprehension-escape, - trailing-newlines + trailing-newlines, + missing-function-docstring, + missing-class-docstring, + missing-module-docstring # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/gpoa/util/util.py b/gpoa/util/util.py index 6da33ca..e9dbf90 100644 --- a/gpoa/util/util.py +++ b/gpoa/util/util.py @@ -15,23 +15,26 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import logging + import socket import os import pwd + def get_machine_name(): ''' Get localhost name looking like DC0$ ''' return socket.gethostname().split('.', 1)[0].upper() + "$" + def is_machine_name(name): ''' Check if supplied username is machine name in fact. ''' return name == get_machine_name() + def traverse_dir(root_dir): ''' Recursively fetch all files from directory and its subdirectories. @@ -42,12 +45,14 @@ def traverse_dir(root_dir): filelist.append(os.path.join(root, filename)) return filelist + def get_homedir(username): ''' Query password database for user's home directory. ''' return pwd.getpwnam(username).pw_dir + def mk_homedir_path(username, homedir_path): ''' Create subdirectory in user's $HOME. diff --git a/gpoa/util/windows.py b/gpoa/util/windows.py index 44f1759..290a79d 100644 --- a/gpoa/util/windows.py +++ b/gpoa/util/windows.py @@ -14,7 +14,9 @@ # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + '''Dummy module docstring''' + import logging import os @@ -31,7 +33,9 @@ from .xdg import get_user_dir from .util import get_homedir from .logging import slogm + class smbcreds: + def __init__(self, dc_fqdn=None): self.parser = optparse.OptionParser('GPO Applier') self.sambaopts = options.SambaOptions(self.parser) @@ -53,9 +57,11 @@ class smbcreds: samba_dc = get_dc_hostname(self.creds, self.lp) if samba_dc != dc_fqdn and dc_fqdn != None: + logging.debug( - slogm('Samba DC setting is {} and is overwritten by user setting {}'.format( - samba_dc, dc))) + slogm('Samba DC setting is {} and is overwritten by user setting {}'.format( + samba_dc, dc))) + self.selected_dc = dc_fqdn else: self.selected_dc = samba_dc @@ -101,8 +107,9 @@ class smbcreds: logging.info(slogm('GPO: {} ({})'.format(gpo.display_name, gpo.name))) except Exception as exc: - logging.error(slogm('Unable to get GPO list for {} from {}'.format( - username, self.selected_dc))) + logging.error( + slogm('Unable to get GPO list for {} from {}'.format( + username, self.selected_dc))) return gpos @@ -112,9 +119,9 @@ class smbcreds: try: check_refresh_gpo_list(self.selected_dc, self.lp, self.creds, gpos) except Exception as exc: - logging.error(slogm('Unable to refresh GPO list for {} from {}'.format( - username, self.selected_dc))) - + logging.error( + slogm('Unable to refresh GPO list for {} from {}'.format( + username, self.selected_dc))) return gpos def _get_prop(self, property_name): @@ -154,7 +161,7 @@ def get_sid(domain, username): except: sid = 'local-{}'.format(username) logging.warning( - slogm('Error getting SID using wbinfo, will use cached SID: {}'.format(sid))) + slogm('Error getting SID using wbinfo, will use cached SID: {}'.format(sid))) logging.debug(slogm('Working with SID: {}'.format(sid))) @@ -178,10 +185,12 @@ def expand_windows_var(text, username=None): if username: variables['HOME'] = get_homedir(username) - variables['DesktopDir'] = get_user_dir('DESKTOP', os.path.join(variables['HOME'], - 'Desktop')) - variables['StartMenuDir'] = os.path.join(variables['HOME'], '.local', 'share', - 'applications') + + variables['DesktopDir'] = get_user_dir( + 'DESKTOP', os.path.join(variables['HOME'], 'Desktop')) + + variables['StartMenuDir'] = os.path.join( + variables['HOME'], '.local', 'share', 'applications') result = text for var in variables.keys():