1212# language governing permissions and limitations under the License.
1313"""Add S3 specific event streaming output arg."""
1414
15- import os
16-
1715from awscli .arguments import CustomArgument
1816
1917STREAM_HELP_TEXT = 'Filename where the records will be saved'
@@ -61,7 +59,8 @@ def replace_event_stream_docs(help_command, **kwargs):
6159 # This should never happen, but in the rare case that it does
6260 # we should be raising something with a helpful error message.
6361 raise DocSectionNotFoundError (
64- f'Could not find the "output" section for the command: { help_command } '
62+ 'Could not find the "output" section for the command: %s'
63+ % help_command
6564 )
6665 doc .write ('======\n Output\n ======\n ' )
6766 doc .write (
@@ -99,7 +98,7 @@ class S3SelectStreamOutputArgument(CustomArgument):
9998 _DOCUMENT_AS_REQUIRED = True
10099
101100 def __init__ (self , stream_key , session , ** kwargs ):
102- super ().__init__ (** kwargs )
101+ super (S3SelectStreamOutputArgument , self ).__init__ (** kwargs )
103102 # This is the key in the response body where we can find the
104103 # streamed contents.
105104 self ._stream_key = stream_key
@@ -121,11 +120,7 @@ def save_file(self, parsed, **kwargs):
121120 if self ._stream_key not in parsed :
122121 return
123122 event_stream = parsed [self ._stream_key ]
124- fd = os .open (
125- self ._output_file , os .O_WRONLY | os .O_CREAT | os .O_TRUNC , 0o600
126- )
127- os .chmod (self ._output_file , 0o600 )
128- with os .fdopen (fd , 'wb' ) as fp :
123+ with open (self ._output_file , 'wb' ) as fp :
129124 for event in event_stream :
130125 if 'Records' in event :
131126 fp .write (event ['Records' ]['Payload' ])
0 commit comments