Skip to content

Instantly share code, notes, and snippets.

@yejianye
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yejianye/74f69651aa3b009df24b to your computer and use it in GitHub Desktop.
Save yejianye/74f69651aa3b009df24b to your computer and use it in GitHub Desktop.
Auto-evaluate variables in a string, especially useful when writing a shell-scripts in Python
from fabric.api import local
def sh(command, *args, **kwargs):
frame = inspect.currentframe()
ctx = frame.f_back.f_globals.copy()
ctx.update(frame.f_back.f_locals)
command = command.format(**ctx)
del frame
return local(command, *args, **kwargs)
def resign_ipa(uapp_name, unsigned_app, target_dir):
sh('mkdir -p {target_dir}/Payload')
sh('cp -r "{unsigned_app}" {target_dir}/Payload')
sh('rm -rf {target_dir}/{app_name}.app/_CodeSignature')
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment