本文整理汇总了Python中twisted.python.usage.Options.get方法的典型用法代码示例。如果您正苦于以下问题:Python Options.get方法的具体用法?Python Options.get怎么用?Python Options.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.python.usage.Options
的用法示例。
在下文中一共展示了Options.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initializeDB
# 需要导入模块: from twisted.python.usage import Options [as 别名]
# 或者: from twisted.python.usage.Options import get [as 别名]
def initializeDB(Store: store.Store, options: usage.Options):
username = options.get('username')
password = options.get('password')
employees = commandFinder(Store)("Check For New Employees").doCheckForEmployees()
for emp in employees:
un = runWithConnection(findUsername, username, password, args=(emp, options))
if un:
emp.active_directory_name = un
示例2: findUsername
# 需要导入模块: from twisted.python.usage import Options [as 别名]
# 或者: from twisted.python.usage.Options import get [as 别名]
def findUsername(conn, emp: IEmployee, options: usage.Options) -> str:
ise = ISolomonEmployee(emp)
name = ise.name
if '~' in name:
name = name.split('~')
ln = name[0]
fn = name[1].split()[0]
else:
name = name.split()
fn = name[0]
ln = name[-1]
if conn.search('dc=ugm, dc=local', '(&(givenName=%s) (sn=%s))' % (fn, ln), attributes=['sAMAccountName']):
if len(conn.response) == 4 and 'attributes' in conn.response[0]:
if conn.response[0]['attributes']['sAMAccountName']:
return conn.response[0]['attributes']['sAMAccountName'][0]
if options.get('resolve'):
print("AD username not found for %s, searching by last name only" % ise.name)
if conn.search('dc=ugm, dc=local', '(&(givenName=*) (sn=%s))' % (ln,), attributes=['sAMAccountName',
'givenName',
'sn']):
while len(conn.response) > 3:
resp = conn.response.pop(0)
if 'attributes' not in resp:
break
print("Possible match found")
print("FN:", resp['attributes']['givenName'])
print("LN:", resp['attributes']['sn'])
if 'Y' in input("Is this a match? (yN)").upper():
return resp['attributes']['sAMAccountName'][0]
if options.get('resolve') == 'firstname':
print("AD username not found, searching by first name only")
if conn.search('dc=ugm, dc=local', '(&(givenName=%s) (sn=*))' % (fn,),
attributes=['sAMAccountName', 'givenName', 'sn']):
while len(conn.response) > 3:
resp = conn.response.pop(0)
if 'attributes' not in resp:
break
print("Possible match found")
print("FN:", resp['attributes']['givenName'])
print("LN:", resp['attributes']['sn'])
if 'Y' in input("Is this a match? (yN)").upper():
return resp['attributes']['sAMAccountName'][0]