Commit 3d5599c8 by Ashley Penney

Further fixes to close the ssh connection explictly, make both the

default option if nothing is provided, and not bother passing true
when calling the subcommands.
parent 0555ebc4
...@@ -28,23 +28,21 @@ class Command(BaseCommand): ...@@ -28,23 +28,21 @@ class Command(BaseCommand):
def import_pearson(): def import_pearson():
sftp(settings.PEARSON[SFTP_IMPORT], settings.PEARSON[LOCAL_IMPORT]) sftp(settings.PEARSON[SFTP_IMPORT], settings.PEARSON[LOCAL_IMPORT])
s3(settings.PEARSON[LOCAL_IMPORT], settings.PEARSON[BUCKET]) s3(settings.PEARSON[LOCAL_IMPORT], settings.PEARSON[BUCKET])
call_command('pearson_import', 'dest_from_settings=True') call_command('pearson_import', 'dest_from_settings')
def export_pearson(): def export_pearson():
call_command('pearson_export_ccd', 'dest_from_settings=True') call_command('pearson_export_ccd', 'dest_from_settings')
call_command('pearson_export_ead', 'dest_from_settings=True') call_command('pearson_export_ead', 'dest_from_settings')
sftp(settings.PEARSON[LOCAL_EXPORT], settings.PEARSON[SFTP_EXPORT]) sftp(settings.PEARSON[LOCAL_EXPORT], settings.PEARSON[SFTP_EXPORT])
s3(settings.PEARSON[LOCAL_EXPORT], settings.PEARSON[BUCKET]) s3(settings.PEARSON[LOCAL_EXPORT], settings.PEARSON[BUCKET])
if options['mode'] == 'both': if options['mode'] == 'export':
export_pearson()
import_pearson()
elif options['mode'] == 'export':
export_pearson() export_pearson()
elif options['mode'] == 'import': elif options['mode'] == 'import':
import_pearson() import_pearson()
else: else:
print("ERROR: Mode must be export or import.") export_pearson()
import_pearson()
def sftp(files_from, files_to): def sftp(files_from, files_to):
...@@ -62,6 +60,7 @@ class Command(BaseCommand): ...@@ -62,6 +60,7 @@ class Command(BaseCommand):
for filename in sftp.listdir(files_from): for filename in sftp.listdir(files_from):
sftp.get(files_from+'/'+filename, sftp.get(files_from+'/'+filename,
files_to+'/'+filename) files_to+'/'+filename)
t.close()
except: except:
dog_http_api.event('pearson {0}'.format(mode), dog_http_api.event('pearson {0}'.format(mode),
'sftp uploading failed', alert_type='error') 'sftp uploading failed', alert_type='error')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment