本文整理汇总了Python中azure.storage.Entity.cost方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.cost方法的具体用法?Python Entity.cost怎么用?Python Entity.cost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.storage.Entity
的用法示例。
在下文中一共展示了Entity.cost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveApplication
# 需要导入模块: from azure.storage import Entity [as 别名]
# 或者: from azure.storage.Entity import cost [as 别名]
def saveApplication(application):
app = Entity()
app.PartitionKey = application['partition'] #uiquely identifies a partition of entities
app.RowKey = str(next(unique_sequence))
# app.RowKey = "kjlhajkdlhfjhasdnfasdkjflnasdf"
app.package_type = application['apptype']
app.name = application['name']
app.reigon = application['reigon']
app.port = str(services.get_port())
app.priority = priority
app.requests = str(0)
app.cost = str(0)
user = user_services.get_user_by_email(application['partition']) #get the current user
if user is not None:
app_count = int(user.app_count) #get app count an convert to int
try:
if app_count >= 0 : #if there is a valid amount of apps
ts.insert_entity(table,app) #add new app
print "new app created"
app_count+=1 #increase the count
user.app_count = str(app_count) #convert count back to str
if user_services.update_user(application['partition'], user): #update the user count
print "user app count updated"
print "notifying that a new app was created..."
temp = {
"partition" : app.PartitionKey,
"rowkey" : app.RowKey,
"package_type" : app.package_type,
"status" : "created"
}
notifying.notify_client("http://146.148.74.93:3000/update_package", temp)
print " success"
return app_count
else :
return -1
# return True
except Exception, e:
return -1