Created
July 18, 2012 14:59
-
-
Save playpauseandstop/3136704 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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