Last active
March 22, 2016 14:14
-
-
Save scottfrazer/f8fe3cee0881c424212f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class ExecutableTempFile: | |
def __init__(self, someFile): | |
self.theFile= someFile | |
def __enter__(self): | |
self.transLog= SecureLog( self.theFile ) | |
return self.transLog | |
def __exit__( self, type, value, tb ): | |
if type is not None: | |
pass # Exception occurred | |
self.transLog.finalize() | |
self.transLog.close() | |
self.theFile.close() | |
contents = "foobar" | |
with ExecutableTempFile(contents) as path: | |
subprocess.check_call("sh " + path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment