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


Python hackathon.RequiredFeature类代码示例

本文整理汇总了Python中hackathon.RequiredFeature的典型用法代码示例。如果您正苦于以下问题:Python RequiredFeature类的具体用法?Python RequiredFeature怎么用?Python RequiredFeature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: get_local_pem_url

 def get_local_pem_url(self, pem_url):
     local_pem_url = self.CERT_BASE + "/" + pem_url.split("/")[-1]
     if not isfile(local_pem_url):
         self.log.debug("Recover local %s.pem file from azure storage %s" % (local_pem_url, pem_url))
         cryptor = RequiredFeature("cryptor")
         cryptor.recover_local_file(pem_url, local_pem_url)
     return local_pem_url
开发者ID:qianliwg,项目名称:open-hackathon,代码行数:7,代码来源:azure_cert_manager.py

示例2: upload_files

    def upload_files(self):
        """Handle uploaded files from http request"""
        self.__validate_upload_files()

        images = []
        storage = RequiredFeature("storage")
        for file_name in request.files:
            file_storage = request.files[file_name]
            self.log.debug("upload image file : " + file_name)
            context = Context(
                hackathon_name=g.hackathon.name,
                file_name=file_storage.filename,
                file_type=FILE_TYPE.HACK_IMAGE,
                content=file_storage
            )
            context = storage.save(context)
            image = {
                "name": file_storage.filename,
                "url": context.url,
                "thumbnailUrl": context.url,
                "deleteUrl": '/api/admin/file?key=' + context.file_name
            }
            # context.file_name is a random name created by server, file.filename is the original name
            images.append(image)

        return {"files": images}
开发者ID:rapidhere,项目名称:open-hackathon,代码行数:26,代码来源:hackathon_manager.py

示例3: is_pre_allocate_enabled

def is_pre_allocate_enabled(hackathon):
    if hackathon.status != HACK_STATUS.ONLINE:
        return False

    hack_manager = RequiredFeature("hackathon_manager")
    value = hack_manager.get_basic_property(hackathon, HACKATHON_BASIC_INFO.PRE_ALLOCATE_ENABLED, "1")
    return util.str2bool(value)
开发者ID:vitan,项目名称:open-hackathon,代码行数:7,代码来源:hackathon_manager.py

示例4: get_network_config

    def get_network_config(self, azure_key_id, update):
        """
        Return None if image type is vm and not update
        Public endpoint should be assigned in real time
        :param service:
        :return:
        """
        azure_service = RequiredFeature("azure_service")

        if self.is_vm_image() and not update:
            return None
        cs = self.virtual_environment[self.T_CLOUD_SERVICE]
        nc = self.virtual_environment[self.T_NETWORK_CONFIG]
        network_config = ConfigurationSet()
        network_config.configuration_set_type = nc[self.T_CONFIGURATION_SET_TYPE]
        input_endpoints = nc[self.T_INPUT_ENDPOINTS]
        # avoid duplicate endpoint under same cloud service
        assigned_endpoints = azure_service.get_assigned_endpoints(azure_key_id, cs[self.SERVICE_NAME])
        endpoints = map(lambda i: i[self.T_LOCAL_PORT], input_endpoints)
        unassigned_endpoints = map(str, find_unassigned_endpoints(endpoints, assigned_endpoints))
        map(lambda (i, u): i.update({self.PORT: u}), zip(input_endpoints, unassigned_endpoints))
        for input_endpoint in input_endpoints:
            network_config.input_endpoints.input_endpoints.append(
                ConfigurationSetInputEndpoint(
                    input_endpoint[self.NAME],
                    input_endpoint[self.PROTOCOL],
                    input_endpoint[self.PORT],
                    input_endpoint[self.T_LOCAL_PORT]
                )
            )
        return network_config
开发者ID:mshubian,项目名称:open-hackathon,代码行数:31,代码来源:vm_template_unit.py

示例5: upload_files

    def upload_files(self, user_id, file_type):
        """Handle uploaded files from http request"""
        try:
            self.__validate_upload_files()
        except Exception as e:
            self.log.error(e)
            return bad_request("file size or file type unsupport")

        file_list = []
        storage = RequiredFeature("storage")
        for file in request.files:
            file_content = request.files[file]
            pre_file_name = file_content.filename
            file_suffix = pre_file_name[pre_file_name.rfind('.'):]
            new_file_name = self.__generate_file_name(user_id, file_type, file_suffix)
            self.log.debug("upload file: " + new_file_name)
            context = Context(
                file_name=new_file_name,
                file_type=file_type,
                content=file_content
            )
            context = storage.save(context)

            # file_name is a random name created by server, pre_file_name is the original name
            file_info = {
                "file_name": new_file_name,
                "pre_file_name": pre_file_name,
                "url": context.url
            }
            file_list.append(file_info)
        return {"files": file_list}
开发者ID:RangeForce,项目名称:open-hackathon,代码行数:31,代码来源:user_manager.py

示例6: stop_expr

    def stop_expr(self, expr_id, force=0):
        """
        :param expr_id: experiment id
        :param force: 0: only stop container and release ports, 1: force stop and delete container and release ports.
        :return:
        """
        self.log.debug("begin to stop %d" % expr_id)
        expr = self.db.find_first_object_by(Experiment, id=expr_id, status=EStatus.RUNNING)
        if expr is not None:
            # Docker
            if expr.template.provider == VE_PROVIDER.DOCKER:
                # stop containers
                for c in expr.virtual_environments.all():
                    try:
                        self.log.debug("begin to stop %s" % c.name)
                        docker = self.__get_docker(expr.hackathon, c)
                        if force:
                            docker.delete(c.name, virtual_environment=c, container=c.container, expr_id=expr_id)
                            c.status = VEStatus.DELETED
                        else:
                            docker.stop(c.name, virtual_environment=c, container=c.container, expr_id=expr_id)
                            c.status = VEStatus.STOPPED
                    except Exception as e:
                        self.log.error(e)
                        self.__roll_back(expr_id)
                        return internal_server_error('Failed stop/delete container')
                if force:
                    expr.status = EStatus.DELETED
                else:
                    expr.status = EStatus.STOPPED
                self.db.commit()
            else:
                try:
                    # todo support delete azure vm
                    hosted_docker = RequiredFeature("hosted_docker")
                    af = AzureFormation(hosted_docker.load_azure_key_id(expr_id))
                    af.stop(expr_id, AVMStatus.STOPPED_DEALLOCATED)
                except Exception as e:
                    self.log.error(e)
                    return internal_server_error('Failed stopping azure')

            self.log.debug("experiment %d ended success" % expr_id)
            return ok('OK')
        else:
            return ok()
开发者ID:IdearHui,项目名称:open-hackathon,代码行数:45,代码来源:expr_mgr.py

示例7: upload_files

    def upload_files(self):
        status, return_info = self.validate_args()
        if not status:
            return return_info

        image_container_name = self.util.safe_get_config("storage.image_container", "images")
        images = []
        storage = RequiredFeature("storage")
        for file_name in request.files:
            file = request.files[file_name]
            self.log.debug("upload image file : " + file_name)
            context = Context(
                hackathon_name=g.hackathon.name,
                file_name=file.filename,
                file_type=FILE_TYPE.HACK_IMAGE,
                content=file
            )
            context = storage.save(context)
            image = {}
            image['name'] = file.filename
            image['url'] = context.url
            image['thumbnailUrl'] = context.url
            # context.file_name is a random name created by server, file.filename is the original name
            image['deleteUrl'] = '/api/admin/file?key=' + context.file_name
            images.append(image)

        # for file_name in request.files:
        # file = request.files[file_name]
        # real_name = self.generate_file_name(file)
        #     self.log.debug("upload image file : " + real_name)
        #
        #     url = self.file_service.upload_file_to_azure(file, image_container_name, real_name)
        #     if url is not None:
        #         image = {}
        #         image['name'] = file.filename
        #         image['url'] = url
        #         # frontUI components needed return values
        #         image['thumbnailUrl'] = url
        #         image['deleteUrl'] = '/api/file?key=' + real_name
        #         images.append(image)
        #     else:
        #         return internal_server_error("upload file failed")

        return {"files": images}
开发者ID:mshubian,项目名称:open-hackathon,代码行数:44,代码来源:hackathon_manager.py

示例8: HostedDockerHealthCheck

class HostedDockerHealthCheck(HealthCheck):
    """Report status of hostdd docker

    see more on docker/hosted_docker.py
    """

    def __init__(self):
        self.hosted_docker = RequiredFeature("hosted_docker_proxy")

    def report_health(self):
        return self.hosted_docker.report_health()
开发者ID:msopentechcn,项目名称:open-hackathon,代码行数:11,代码来源:health_check.py

示例9: AlaudaDockerHealthCheck

class AlaudaDockerHealthCheck(HealthCheck):
    """Report status of Alauda service

    see more on docker/alauda_docker.py
    """

    def __init__(self):
        self.alauda_docker = RequiredFeature("alauda_docker")

    def report_health(self):
        return self.alauda_docker.report_health()
开发者ID:ifhuang,项目名称:open-hackathon,代码行数:11,代码来源:health_check.py

示例10: __init__

 def __init__(self):
     self.hosted_docker = RequiredFeature("hosted_docker")
     self.alauda_docker = RequiredFeature("alauda_docker")
开发者ID:ifhuang,项目名称:open-hackathon,代码行数:3,代码来源:health_check.py

示例11: get_basic_property

def get_basic_property(hackathon, property_name, default_value=None):
    hack_manager = RequiredFeature("hackathon_manager")
    return hack_manager.get_basic_property(hackathon, property_name, default_value)
开发者ID:yongxu74,项目名称:open-hackathon,代码行数:3,代码来源:hackathon_manager.py

示例12: is_auto_approve

def is_auto_approve(hackathon):
    hack_manager = RequiredFeature("hackathon_manager")
    value = hack_manager.get_basic_property(hackathon, HACKATHON_CONFIG.AUTO_APPROVE, "1")
    return util.str2bool(value)
开发者ID:yongxu74,项目名称:open-hackathon,代码行数:4,代码来源:hackathon_manager.py

示例13: is_alauda_enabled

def is_alauda_enabled(hackathon):
    hack_manager = RequiredFeature("hackathon_manager")
    value = hack_manager.get_basic_property(hackathon, HACKATHON_BASIC_INFO.ALAUDA_ENABLED, "0")
    return util.str2bool(value)
开发者ID:vitan,项目名称:open-hackathon,代码行数:4,代码来源:hackathon_manager.py

示例14: is_alauda_enabled

def is_alauda_enabled(hackathon):
    hack_manager = RequiredFeature("hackathon_manager")
    return hack_manager.is_alauda_enabled(hackathon)
开发者ID:mshubian,项目名称:open-hackathon,代码行数:3,代码来源:hackathon_manager.py

示例15: get_pre_allocate_number

def get_pre_allocate_number(hackathon):
    hack_manager = RequiredFeature("hackathon_manager")
    return hack_manager.get_pre_allocate_number(hackathon)
开发者ID:mshubian,项目名称:open-hackathon,代码行数:3,代码来源:hackathon_manager.py


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