Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced StringIO with tempfile #1

Merged
merged 1 commit into from
Oct 28, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bakthat.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import tarfile
import tempfile
import os
import sys
import ConfigParser
from datetime import datetime
from cStringIO import StringIO
from getpass import getpass
import logging

Expand Down Expand Up @@ -66,7 +66,7 @@ def download(self, keyname):
k = Key(self.bucket)
k.key = keyname

encrypted_out = StringIO()
encrypted_out = tempfile.TemporaryFile()
k.get_contents_to_file(encrypted_out)
encrypted_out.seek(0)

Expand Down Expand Up @@ -214,7 +214,7 @@ def download(self, keyname):

if job.completed:
self.logger.info("Downloading...")
encrypted_out = StringIO()
encrypted_out = tempfile.TemporaryFile()
encrypted_out.write(job.get_output().read())
encrypted_out.seek(0)
return encrypted_out
Expand Down Expand Up @@ -242,7 +242,7 @@ def backup(filename, destination="s3", **kwargs):
log.info("Backing up " + filename)
arcname = filename.split("/")[-1]

out = StringIO()
out = tempfile.TemporaryFile()
with tarfile.open(fileobj=out, mode="w:gz") as tar:
tar.add(filename, arcname=arcname)

Expand Down Expand Up @@ -298,7 +298,7 @@ def restore(filename, destination="s3", **kwargs):
if not password:
password = getpass()

out = StringIO()
out = tempfile.TemporaryFile()
decrypt(encrypted_out, out, password)
out.seek(0)

Expand Down