本文整理汇总了Python中models.package.Package.lookup方法的典型用法代码示例。如果您正苦于以下问题:Python Package.lookup方法的具体用法?Python Package.lookup怎么用?Python Package.lookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.package.Package
的用法示例。
在下文中一共展示了Package.lookup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import lookup [as 别名]
def post(self):
p = Package()
p._id = self.get_argument('package_name')
package = Package.lookup(p._id)
p.avail_timelong = int(self.get_argument('avail_timelong', package['avail_timelong']))
p.avail_begintime = int(self.get_argument("avail_begintime", package['avail_begintime']))
p.avail_endtime = int(self.get_argument("avail_endtime1", package['avail_endtime']))
#p.avail_begintime = datetime.datetime.strptime(avail_begintime+':00', "%H:%M")
#p.avail_endtime = datetime.datetime.strptime(avail_endtime+':00',"%H:%M")
'''
p.pname = self.get_argument('package_name')
p.avail_timelong = int(self.get_argument('avail_timelong'))
p.avail_begintime = datetime.datetime.strptime(self.get_argument("avail_begintime"), "%H:%M")
p.avail_endtime = datetime.datetime.strptime(self.get_argument("avail_endtime"), "%H:%M")
avail_beginhourstr = self.get_argument("avail_begintime", None)
nPos1 =avail_beginhourstr.index(':')
avail_beginhour = int(avail_beginhourstr[0:nPos1])
avail_endhourstr = self.get_argument("avail_endtime", None)
nPos2 =avail_endhourstr.index(':')
avail_endhour = int(avail_endhourstr[0:nPos2])
if avail_endhour <= avail_beginhour:
p.effective_length = avail_endhour+24 - avail_beginhour
else:
p.effective_length = avail_endhour - avail_beginhour
'''
p.is_weekday= int(self.get_argument("is_weekday", package['is_weekday']))
p.created_at = datetime.datetime.now()
Package.updatePackage(p)
self.redirect("/get_packages")
示例2: main
# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import lookup [as 别名]
def main():
from models.product import Product
from models.order import Order
from models.package import Package
# from views.paginator import Paginator
from models.exchange import Exchange
#
# from datetime import datetime
# start = datetime(2010, 4, 1)
# end = datetime(2015, 5, 1)
#
for exchange in Exchange.get_status_exchanges(1):
need_do = []
orders = Order.get_working_orders(1, exchange["_id"])
for order in orders:
print order["custom_time"]
product = Product.lookup(order["p_id"])
exchange = Exchange.get_exchange(order["e_id"])
package = Package.lookup(order["package_id"])
# need_do = need_do + json.dumps({'switch_name':exchange['ename'],'port':product['port'], 'bandwidth':order['bandwidth'], \
# 'port_name':product['port'], 'ipAddress':exchange['ipAddress'],'o_id':order['_id'] })
need_do.append(
json.dumps(
{
"switch_name": exchange["ename"],
"port": product["port"],
"port_name": product["port"],
"host": exchange["ipAddress"],
"bandwidth": order["bandwidth"],
}
)
)
if len(need_do) > 0:
cmd = json.dumps({"switch_name": exchange["ename"], "host": exchange["ipAddress"], "orders": need_do})
# print cmd
print len(cmd)
print cmd
print "-----------"
keys = json.loads(cmd)
print keys["host"]
print keys["orders"]
##################################################
# if read(key_file):
# keys = json.loads(encrypt_util.decode(body))
if 1 == 1:
keys = json.loads(cmd)
host = keys["host"]
username, password = json.loads(read(key_file))[host] # here is the switch address
values = keys["orders"]
switch_name = keys["switch_name"]
###################################################################
# switch_name = keys['switch_name']
# port_name = keys['port_name']
# bandwidth = keys['bandwidth']
# vlan = keys['vlan']
response = do_command(switch_name, host, username, password, values)
示例3:
# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import lookup [as 别名]
# -*- coding: utf-8 -*-