本文整理汇总了Python中version.VERSION属性的典型用法代码示例。如果您正苦于以下问题:Python version.VERSION属性的具体用法?Python version.VERSION怎么用?Python version.VERSION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类version
的用法示例。
在下文中一共展示了version.VERSION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def main():
logger.info('VLC Scheduler v%s started.' % version.VERSION)
if sys.platform == 'win32':
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(main_coro())
except Exception as e:
if config.DEBUG:
logger.fatal(traceback.format_exc())
else:
logger.fatal(str(e))
finally:
loop.close()
logger.info('VLC Scheduler stopped.')
示例2: get_workbook_id
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def get_workbook_id(server, auth_token, user_id, site_id, workbook_name):
"""
Gets the id of the desired workbook to relocate.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
'user_id' ID of the user with access to workbooks
'site_id' ID of the site that the user is signed into
'workbook_name' name of workbook to get ID of
Returns the workbook id and the project id that contains the workbook.
"""
url = server + "/api/{0}/sites/{1}/users/{2}/workbooks".format(VERSION, site_id, user_id)
server_response = requests.get(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 200)
xml_response = ET.fromstring(_encode_for_display(server_response.text))
workbooks = xml_response.findall('.//t:workbook', namespaces=xmlns)
for workbook in workbooks:
if workbook.get('name') == workbook_name:
return workbook.get('id')
error = "Workbook named '{0}' not found.".format(workbook_name)
raise LookupError(error)
示例3: get_workbook_id
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def get_workbook_id(server, auth_token, user_id, site_id, workbook_name):
"""
Gets the id of the desired workbook to relocate.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
'user_id' ID of user with access to workbooks
'site_id' ID of the site that the user is signed into
'workbook_name' name of workbook to get ID of
Returns the workbook id and the project id that contains the workbook.
"""
url = server + "/api/{0}/sites/{1}/users/{2}/workbooks".format(VERSION, site_id, user_id)
server_response = requests.get(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 200)
xml_response = ET.fromstring(_encode_for_display(server_response.text))
# Find all workbooks in the site and look for the desired one
workbooks = xml_response.findall('.//t:workbook', namespaces=xmlns)
for workbook in workbooks:
if workbook.get('name') == workbook_name:
return workbook.get('id')
error = "Workbook named '{0}' not found.".format(workbook_name)
raise LookupError(error)
示例4: get_user_id
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def get_user_id(server, auth_token, site_id, username_to_audit):
"""
Returns the user id of the user to audit permissions for, if found.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
'site_id' ID of the site that the user is signed into
'username_to_audit' username to audit permission for on server
"""
url = server + "/api/{0}/sites/{1}/users".format(VERSION, site_id)
server_response = requests.get(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 200)
server_response = ET.fromstring(_encode_for_display(server_response.text))
# Find all user tags in the response and look for matching id
users = server_response.findall('.//t:user', namespaces=xmlns)
for user in users:
if user.get('name') == username_to_audit:
return user.get('id')
error = "User id for {0} not found".format(username_to_audit)
raise LookupError(error)
示例5: delete_permission
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def delete_permission(server, auth_token, site_id, workbook_id, user_id, permission_name, existing_mode):
"""
Deletes a specific permission from the workbook.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
'site_id' ID of the site that the user is signed into
'workbook_id' ID of workbook to audit permission in
'user_id' ID of the user to audit
'permission_name' name of permission to add or update
'existing_mode' is the mode of the permission already set for the workbook
"""
url = server + "/api/{0}/sites/{1}/workbooks/{2}/permissions/users/{3}/{4}/{5}".format(VERSION,
site_id,
workbook_id,
user_id,
permission_name,
existing_mode)
server_response = requests.delete(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 204)
return
示例6: get_users_in_group
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def get_users_in_group(server, auth_token, site_id, group_id, page_size, page_number):
"""
Get all the users in the group using group id
GET /api/api-version/sites/site-id/groups/group-id/users
GET /api/api-version/sites/site-id/groups/group-id/users?pageSize=page-size&pageNumber=page-number
"""
if page_size == 0:
url = server + "/api/{0}/sites/{1}/groups/{2}/users".format(VERSION, site_id, group_id)
else:
url = server + "/api/{0}/sites/{1}/groups/{2}/users?pageSize={3}&pageNumber={4}".format(VERSION, site_id, group_id, page_size, page_number)
server_response = requests.get(url, headers={'x-tableau-auth': auth_token})
#_check_status(server_response, 200)
xml_response = ET.fromstring(_encode_for_display(server_response.text))
users = xml_response.findall('.//t:user', namespaces=XMLNS)
return users
示例7: get_workbook_id
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def get_workbook_id(server, auth_token, user_id, site_id, workbook_name):
"""
Gets the id of the desired workbook to relocate.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
'user_id' ID of user with access to workbook
'site_id' ID of the site that the user is signed into
'workbook_name' name of workbook to get ID of
Returns the workbook id and the project id that contains the workbook.
"""
url = server + "/api/{0}/sites/{1}/users/{2}/workbooks".format(VERSION, site_id, user_id)
server_response = requests.get(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 200)
xml_response = ET.fromstring(_encode_for_display(server_response.text))
workbooks = xml_response.findall('.//t:workbook', namespaces=xmlns)
for workbook in workbooks:
if workbook.get('name') == workbook_name:
return workbook.get('id')
error = "Workbook named '{0}' not found.".format(workbook_name)
raise LookupError(error)
示例8: delete_workbook
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def delete_workbook(server, auth_token, site_id, workbook_id, workbook_filename):
"""
Deletes the temp workbook file, and workbook from the source project.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
'site_id' ID of the site that the user is signed into
'workbook_id' ID of workbook to delete
'workbook_filename' filename of temp workbook file to delete
"""
# Builds the request to delete workbook from the source project on server
url = server + "/api/{0}/sites/{1}/workbooks/{2}".format(VERSION, site_id, workbook_id)
server_response = requests.delete(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 204)
# Remove the temp file created for the download
os.remove(workbook_filename)
示例9: get_workbook_id
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def get_workbook_id(server, auth_token, user_id, site_id, workbook_name):
"""
Gets the id of the desired workbook to relocate.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
'user_id' ID of user with access to workbook
'site_id' ID of the site that the user is signed into
'workbook_name' name of workbook to get ID of
Returns the workbook id and the project id that contains the workbook.
"""
url = server + "/api/{0}/sites/{1}/users/{2}/workbooks".format(VERSION, site_id, user_id)
server_response = requests.get(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 200)
xml_response = ET.fromstring(_encode_for_display(server_response.text))
workbooks = xml_response.findall('.//t:workbook', namespaces=xmlns)
for workbook in workbooks:
if workbook.get('name') == workbook_name:
source_project_id = workbook.find('.//t:project', namespaces=xmlns).get('id')
return source_project_id, workbook.get('id')
error = "Workbook named '{0}' not found.".format(workbook_name)
raise LookupError(error)
示例10: get_user_id
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def get_user_id(server, auth_token, site_id, username_to_update):
"""
Returns the user id of the user to update permissions for, if found.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
'site_id' ID of the site that the user is signed into
'username_to_update' username to update permission for on server
"""
url = server + "/api/{0}/sites/{1}/users".format(VERSION, site_id)
server_response = requests.get(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 200)
server_response = ET.fromstring(_encode_for_display(server_response.text))
# Find all user tags in the response and look for matching id
users = server_response.findall('.//t:user', namespaces=xmlns)
for user in users:
if user.get('name') == username_to_update:
return user.get('id')
error = "User id for {0} not found".format(username_to_update)
raise LookupError(error)
示例11: get_workbooks
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def get_workbooks(server, auth_token, user_id, site_id):
"""
Queries all existing workbooks on the current site.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
'user_id' ID of user with access to workbooks
'site_id' ID of the site that the user is signed into
Returns tuples for each workbook, containing its id and name.
"""
url = server + "/api/{0}/sites/{1}/users/{2}/workbooks".format(VERSION, site_id, user_id)
server_response = requests.get(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 200)
server_response = ET.fromstring(_encode_for_display(server_response.text))
# Find all workbook ids
workbook_tags = server_response.findall('.//t:workbook', namespaces=xmlns)
# Tuples to store each workbook information:(workbook_id, workbook_name)
workbooks = [(workbook.get('id'), workbook.get('name')) for workbook in workbook_tags]
if len(workbooks) == 0:
error = "No workbooks found on this site"
raise LookupError(error)
return workbooks
示例12: query_permission
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def query_permission(server, auth_token, site_id, workbook_id, user_id):
"""
Returns a list of all permissions for the specified user.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
'site_id' ID of the site that the user is signed into
'workbook_id' ID of workbook to update permission in
'user_id' ID of the user to update
"""
url = server + "/api/{0}/sites/{1}/workbooks/{2}/permissions".format(VERSION, site_id, workbook_id)
server_response = requests.get(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 200)
server_response = _encode_for_display(server_response.text)
# Reads and parses the response
parsed_response = ET.fromstring(server_response)
# Find all the capabilities for a specific user
capabilities = parsed_response.findall('.//t:granteeCapabilities', namespaces=xmlns)
for capability in capabilities:
user = capability.find('.//t:user', namespaces=xmlns)
if user is not None and user.get('id') == user_id:
return capability.findall('.//t:capability', namespaces=xmlns)
return None
示例13: delete_permission
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def delete_permission(server, auth_token, site_id, workbook_id, user_id, permission_name, existing_mode):
"""
Deletes a specific permission from the workbook.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
'site_id' ID of the site that the user is signed into
'workbook_id' ID of workbook to update permission in
'user_id' ID of the user to update
'permission_name' name of permission to update
'existing_mode' is the existing mode for the permission
"""
url = server + "/api/{0}/sites/{1}/workbooks/{2}/permissions/users/{3}/{4}/{5}".format(VERSION,
site_id,
workbook_id,
user_id,
permission_name,
existing_mode)
print("\tDeleting existing permission")
server_response = requests.delete(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 204)
return
示例14: sign_in
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def sign_in(server, username, password, site=""):
"""
Signs in to the server specified with the given credentials
'server' specified server address
'username' is the name (not ID) of the user to sign in as.
Note that most of the functions in this example require that the user
have server administrator permissions.
'password' is the password for the user.
'site' is the ID (as a string) of the site on the server to sign in to. The
default is "", which signs in to the default site.
Returns the authentication token and the site ID.
"""
url = server + "/api/{0}/auth/signin".format(VERSION)
# Builds the request
xml_request = ET.Element('tsRequest')
credentials_element = ET.SubElement(xml_request, 'credentials', name=username, password=password)
ET.SubElement(credentials_element, 'site', contentUrl=site)
xml_request = ET.tostring(xml_request)
# Make the request to server
server_response = requests.post(url, data=xml_request)
_check_status(server_response, 200)
# ASCII encode server response to enable displaying to console
server_response = _encode_for_display(server_response.text)
# Reads and parses the response
parsed_response = ET.fromstring(server_response)
# Gets the auth token and site ID
token = parsed_response.find('t:credentials', namespaces=xmlns).get('token')
site_id = parsed_response.find('.//t:site', namespaces=xmlns).get('id')
user_id = parsed_response.find('.//t:user', namespaces=xmlns).get('id')
return token, site_id, user_id
示例15: sign_out
# 需要导入模块: import version [as 别名]
# 或者: from version import VERSION [as 别名]
def sign_out(server, auth_token):
"""
Destroys the active session and invalidates authentication token.
'server' specified server address
'auth_token' authentication token that grants user access to API calls
"""
url = server + "/api/{0}/auth/signout".format(VERSION)
server_response = requests.post(url, headers={'x-tableau-auth': auth_token})
_check_status(server_response, 204)
return