当前位置: 首页>>代码示例>>Python>>正文


Python Utils.timestamp_datetime_to_str方法代码示例

本文整理汇总了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": []}
开发者ID:kadler15,项目名称:surveillance,代码行数:25,代码来源:webserver.py

示例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
开发者ID:kadler15,项目名称:surveillance,代码行数:17,代码来源:database.py

示例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' : [] }
开发者ID:kadler15,项目名称:surveillance,代码行数:46,代码来源:mediaserver.py

示例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
开发者ID:kadler15,项目名称:surveillance,代码行数:22,代码来源:database.py


注:本文中的utils.Utils.timestamp_datetime_to_str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。