Skip to content

Instantly share code, notes, and snippets.

@playpauseandstop
Created July 18, 2012 14:59
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 playpauseandstop/3136704 to your computer and use it in GitHub Desktop.
Save playpauseandstop/3136704 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
# Redirect outputs from pbs command result to file.
#
import os
import pbs
PATH = os.path.expanduser
def main():
pbs.cd(PATH('~/Projects/deploy-it'))
handler = open(PATH('~/Deploy/deploy-it.zip'), 'wb+')
pbs.git('archive', 'HEAD', format='zip', prefix='deploy-it/', _out=handler)
handler.close()
pbs.cd(PATH('~/Deploy'))
print(pbs.unzip('-x', 'deploy-it.zip'))
pbs.rm('deploy-it.zip')
pbs.rm('-r', 'deploy-it')
handler = open(PATH('~/Deploy/error_log'), 'wb+')
try:
pbs.stat('deploy-it.zip', _err=handler)
except pbs.ErrorReturnCode:
pass
handler.close()
print(pbs.cat('error_log'))
pbs.rm('error_log')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment