Skip to content

Commit

Permalink
import StringIO and pass data through StringIO read (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
Keimille authored Apr 13, 2023
1 parent 3afb563 commit 843ffe9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion grafana_backup/s3_download.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import boto3
from botocore.exceptions import NoCredentialsError, ClientError
import StringIO


def main(args, settings):
Expand All @@ -22,7 +23,8 @@ def main(args, settings):

try:
# .read() left off on purpose, tarfile.open() takes care of that part
s3_data = s3_object.get()["Body"]
s3_data_raw = s3_object.get()["Body"]
s3_data = StringIO.StringIO(s3_data_raw.read())
print("Download from S3 was successful")
except ClientError as e:
if e.response["Error"]["Code"] == "NoSuchKey":
Expand Down

1 comment on commit 843ffe9

@spyder007
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't stringIO gone in python3??
from https://docs.python.org/3.0/whatsnew/3.0.html

The StringIO and cStringIO modules are gone. Instead, import the io module and use io.StringIO or io.BytesIO for text and data respectively.

Please sign in to comment.