1818 log .error (e )
1919 sys .exit (1 )
2020
21+ if 'SENZING_ENGINE_CONFIGURATION_JSON' not in os .environ :
22+ log .error ('SENZING_ENGINE_CONFIGURATION_JSON environment variable required.' )
23+ sys .exit (1 )
2124SZ_CONFIG = json .loads (os .environ ['SENZING_ENGINE_CONFIGURATION_JSON' ])
22- S3_BUCKET = 'sqs-senzing-local-export'
25+
26+ if 'S3_BUCKET_NAME' not in os .environ :
27+ log .error ('S3_BUCKET_NAME environment variable required.' )
28+ sys .exit (1 )
29+ S3_BUCKET_NAME = os .environ ['S3_BUCKET_NAME' ]
30+
2331EXPORT_FLAGS = sz .SzEngineFlags .SZ_EXPORT_DEFAULT_FLAGS
2432
2533#-------------------------------------------------------------------------------
@@ -31,7 +39,7 @@ def ts():
3139def make_s3_client ():
3240 try :
3341 sess = boto3 .Session ()
34- if 'AWS_ENDPOINT_URL' in os .environ :
42+ if 'AWS_ENDPOINT_URL' in os .environ :
3543 return sess .client ('s3' , endpoint_url = os .environ ['AWS_ENDPOINT_URL' ])
3644 else :
3745 return sess .client ('s3' )
@@ -104,8 +112,8 @@ def go():
104112 fname = 'output-' + ts () + '.json'
105113 log .info (AWS_TAG + 'About to upload JSON file ' + fname + ' to S3 ...' )
106114 try :
107- s3 .upload_fileobj (buff , S3_BUCKET , fname )
108- log .info (AWS_TAG + 'Successfully upload file.' )
115+ s3 .upload_fileobj (buff , S3_BUCKET_NAME , fname )
116+ log .info (AWS_TAG + 'Successfully uploaded file.' )
109117 except Exception as e :
110118 log .error (AWS_TAG + str (e ))
111119
@@ -121,22 +129,22 @@ def main():
121129if __name__ == '__main__' : main ()
122130
123131#-------------------------------------------------------------------------------
124- # test funcs
132+ # ad-hoc test funcs - might move later
125133
126- def upload_test_file_to_s3 ():
134+ def _upload_test_file_to_s3 ():
127135 print ("Starting test upload to S3 ..." )
128136 s3 = make_s3_client ()
129137 print (s3 )
130138 fname = 'hemingway.txt'
131- resp = s3 .upload_file (fname , S3_BUCKET , fname )
139+ resp = s3 .upload_file (fname , S3_BUCKET_NAME , fname )
132140 print (resp )
133141 print ('Upload successful.' )
134142
135- def get_file_from_s3 (key ):
136- '''Get from from S3 and write to /tmp (use docker-compose to map this
143+ def _get_file_from_s3 (key ):
144+ '''Get file from S3 and write to /tmp (use docker-compose to map this
137145 to desired directory on host machine).'''
138146 print ('Grabbing file...' )
139147 s3 = make_s3_client ()
140- resp = s3 .download_file (S3_BUCKET , key , '/tmp/' + key )
148+ resp = s3 .download_file (S3_BUCKET_NAME , key , '/tmp/' + key )
141149 print (resp )
142150 print ('Done.' )
0 commit comments