本文整理汇总了Python中AccessControl.getToken方法的典型用法代码示例。如果您正苦于以下问题:Python AccessControl.getToken方法的具体用法?Python AccessControl.getToken怎么用?Python AccessControl.getToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AccessControl
的用法示例。
在下文中一共展示了AccessControl.getToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Initial_Script_Data
# 需要导入模块: import AccessControl [as 别名]
# 或者: from AccessControl import getToken [as 别名]
def Initial_Script_Data(log):
"""Initialize configuration settings from 'config.txt' that resides inside same directory as python script:
1) Defined code of Complexity issues
2) Defined Project Manager role
3) Grouping - default is "off"
4) Klocwork server address
5) Klocwork server port
6) User with sufficient permissions to run the script - default is currently logged in user"""
from os import path
from sys import executable
ServerData = {}
'''If run from Python shell/not from PyInstaller executable, replace "path.dirname(executable)" with "path.dirname(__file__) in this function'''
with open(path.dirname(__file__)+'\\'+'config.txt','r') as config:
for line in config:
temp_line = line.split('=', 1)
if len(temp_line) > 2:
exit("Config file syntax is incorrect!")
else:
ServerData[temp_line[0]] = temp_line[1].replace('\n','')
if ServerData["KW_SERVER"] is '':
ServerData["KW_SERVER"] = "localhost"
if ServerData["KW_SERVER_PORT"] is '':
ServerData["KW_SERVER_PORT"] = "8080"
if ServerData["USER"] is '':
ServerData["USER"] = getpass.getuser()
if ServerData["Grouping"] is '':
ServerData["Grouping"] = "off"
if ServerData["FILE_PATH"] is '':
ServerData["FILE_PATH"] = path.dirname(__file__)
if ServerData["FILE_NAME"] is '':
import time
ServerData["FILE_NAME"] = time.strftime("%d.%m.%y", time.localtime())
url = "http://%s:%s/review/api" % (ServerData["KW_SERVER"], ServerData["KW_SERVER_PORT"])
ServerData["url"] = url
print("Server configurations are:")
print("KW_SERVER: %s" %ServerData["KW_SERVER"])
print("KW_SERVER_PORt: %s" %ServerData["KW_SERVER_PORT"])
print("USER: %s" %ServerData["USER"])
print("FILE_PATH: %s" %ServerData["FILE_PATH"])
print("FILE_NAME: %s" %ServerData["FILE_NAME"])
print("ComplexityCode: %s" %ServerData["ComplexityCode"])
print("ManagerRole: %s" %ServerData["ManagerRole"])
print("Grouping: %s" %ServerData["Grouping"])
log.write("Server configurations are:")
log.write("KW_SERVER: %s" %ServerData["KW_SERVER"])
log.write("KW_SERVER_PORt: %s" %ServerData["KW_SERVER_PORT"])
log.write("USER: %s" %ServerData["USER"])
log.write("FILE_PATH: %s" %ServerData["FILE_PATH"])
log.write("FILE_NAME: %s" %ServerData["FILE_NAME"])
log.write("ComplexityCode: %s" %ServerData["ComplexityCode"])
log.write("ManagerRole: %s" %ServerData["ManagerRole"])
log.write("Grouping: %s" %ServerData["Grouping"])
values = {"user": ServerData["USER"]}
loginToken = AccessControl.getToken(ServerData["KW_SERVER"], ServerData["KW_SERVER_PORT"], ServerData["USER"])
if loginToken is not None:
values["ltoken"] = loginToken
else:
return None
return ServerData, values