diff --git a/common/djangoapps/student/management/commands/pearson_export_cdd.py b/common/djangoapps/student/management/commands/pearson_export_cdd.py index c2c13916ab..2655960ff5 100644 --- a/common/djangoapps/student/management/commands/pearson_export_cdd.py +++ b/common/djangoapps/student/management/commands/pearson_export_cdd.py @@ -44,7 +44,7 @@ class Command(BaseCommand): default=False, help='Retrieve the destination to export to from django? True/False'), make_option('--destination', - action='store_true', + action='store', dest='destination', default=None, help='Where to store the exported files') @@ -61,24 +61,22 @@ class Command(BaseCommand): # Name will use timestamp -- this is UTC, so it will look funny, # but it should at least be consistent with the other timestamps # used in the system. - if options['dest-from-settings'] is True: - if settings.PEARSON[LOCAL_EXPORT]: + if 'dest-from-settings' in options: + if LOCAL_EXPORT in settings.PEARSON: dest = settings.PEARSON[LOCAL_EXPORT] else: raise CommandError('--dest-from-settings was enabled but the' 'PEARSON[LOCAL_EXPORT] setting was not set.') - elif options['destination']: + elif 'destination' in options: dest = options['destination'] else: - raise ComamndError('--destination or --dest-from-settings must be used') + raise CommandError('--destination or --dest-from-settings must be used') if not os.path.isdir(dest): os.makedirs(dest) - destfile = os.path.join(dest, uploaded_at.strftime("cdd-%Y%m%d-%H%M%S.dat")) - else: - destfile = os.path.join(dest, uploaded_at.strftime("cdd-%Y%m%d-%H%M%S.dat")) + destfile = os.path.join(dest, uploaded_at.strftime("cdd-%Y%m%d-%H%M%S.dat")) # strings must be in latin-1 format. CSV parser will # otherwise convert unicode objects to ascii. diff --git a/common/djangoapps/student/management/commands/pearson_export_ead.py b/common/djangoapps/student/management/commands/pearson_export_ead.py index 6e3149778d..7697c99e4a 100644 --- a/common/djangoapps/student/management/commands/pearson_export_ead.py +++ b/common/djangoapps/student/management/commands/pearson_export_ead.py @@ -30,7 +30,7 @@ class Command(BaseCommand): default=False, help='Retrieve the destination to export to from django? True/False'), make_option('--destination', - action='store_true', + action='store', dest='destination', default=None, help='Where to store the exported files'), @@ -55,22 +55,21 @@ class Command(BaseCommand): # Name will use timestamp -- this is UTC, so it will look funny, # but it should at least be consistent with the other timestamps # used in the system. - if options['dest-from-settings'] is True: - if settings.PEARSON[LOCAL_EXPORT]: + if 'dest-from-settings' in options: + if LOCAL_EXPORT in settings.PEARSON: dest = settings.PEARSON[LOCAL_EXPORT] else: raise CommandError('--dest-from-settings was enabled but the' 'PEARSON[LOCAL_EXPORT] setting was not set.') - elif options['destination']: + elif destinations in options: dest = options['destination'] else: - raise ComamndError('--destination or --dest-from-settings must be used') + raise CommandError('--destination or --dest-from-settings must be used') if not os.path.isdir(dest): os.makedirs(dest) - destfile = os.path.join(dest, uploaded_at.strftime("ead-%Y%m%d-%H%M%S.dat")) - else: - destfile = os.path.join(dest, uploaded_at.strftime("ead-%Y%m%d-%H%M%S.dat")) + + destfile = os.path.join(dest, uploaded_at.strftime("ead-%Y%m%d-%H%M%S.dat")) dump_all = kwargs['dump_all'] diff --git a/common/djangoapps/student/management/commands/pearson_transfer.py b/common/djangoapps/student/management/commands/pearson_transfer.py index 1d04936216..7d4a2ead3f 100644 --- a/common/djangoapps/student/management/commands/pearson_transfer.py +++ b/common/djangoapps/student/management/commands/pearson_transfer.py @@ -14,7 +14,7 @@ class Command(BaseCommand): option_list = BaseCommand.option_list + ( make_option('--mode', - action='store_true', + action='store', dest='mode', default='both', help='mode is import, export, or both'), @@ -55,11 +55,11 @@ class Command(BaseCommand): password=settings.PEARSON[SFTP_PASSWORD]) sftp = paramiko.SFTPClient.from_transport(t) if os.path.isdir(files_from): - for file in os.listdir(files_from): + for filename in os.listdir(files_from): sftp.put(files_from+'/'+filename, files_to+'/'+filename) else: - for file in sftp.listdir(files_from): + for filename in sftp.listdir(files_from): sftp.get(files_from+'/'+filename, files_to+'/'+filename) except: