mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-01-05 05:17:52 +03:00
util/util.py
Line: 1 pylint: missing-module-docstring / Missing module docstring Line: 18 pylint: unused-import / Unused import logging Line: 23 pep8: E302 / expected 2 blank lines, found 1 (col 1) Line: 29 pep8: E302 / expected 2 blank lines, found 1 (col 1) Line: 35 pep8: E302 / expected 2 blank lines, found 1 (col 1) Line: 45 pep8: E302 / expected 2 blank lines, found 1 (col 1) Line: 51 pep8: E302 / expected 2 blank lines, found 1 (col 1) Other fixes: ------------ In .pylintrc excluded problems: missing-module-docstring
This commit is contained in:
parent
c1cd77d114
commit
f09685ee72
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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():
|
||||
|
Loading…
Reference in New Issue
Block a user