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


Python Utility.compress方法代码示例

本文整理汇总了Python中utility.Utility.compress方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.compress方法的具体用法?Python Utility.compress怎么用?Python Utility.compress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utility.Utility的用法示例。


在下文中一共展示了Utility.compress方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getsegmentation

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import compress [as 别名]
    def getsegmentation(self, imageId, projectId, segTime):
        data = []
        # if no new segmentation, just return nothing
        if not self.has_new_segmentation(imageId, projectId, segTime):
            return Utility.compress(data)

        path = 'resources/output/%s.%s.seg'%(imageId,projectId)
        data = []
        # Settings.addPredictionImage( projectId, imageId)
        if os.path.isfile( path ):
            with open(path, 'r') as content_file:
                compressed = content_file.read()
                decompressed = zlib.decompress(compressed)
                data = base64.b64decode(decompressed)
        return Utility.compress(data)
开发者ID:Rhoana,项目名称:icon,代码行数:17,代码来源:annotationhandler.py

示例2: getuuid

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import compress [as 别名]
    def getuuid(self, projectId, imageId, guid):
        data = {}
        project = DB.getProject( projectId )
        task = DB.getImage( projectId, imageId )

        expiration = project.syncTime*4

        if task.annotationLockId == guid:
            data['uuid'] = DB.lockImage( projectId, imageId )
            now = datetime.now()
            annotationTime = datetime.strptime(task.annotationTime, '%Y-%m-%d %H:%M:%S')
            diff = now - annotationTime
            print 'diff: ', diff.total_seconds()
        elif task.annotationStatus == 1:
            now = datetime.now()
            annotationTime = datetime.strptime(task.annotationTime, '%Y-%m-%d %H:%M:%S')
            diff = now - annotationTime
            diff = diff.total_seconds()
            print 'time diff:', diff
            if diff > expiration:
                data['uuid'] = DB.lockImage( projectId, imageId )
        else:
            data['uuid'] = DB.lockImage( projectId, imageId )

        return Utility.compress(json.dumps( data ))
开发者ID:thouis,项目名称:icon,代码行数:27,代码来源:annotationhandler.py

示例3: getstatus

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import compress [as 别名]
 def getstatus(self, imageId, projectId, guid, segTime):
     # make sure this image prioritize for segmentation
     DB.requestSegmentation( projectId, imageId )
     task = DB.getImage(projectId, imageId);
     data = {}
     data['image'] = task.toJson()
     data['project'] = DB.getProject(projectId).toJson()
     data['has_new_segmentation'] = self.has_new_segmentation(imageId, projectId, segTime)
     return Utility.compress(json.dumps( data ))
开发者ID:Rhoana,项目名称:icon,代码行数:11,代码来源:annotationhandler.py

示例4: getLabels

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import compress [as 别名]
 def getLabels(self, imageId, projectId):
     path = 'resources/labels/%s.%s.json'%(imageId,projectId)
     content = '[]'
     try:
         with open(path, 'r') as content_file:
             content = content_file.read()
     except:
         pass
     return Utility.compress(content)
开发者ID:Rhoana,项目名称:icon,代码行数:11,代码来源:annotationhandler.py

示例5: getProjectEditData

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import compress [as 别名]
 def getProjectEditData(self, projectId ):
     print 'project.getProjectEditData ', projectId
     project = DB.getProject( projectId )
     project = None if project is None else project.toJson()
     data = {}
     data['project'] = project
     data['images'] = Utility.getImages( Paths.TrainGrayscale )
     data['validation_images'] = Utility.getImages( Paths.ValidGrayscale )
     data['projectnames'] = DB.getProjectNames()
     data = json.dumps( data )
     return Utility.compress( data )
开发者ID:Rhoana,项目名称:icon,代码行数:13,代码来源:projecthandler.py

示例6: get

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import compress [as 别名]
    def get(self):
        print ('-->ProjectHandler.get...' + self.request.uri)
        tokens = self.request.uri.split(".")
        print tokens

        if len(tokens) > 1 and tokens[1] == 'getprojects':
            #self.render( self.getimages() )
            print 'ProjectHandler.getting projects...'
            self.set_header('Content-Type', 'text')
            projects = json.dumps(DB.getProjects())
            self.write(Utility.compress( projects ))
        elif len(tokens) > 2 and tokens[1] == 'getproject':
            #self.render( self.getimages() )
            print 'ProjectHandler.getting project...'
            self.set_header('Content-Type', 'text')
            projects = json.dumps(DB.getProject( tokens[2] ).toJson() )
            self.write(Utility.compress( projects ))
        elif len(tokens) > 2 and tokens[1] == 'getprojecteditdata':
            #self.render( self.getimages() )
            print 'ProjectHandler.getprojecteditdata...'
            self.set_header('Content-Type', 'text')
            self.write(self.getProjectEditData( tokens[2] ))
        else:
            self.render("project.html")
开发者ID:Rhoana,项目名称:icon,代码行数:26,代码来源:projecthandler.py

示例7: getAnnotations

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import compress [as 别名]
    def getAnnotations(self, imageId, projectId):

        path = 'resources/labels/%s.%s.json'%(imageId,projectId)
        # check the incoming folder first before to ensure
        # the most latest data is being referenced.
        path_incoming = 'resources/incoming/%s.%s.json'%(imageId,projectId)
        path = path_incoming if os.path.exists(path_incoming) else path

        #default to the labels template
        content = '[]'
        try:
            with open(path, 'r') as content_file:
                content = content_file.read()
        except:
            pass

        return Utility.compress(content)
开发者ID:Rhoana,项目名称:icon,代码行数:19,代码来源:annotationhandler.py

示例8: getProjectsData

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import compress [as 别名]
    def getProjectsData(self, projectId):
        print 'browse.getProjectEditData'

	project          = DB.getProject( projectId )
        data             = {}
        data['names']    = DB.getProjectNames()

        if project == None and len(data['names']) > 0:
		project  = DB.getProject( data['names'][0] )

	active           = DB.getActiveProject()
        data['project']  = project.toJson()
	#DB.getProject( projectId ).toJson()
        #data['images']   = [ i.toJson() for i in DB.getImages( projectId ) ]
        #data['offline']  = DB.getOfflinePerformance( projectId )
	#data['online']   = DB.getOnlinePerformance( projectId )
	#data['baseline'] = DB.getBaselinePerformance( projectId )
	data['active']   = active.toJson() if active is not None else {}

        return Utility.compress( json.dumps( data ) )
开发者ID:thouis,项目名称:icon,代码行数:22,代码来源:browserhandler.py


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