本文整理汇总了Python中pytas.http.TASClient.allocation_approval方法的典型用法代码示例。如果您正苦于以下问题:Python TASClient.allocation_approval方法的具体用法?Python TASClient.allocation_approval怎么用?Python TASClient.allocation_approval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytas.http.TASClient
的用法示例。
在下文中一共展示了TASClient.allocation_approval方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: approval
# 需要导入模块: from pytas.http import TASClient [as 别名]
# 或者: from pytas.http.TASClient import allocation_approval [as 别名]
#.........这里部分代码省略.........
if data['computeAllocated']:
try:
data['computeAllocated'] = int( data['computeAllocated'] )
except ValueError:
errors['computeAllocated'] = 'Compute Allocated must be a number.'
if data['computeRequested']:
try:
data['computeRequested'] = int( data['computeRequested'] )
except ValueError:
errors['computeRequested'] = 'Compute Requested must be a number.'
if data['storageAllocated']:
try:
data['storageAllocated'] = int( data['storageAllocated'] )
except ValueError:
errors['storageAllocated'] = 'Storage Allocated must be a number.'
if data['storageRequested']:
try:
data['storageRequested'] = int( data['storageRequested'] )
except ValueError:
errors['storageRequested'] = 'Storage Requested must be a number.'
if data['memoryAllocated']:
try:
data['memoryAllocated'] = int( data['memoryAllocated'] )
except ValueError:
errors['memoryAllocated'] = 'Memory Allocated must be a number.'
if data['memoryRequested']:
try:
data['memoryRequested'] = int( data['memoryRequested'] )
except ValueError:
errors['memoryRequested'] = 'Memory Requested must be a number.'
if data['projectId']:
try:
data['projectId'] = int( data['projectId'] )
except ValueError:
errors['projectId'] = 'Project id must be number.'
else:
errors['projectId'] = 'Project id is required.'
if not data['project']:
errors['project'] = 'Project charge code is required.'
if data['reviewerId']:
try:
data['reviewerId'] = int( data['reviewerId'] )
except ValueError:
errors['reviewerId'] = 'Reviewer id must be number.'
else:
errors['reviewerId'] = 'Reviewer id is required.'
if not data['reviewer']:
errors['reviewer'] = 'Reviewer username is required.'
if data['dateRequested']:
try:
validate_datetimestring(data['dateRequested'])
except ValidationError:
errors['dateRequested'] = 'Requested date must be a valid date string e.g. "2015-05-20T05:00:00Z" .'
#else:
# errors['dateRequested'] = 'Requested date is required.'
if data['dateReviewed']:
try:
validate_datestring( data['dateReviewed'] )
except ValidationError:
errors['dateReviewed'] = 'Reviewed date must be a valid date string e.g. "2015-05-20" .'
else:
errors['dateReviewed'] = 'Reviewed date is required.'
if len( errors ) == 0:
# source
data['source'] = 'Chameleon'
# log the request
logger.info( 'Request data passed validation. Calling TAS ...')
try:
resp['result'] = tas.allocation_approval( data['id'], data )
logger.info('Allocation approval TAS response: data=%s', json.dumps(resp['result']))
status = 'success'
except Exception as e:
logger.exception('Error processing allocation approval.')
status = 'error'
errors['message'] = 'An unexpected error occurred. If this problem persists please create a help ticket.'
else:
logger.info( 'Request data failed validation. %s', errors.values())
status = 'error'
else:
status = 'error'
errors['message'] = 'Only POST method allowed.'
resp['status'] = status
resp['errors'] = errors
return HttpResponse(json.dumps(resp), content_type="application/json")