Skip to content
This repository has been archived by the owner on Feb 25, 2018. It is now read-only.

Commit

Permalink
got esky support code working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
rfk committed Aug 2, 2010
1 parent 641a2b6 commit 62981df
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions setup.py
@@ -1,6 +1,7 @@
# Copyright (c) 2009-2010, Cloud Matrix Pty. Ltd.
# All rights reserved; available under the terms of the BSD License.

import os
import sys
setup_kwds = {}
if sys.version_info > (3,):
Expand Down
2 changes: 2 additions & 0 deletions signedimp/bootstrap.py
Expand Up @@ -912,6 +912,8 @@ def __init__(self,path=None,base_path=None):
else:
# We're nowhere on sys.path
self.base_path = path
else:
self.base_path = base_path

def _exists(self,*args):
"""Shortcut for checking if a file exists relative to my path."""
Expand Down
8 changes: 8 additions & 0 deletions signedimp/compat/__init__.py
@@ -0,0 +1,8 @@
# Copyright (c) 2009-2010, Cloud Matrix Pty. Ltd.
# All rights reserved; available under the terms of the BSD License.
"""
signedimp.compat: compatability hook for integrating with other packages
"""

17 changes: 12 additions & 5 deletions signedimp/compat/esky.py
Expand Up @@ -13,15 +13,22 @@
import signedimp.tools

def get_bootstrap_code(key):
signedimp_bootstrap = signedimp.tools.get_bootstrap_code()
signedimp_bootstrap = signedimp.tools.get_bootstrap_code(indent=" ")
pubkey = key.get_public_key()
return """
def _make_signedimp_chainload(orig_chainload):
%(signedimp_bootstrap)s
key = %(key)r
def chainload(target_dir):
def _chainload(target_dir):
key = signedimp.%(pubkey)r
manager = signedimp.SignedImportManager([key])
target_exe = pathjoin(target_dir,basename(sys.executable))
target_imp = signedimp.DefaultImporter(target_dir,target_dir)
target_imp = signedimp.SignedLoader(manager,target_imp)
# Calling get_data forces verification of the specfied data file
target_imp.get_data(basename(sys.executable))
orig_chainload(target_dir)
return chainload
chainload = _make_signedimp_chainload(chainload)
return _chainload
_chainload = _make_signedimp_chainload(_chainload)
""" % locals()


5 changes: 2 additions & 3 deletions signedimp/tools.py
Expand Up @@ -85,7 +85,7 @@ def _get_source_lines(mod,indent):
%(indent)s def _signedimp_init():
%(indent)s import imp
%(indent)s signedimp = imp.new_module("signedimp")
%(indent)s %(bscode)s
%(bscode)s
%(indent)s lvars = locals()
%(indent)s for nm in __all__:
%(indent)s setattr(signedimp,nm,lvars[nm])
Expand All @@ -94,8 +94,7 @@ def _get_source_lines(mod,indent):
%(indent)s signedimp._path_is_broken = True
%(indent)s return signedimp
%(indent)s signedimp = sys.modules["signedimp"] = _signedimp_init()
""" % dict(bscode="\n".join(_get_source_lines("signedimp.bootstrap"," "*8)),
indent=indent)
""" % dict(indent=indent,bscode="\n".join(_get_source_lines("signedimp.bootstrap",indent+" "*8)))


def sign_directory(path,key,hash="sha1",outfile=signedimp.HASHFILE_NAME):
Expand Down

0 comments on commit 62981df

Please sign in to comment.