PageRenderTime 102ms CodeModel.GetById 60ms app.highlight 3ms RepoModel.GetById 38ms app.codeStats 0ms

/silverlining/mgr-scripts/save-tmp-file.py

https://bitbucket.org/ianb/silverlining/
Python | 28 lines | 22 code | 4 blank | 2 comment | 1 complexity | b1bf0ee0834546fd3ddbf87ed03b8fc1 MD5 | raw file
 1#!/usr/bin/env python
 2import sys
 3sys.path.insert(0, '/usr/local/share/silverlining/lib')
 4import os
 5import optparse
 6import zipfile
 7import warnings
 8from cStringIO import StringIO
 9
10parser = optparse.OptionParser(
11    usage="%prog < zip")
12
13def main():
14    options, args = parser.parse_args()
15    with warnings.catch_warnings():
16        # I don't care if it is theoretically insecure
17        warnings.simplefilter("ignore")
18        location = os.tempnam(None, 'save-tmp-files-')
19    os.mkdir(location)
20    input = StringIO(sys.stdin.read())
21    zip = zipfile.ZipFile(input, 'r')
22    zip.extractall(location)
23    zip.close()
24    print 'tmp="%s"' % location
25
26if __name__ == '__main__':
27    main()
28