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


Python Device.get_central_server方法代码示例

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


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

示例1: verify_inner_zip

# 需要导入模块: from securesync.models import Device [as 别名]
# 或者: from securesync.models.Device import get_central_server [as 别名]
    def verify_inner_zip(self, zip_file):
        """
        Extract contents of outer zip, verify the inner zip
        """
        zip = ZipFile(zip_file, "r")
        nfiles = len(zip.namelist())
        for fi,afile in enumerate(zip.namelist()):
            zip.extract(afile, path=self.working_dir)

        self.signature_file = os.path.join(self.working_dir, Command.signature_filename)
        self.inner_zip_file = os.path.join(self.working_dir, Command.inner_zip_filename)

        central_server = Device.get_central_server()
        lines = open(self.signature_file, "r").read().split("\n")
        chunk_size = int(lines.pop(0))
        if not central_server:
            logging.warn("No central server device object found; trusting zip file because you asked me to...")
        elif central_server.key.verify_large_file(self.inner_zip_file, signature=lines, chunk_size=chunk_size):
            logging.info("Verified file!")
        else:
            raise Exception("Failed to verify inner zip file.")
        return self.inner_zip_file
开发者ID:EconometricsBySimulation,项目名称:ka-lite,代码行数:24,代码来源:update.py

示例2: create_json_file

# 需要导入模块: from securesync.models import Device [as 别名]
# 或者: from securesync.models.Device import get_central_server [as 别名]
        def create_json_file(include_data):
            central_server = Device.get_central_server()
            if not zone_id:
                models = [central_server] if central_server else []

            else:
                # Get a chain of trust to the zone owner.
                #   Because we're on the central server, this will
                #   simply be the central server, but in the future
                #   this would return an actual chain.
                logging.debug("Generating a zone invitation...")
                zone = Zone.objects.get(id=zone_id)
                chain = ChainOfTrust(zone=zone)
                assert chain.validate()
                new_invitation = ZoneInvitation.generate(zone=zone, invited_by=Device.get_own_device())
                new_invitation.save()  # keep a record of the invitation, for future revocation.  Also, signs the thing

                # This ordering of objects is a bit be hokey, but OK--invitation usually must be 
                #   inserted before devicezones--but because it's not pointing to any devices,
                #   it's OK to be at the end.
                # Note that the central server will always be at the front of the chain of trust,
                #   so no need to explicitly include.
                models = chain.objects() + [new_invitation]

                # 
                if include_data:
                    logging.debug("Serializing entire dataset...")
                    devices = Device.objects.by_zone(zone)
                    devicezones = DeviceZone.objects.filter(zone=zone)
                    models += list(devices) + list(devicezones)
                    models += engine.get_models(zone=zone, limit=None)  # get all models on this zone

            models_file = tempfile.mkstemp()[1]
            with open(models_file, "w") as fp:
                fp.write(engine.serialize(models))
            return models_file
开发者ID:AbhiUnni,项目名称:ka-lite,代码行数:38,代码来源:package_for_download.py


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