publish_manifest.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:iconograph 作者: robot-tools 项目源码 文件源码
def main():
  base = os.path.dirname(sys.argv[0])

  unsigned_manifest = os.path.join(FLAGS.image_dir, 'manifest.json.unsigned')
  signed_manifest = os.path.join(FLAGS.image_dir, 'manifest.json')

  with tempfile.NamedTemporaryFile(dir=FLAGS.image_dir, delete=False) as fh:
    try:
      Exec(
          os.path.join(base, 'build_manifest.py'),
          '--default-rollout', str(FLAGS.default_rollout),
          '--image-dir', FLAGS.image_dir,
          '--old-manifest', unsigned_manifest,
          '--max-images', str(FLAGS.max_images),
          stdout=fh)
      os.rename(fh.name, unsigned_manifest)
    except:
      os.unlink(fh.name)
      raise

  with tempfile.NamedTemporaryFile(dir=FLAGS.image_dir, delete=False) as fh, open(unsigned_manifest, 'r') as fh_in:
    try:
      args = [
          os.path.join(base, 'wrap_file.py'),
          '--cert', FLAGS.cert,
          '--key', FLAGS.key,
      ]
      for other_cert in FLAGS.other_certs or []:
        args.extend([
            '--other-cert', other_cert,
        ])
      Exec(
          *args,
          stdin=fh_in,
          stdout=fh)
      os.fchmod(fh.fileno(), 0o644)
      os.rename(fh.name, signed_manifest)
    except:
      os.unlink(fh.name)
      raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号