本文整理汇总了Python中utils.Utils.timestamp_datetime_to_str方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.timestamp_datetime_to_str方法的具体用法?Python Utils.timestamp_datetime_to_str怎么用?Python Utils.timestamp_datetime_to_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Utils
的用法示例。
在下文中一共展示了Utils.timestamp_datetime_to_str方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: availableimages
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import timestamp_datetime_to_str [as 别名]
def availableimages(self, camid=None, start=None, end=None):
"""
/availableimages?camid=X&start=Y&end=Z
Get the images within the provided range, only for the specified camid
is one is provided.
"""
if start == None or start == "":
start = Utils.timestamp_datetime_to_str(datetime(1970, 1, 1))
if end == None or end == "":
end = Utils.timestamp_datetime_to_str(datetime.now())
try:
if camid == None or camid == "":
imgtups = self.db.get_images_for_range(start, end)
else:
imgtups = self.db.get_images_for_range_camid(camid, start, end)
return {"imgurls": self.package_images(imgtups)}
except:
return {"imgurls": []}
示例2: get_most_recent_images
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import timestamp_datetime_to_str [as 别名]
def get_most_recent_images( self, limit ):
'''
Get a list of the most recent images, up to the specified limit.
Returns a list of tuples (camid, timestamp).
'''
session = self.Session()
imgs = []
for row in session.query( Image ).\
order_by( Image.timestamp )[:limit]:
imgs.append( (row.camid, Utils.timestamp_datetime_to_str( row.timestamp ) ) )
return imgs
示例3: multiupload
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import timestamp_datetime_to_str [as 别名]
def multiupload( self, camid=0, rotate=0, length=[] ):
'''
/multiupload?camid=X&rotate=Y&length=Z1&length=Z2&...&length=Zn
Inserts metadata about the uploaded image into the DB and saves the
image to disk.
Returns a JSON struct containing the camids and timestamps necessary to
access the images once they've been post-processed and made available
through the web server.
'''
content_length = cherrypy.request.headers['Content-Length']
content_type = cherrypy.request.headers['Content-Type']
raw = cherrypy.request.body.read( int( content_length ) )
if self.db.get_desc_for_camid( camid ) == None:
return { 'camids' : [], 'timestamps' : [] }
if type( length ) != type( [] ):
length = [length, ]
if content_type == 'image/jpeg':
now = datetime.now()
delta = timedelta( microseconds=1 )
camids = []
timestamps = []
for img_len in length:
img_len = int( img_len )
img = raw[:img_len]
raw = raw[img_len:]
timestamp = Utils.timestamp_datetime_to_str( now )
self.queue.put( (content_type, camid, timestamp, rotate, img) )
camids.append( camid )
timestamps.append( timestamp )
now += delta
return { 'camids' : camids, 'timestamps' : timestamps }
return { 'camids' : [], 'timestamps' : [] }
示例4: get_images_for_range_camid
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import timestamp_datetime_to_str [as 别名]
def get_images_for_range_camid( self, camid, start, end ):
'''
Get a list of the images between timestamps start and end for the
provided camid. List of tuples (camid, timestamp).
'''
session = self.Session()
start = Utils.timestamp_str_to_datetime( start )
end = Utils.timestamp_str_to_datetime( end )
imgs = []
for row in session.query( Image ).\
filter( Image.camid==camid).\
filter( Image.timestamp > start ).\
filter( Image.timestamp < end ).\
order_by( Image.timestamp ):
imgs.append( (row.camid, Utils.timestamp_datetime_to_str( row.timestamp ) ) )
return imgs