From 3a773ffc11f1c2d6fad83f41d6598895a5ec5d22 Mon Sep 17 00:00:00 2001 From: Eric Hanson Date: Mon, 20 May 2019 10:58:45 -0400 Subject: [PATCH 1/5] remove unused headerFileUpload from scripts --- addKeyValuePairOnHandleCSV.py | 2 +- addKeyValuePairToCollection.py | 2 +- addKeyValuePairToCommunity.py | 2 +- addNewItemsToCollection.py | 3 ++- compareTwoKeysInCommunity.py | 2 +- countInitialedNamesByCollection.py | 2 +- deleteBitstreamsFromItem.py | 2 +- deleteKeyFromCollection.py | 2 +- deleteKeyFromCommunity.py | 2 +- deleteKeyValuePairFromCollection.py | 2 +- editBitstreamsNames.py | 2 +- exportCollectionMetadataToCSV.py | 2 +- exportSelectedRecordMetadataToCSV.py | 2 +- findBogusUris.py | 2 +- findDuplicateKeys.py | 2 +- generateCollectionLevelAbstract.py | 2 +- getCollectionMetadataJson.py | 2 +- getCompleteAndUniqueValuesForAllKeys.py | 2 +- getCompleteAndUniqueValuesForAllKeysInCommunity.py | 2 +- getFacultyNamesFromETDs.py | 2 +- getGlobalLanguageValues.py | 2 +- getHandlesAndBitstreamsFromCollection.py | 2 +- getLanguageValuesForKeys.py | 2 +- getRecordsAndValuesForKey.py | 2 +- getRecordsAndValuesForKeyInCollection.py | 2 +- getRecordsWithKeyAndValue.py | 2 +- identifyItemsMissingKeyInCommunity.py | 2 +- metadataCollectionsKeysMatrix.py | 2 +- metadataOverview.py | 2 +- overwriteExistingMetadata.py | 2 +- postCollection.py | 3 ++- removeDuplicateKeyValuePairsFromItems.py | 2 +- replaceKey.py | 2 +- replaceKeyForCollection.py | 2 +- replaceKeyForCommunity.py | 2 +- replaceKeyValuePairOnItemIdCSV.py | 2 +- replaceKeyValuePairsFromCSV.py | 2 +- replaceUnnecessarySpaces.py | 2 +- replaceValueInCollection.py | 2 +- replaceValueInCommunityFromCSV.py | 2 +- repositoryMetadataBackup.py | 2 +- repositoryMetadataRestore.py | 2 +- splitFieldIntoMultipleFields.py | 2 +- updateLanguageTagsForKey.py | 2 +- updateLanguageTagsForKeyInCollection.py | 2 +- 45 files changed, 47 insertions(+), 45 deletions(-) diff --git a/addKeyValuePairOnHandleCSV.py b/addKeyValuePairOnHandleCSV.py index 769d3e2..bb7a024 100644 --- a/addKeyValuePairOnHandleCSV.py +++ b/addKeyValuePairOnHandleCSV.py @@ -24,7 +24,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/addKeyValuePairToCollection.py b/addKeyValuePairToCollection.py index 441b2f8..660c5a0 100644 --- a/addKeyValuePairToCollection.py +++ b/addKeyValuePairToCollection.py @@ -53,7 +53,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/addKeyValuePairToCommunity.py b/addKeyValuePairToCommunity.py index 781ec16..6dfe3e0 100644 --- a/addKeyValuePairToCommunity.py +++ b/addKeyValuePairToCommunity.py @@ -53,7 +53,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/addNewItemsToCollection.py b/addNewItemsToCollection.py index bce1356..74fb3c1 100644 --- a/addNewItemsToCollection.py +++ b/addNewItemsToCollection.py @@ -68,11 +68,12 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() userFullName = status['fullname'] print('authenticated', userFullName) +headerFileUpload = {'accept': 'application/json'} # Get collection ID endpoint = baseURL + '/rest/handle/' + handle diff --git a/compareTwoKeysInCommunity.py b/compareTwoKeysInCommunity.py index 951a735..3fb96be 100644 --- a/compareTwoKeysInCommunity.py +++ b/compareTwoKeysInCommunity.py @@ -45,7 +45,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/countInitialedNamesByCollection.py b/countInitialedNamesByCollection.py index c76b975..64e79ca 100644 --- a/countInitialedNamesByCollection.py +++ b/countInitialedNamesByCollection.py @@ -23,7 +23,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/deleteBitstreamsFromItem.py b/deleteBitstreamsFromItem.py index 3811da2..7649ea1 100644 --- a/deleteBitstreamsFromItem.py +++ b/deleteBitstreamsFromItem.py @@ -25,7 +25,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/deleteKeyFromCollection.py b/deleteKeyFromCollection.py index d8ccb13..83655a2 100644 --- a/deleteKeyFromCollection.py +++ b/deleteKeyFromCollection.py @@ -42,7 +42,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/deleteKeyFromCommunity.py b/deleteKeyFromCommunity.py index 2402b47..72a8b01 100644 --- a/deleteKeyFromCommunity.py +++ b/deleteKeyFromCommunity.py @@ -42,7 +42,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/deleteKeyValuePairFromCollection.py b/deleteKeyValuePairFromCollection.py index d04afe1..e17e01d 100644 --- a/deleteKeyValuePairFromCollection.py +++ b/deleteKeyValuePairFromCollection.py @@ -47,7 +47,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/editBitstreamsNames.py b/editBitstreamsNames.py index 62df011..f571288 100644 --- a/editBitstreamsNames.py +++ b/editBitstreamsNames.py @@ -35,7 +35,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/exportCollectionMetadataToCSV.py b/exportCollectionMetadataToCSV.py index 1ef1c42..4deb6cb 100644 --- a/exportCollectionMetadataToCSV.py +++ b/exportCollectionMetadataToCSV.py @@ -34,7 +34,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/exportSelectedRecordMetadataToCSV.py b/exportSelectedRecordMetadataToCSV.py index aa258bf..b340057 100644 --- a/exportSelectedRecordMetadataToCSV.py +++ b/exportSelectedRecordMetadataToCSV.py @@ -35,7 +35,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/findBogusUris.py b/findBogusUris.py index 6690ecb..a8c5eb3 100644 --- a/findBogusUris.py +++ b/findBogusUris.py @@ -32,7 +32,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/findDuplicateKeys.py b/findDuplicateKeys.py index 19a808f..4f042bd 100644 --- a/findDuplicateKeys.py +++ b/findDuplicateKeys.py @@ -36,7 +36,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/generateCollectionLevelAbstract.py b/generateCollectionLevelAbstract.py index 541667f..4ed1209 100644 --- a/generateCollectionLevelAbstract.py +++ b/generateCollectionLevelAbstract.py @@ -38,7 +38,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/getCollectionMetadataJson.py b/getCollectionMetadataJson.py index 3fca08b..24b1ace 100644 --- a/getCollectionMetadataJson.py +++ b/getCollectionMetadataJson.py @@ -24,7 +24,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/getCompleteAndUniqueValuesForAllKeys.py b/getCompleteAndUniqueValuesForAllKeys.py index 7aebf2d..9ea91ea 100644 --- a/getCompleteAndUniqueValuesForAllKeys.py +++ b/getCompleteAndUniqueValuesForAllKeys.py @@ -29,7 +29,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/getCompleteAndUniqueValuesForAllKeysInCommunity.py b/getCompleteAndUniqueValuesForAllKeysInCommunity.py index 5eff9d5..80d37cb 100644 --- a/getCompleteAndUniqueValuesForAllKeysInCommunity.py +++ b/getCompleteAndUniqueValuesForAllKeysInCommunity.py @@ -27,7 +27,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/getFacultyNamesFromETDs.py b/getFacultyNamesFromETDs.py index 1f85395..bba1321 100644 --- a/getFacultyNamesFromETDs.py +++ b/getFacultyNamesFromETDs.py @@ -34,7 +34,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/getGlobalLanguageValues.py b/getGlobalLanguageValues.py index 8570890..0abfc7c 100644 --- a/getGlobalLanguageValues.py +++ b/getGlobalLanguageValues.py @@ -22,7 +22,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/getHandlesAndBitstreamsFromCollection.py b/getHandlesAndBitstreamsFromCollection.py index 48fc6b4..e6d7b26 100644 --- a/getHandlesAndBitstreamsFromCollection.py +++ b/getHandlesAndBitstreamsFromCollection.py @@ -24,7 +24,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/getLanguageValuesForKeys.py b/getLanguageValuesForKeys.py index d3f7cac..a3ba664 100644 --- a/getLanguageValuesForKeys.py +++ b/getLanguageValuesForKeys.py @@ -22,7 +22,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/getRecordsAndValuesForKey.py b/getRecordsAndValuesForKey.py index 7587d27..c2437f9 100644 --- a/getRecordsAndValuesForKey.py +++ b/getRecordsAndValuesForKey.py @@ -33,7 +33,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/getRecordsAndValuesForKeyInCollection.py b/getRecordsAndValuesForKeyInCollection.py index 18405c0..c71bc59 100644 --- a/getRecordsAndValuesForKeyInCollection.py +++ b/getRecordsAndValuesForKeyInCollection.py @@ -39,7 +39,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/getRecordsWithKeyAndValue.py b/getRecordsWithKeyAndValue.py index a671226..4ec3931 100644 --- a/getRecordsWithKeyAndValue.py +++ b/getRecordsWithKeyAndValue.py @@ -39,7 +39,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/identifyItemsMissingKeyInCommunity.py b/identifyItemsMissingKeyInCommunity.py index c8e3370..5540b33 100644 --- a/identifyItemsMissingKeyInCommunity.py +++ b/identifyItemsMissingKeyInCommunity.py @@ -41,7 +41,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/metadataCollectionsKeysMatrix.py b/metadataCollectionsKeysMatrix.py index 72644e8..7d1bc45 100644 --- a/metadataCollectionsKeysMatrix.py +++ b/metadataCollectionsKeysMatrix.py @@ -23,7 +23,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/metadataOverview.py b/metadataOverview.py index 96ddd70..9da9783 100644 --- a/metadataOverview.py +++ b/metadataOverview.py @@ -24,7 +24,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/overwriteExistingMetadata.py b/overwriteExistingMetadata.py index 84c1656..1a66b80 100644 --- a/overwriteExistingMetadata.py +++ b/overwriteExistingMetadata.py @@ -45,7 +45,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/postCollection.py b/postCollection.py index 3450dec..bdc072c 100644 --- a/postCollection.py +++ b/postCollection.py @@ -54,12 +54,13 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() userFullName = status['fullname'] print('authenticated', userFullName) +headerFileUpload = {'accept': 'application/json'} # create file list and export csv fileList = {} diff --git a/removeDuplicateKeyValuePairsFromItems.py b/removeDuplicateKeyValuePairsFromItems.py index 7feb073..c1eda9f 100644 --- a/removeDuplicateKeyValuePairsFromItems.py +++ b/removeDuplicateKeyValuePairsFromItems.py @@ -24,7 +24,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/replaceKey.py b/replaceKey.py index 65836be..7fc633c 100644 --- a/replaceKey.py +++ b/replaceKey.py @@ -41,7 +41,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/replaceKeyForCollection.py b/replaceKeyForCollection.py index a0236ff..6856017 100644 --- a/replaceKeyForCollection.py +++ b/replaceKeyForCollection.py @@ -47,7 +47,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/replaceKeyForCommunity.py b/replaceKeyForCommunity.py index c74b0ce..594e32b 100644 --- a/replaceKeyForCommunity.py +++ b/replaceKeyForCommunity.py @@ -47,7 +47,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/replaceKeyValuePairOnItemIdCSV.py b/replaceKeyValuePairOnItemIdCSV.py index 1bbb460..f9da491 100644 --- a/replaceKeyValuePairOnItemIdCSV.py +++ b/replaceKeyValuePairOnItemIdCSV.py @@ -24,7 +24,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/replaceKeyValuePairsFromCSV.py b/replaceKeyValuePairsFromCSV.py index 5bfdd4a..42f273b 100644 --- a/replaceKeyValuePairsFromCSV.py +++ b/replaceKeyValuePairsFromCSV.py @@ -36,7 +36,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/replaceUnnecessarySpaces.py b/replaceUnnecessarySpaces.py index e31ce07..fd4865c 100644 --- a/replaceUnnecessarySpaces.py +++ b/replaceUnnecessarySpaces.py @@ -27,7 +27,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/replaceValueInCollection.py b/replaceValueInCollection.py index d1c6b0d..781528f 100644 --- a/replaceValueInCollection.py +++ b/replaceValueInCollection.py @@ -53,7 +53,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/replaceValueInCommunityFromCSV.py b/replaceValueInCommunityFromCSV.py index 2e69d4a..9f6e789 100644 --- a/replaceValueInCommunityFromCSV.py +++ b/replaceValueInCommunityFromCSV.py @@ -42,7 +42,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/repositoryMetadataBackup.py b/repositoryMetadataBackup.py index 6b06e8a..0e338c4 100644 --- a/repositoryMetadataBackup.py +++ b/repositoryMetadataBackup.py @@ -34,7 +34,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/repositoryMetadataRestore.py b/repositoryMetadataRestore.py index e69b4f8..eef640a 100644 --- a/repositoryMetadataRestore.py +++ b/repositoryMetadataRestore.py @@ -36,7 +36,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/splitFieldIntoMultipleFields.py b/splitFieldIntoMultipleFields.py index a3b2ea9..b804223 100644 --- a/splitFieldIntoMultipleFields.py +++ b/splitFieldIntoMultipleFields.py @@ -44,7 +44,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/updateLanguageTagsForKey.py b/updateLanguageTagsForKey.py index 31e5e20..4ab80cc 100644 --- a/updateLanguageTagsForKey.py +++ b/updateLanguageTagsForKey.py @@ -35,7 +35,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() diff --git a/updateLanguageTagsForKeyInCollection.py b/updateLanguageTagsForKeyInCollection.py index fd11144..afebe8f 100644 --- a/updateLanguageTagsForKeyInCollection.py +++ b/updateLanguageTagsForKeyInCollection.py @@ -27,7 +27,7 @@ session = requests.post(baseURL + '/rest/login', headers=header, verify=verify, params=data).cookies['JSESSIONID'] cookies = {'JSESSIONID': session} -headerFileUpload = {'accept': 'application/json'} + status = requests.get(baseURL + '/rest/status', headers=header, cookies=cookies, verify=verify).json() From d9d046b26a3316cee17bafb79733ac8fc96346e3 Mon Sep 17 00:00:00 2001 From: Eric Hanson Date: Mon, 20 May 2019 11:30:32 -0400 Subject: [PATCH 2/5] Update dsFunc.py --- dsFunc.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dsFunc.py b/dsFunc.py index d883e59..f3f7cac 100644 --- a/dsFunc.py +++ b/dsFunc.py @@ -1,5 +1,28 @@ import datetime import time +import requests + + +def auth(email, password, baseURL, verify): + """Authenticate the user to the DSpace API.""" + data = {'email': email, 'password': password} + header = {'content-type': 'application/json', + 'accept': 'application/json'} + session = requests.post(baseURL + '/rest/login', headers=header, + verify=verify, + params=data).cookies['JSESSIONID'] + cookies = {'JSESSIONID': session} + return(cookies, header) + + +def authConfirm(cookies, baseURL, header, verify): + """Confirm user was successfully authenticated to the DSpace API.""" + status = requests.get(baseURL + '/rest/status', headers=header, + cookies=cookies, verify=verify).json() + uName = status['fullname'] + authEmail = status['email'] + print('authenticated', uName, authEmail) + return(uName, authEmail) def elapsedTime(startTime, label): From 161f5eb81c586f7002b27d717fcaae0c9bd080c5 Mon Sep 17 00:00:00 2001 From: Eric Hanson Date: Tue, 21 May 2019 12:33:58 -0400 Subject: [PATCH 3/5] formatting updates --- addKeyValuePairToCollection.py | 23 ++++--- addKeyValuePairToCommunity.py | 17 ++--- addNewItemsToCollection.py | 15 +++-- checkInventory.py | 14 ++-- compareTwoKeysInCommunity.py | 15 +++-- deleteKeyFromCollection.py | 10 +-- deleteKeyFromCommunity.py | 10 +-- deleteKeyValuePairFromCollection.py | 15 +++-- editBitstreamsNames.py | 6 +- exportCollectionMetadataToCSV.py | 17 ++--- exportSelectedRecordMetadataToCSV.py | 9 +-- fileListMetadataReconcile.py | 15 +++-- findDuplicateKeys.py | 4 +- generateCollectionLevelAbstract.py | 10 +-- getBitstreams.py | 85 ++++++++++++------------ getFacultyNamesFromETDs.py | 5 +- getRecordsAndValuesForKey.py | 4 +- getRecordsAndValuesForKeyInCollection.py | 9 +-- getRecordsWithKeyAndValue.py | 8 +-- identifyItemsMissingKeyInCommunity.py | 9 +-- overwriteExistingMetadata.py | 10 +-- postCollection.py | 40 ++++++----- replaceKey.py | 10 +-- replaceKeyForCollection.py | 15 +++-- replaceKeyForCommunity.py | 15 +++-- replaceKeyValuePairsFromCSV.py | 9 +-- replaceValueInCollection.py | 19 +++--- replaceValueInCommunityFromCSV.py | 9 +-- splitFieldIntoMultipleFields.py | 14 ++-- updateLanguageTagsForKey.py | 4 +- 30 files changed, 245 insertions(+), 200 deletions(-) diff --git a/addKeyValuePairToCollection.py b/addKeyValuePairToCollection.py index 660c5a0..d5a5367 100644 --- a/addKeyValuePairToCollection.py +++ b/addKeyValuePairToCollection.py @@ -18,14 +18,16 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--key', help='the key to be added. optional - if \ -not provided, the script will ask for input') -parser.add_argument('-v', '--value', help='the value to be added. optional - \ -if not provided, the script will ask for input') -parser.add_argument('-l', '--language', help='the language tag to be added. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the collection. optional \ -- if not provided, the script will ask for input') +parser.add_argument('-k', '--key', help='the key to be added. optional - if ' + 'not provided, the script will ask for input') +parser.add_argument('-v', '--value', help='the value to be added. optional - ' + 'if not provided, the script will ask for input') +parser.add_argument('-l', '--language', help='the language tag to be added. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-i', '--handle', help='handle of the collection. ' + 'optional - if not provided, the script will ask for ' + 'input') args = parser.parse_args() if args.key: @@ -105,8 +107,9 @@ addedMetadataElement['value'] = addedValue addedMetadataElement['language'] = addedLanguage itemMetadataProcessed.append(addedMetadataElement) - provNote = '\'' + addedKey + ': ' + addedValue + '\' was added through a \ - batch process on ' + datetime.now().strftime('%Y-%m-%d %H:%M:%S') + '.' + provNote = ('\'' + addedKey + ': ' + addedValue + '\' was added through a ' + + 'batch process on ' + + datetime.now().strftime('%Y-%m-%d %H:%M:%S') + '.') provNoteElement = {} provNoteElement['key'] = 'dc.description.provenance' provNoteElement['value'] = provNote diff --git a/addKeyValuePairToCommunity.py b/addKeyValuePairToCommunity.py index 6dfe3e0..ec679bb 100644 --- a/addKeyValuePairToCommunity.py +++ b/addKeyValuePairToCommunity.py @@ -18,14 +18,15 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--key', help='the key to be added. optional - if \ -not provided, the script will ask for input') -parser.add_argument('-v', '--value', help='the value to be added. optional - \ -if not provided, the script will ask for input') -parser.add_argument('-l', '--language', help='the language tag to be added. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the community. optional \ -- if not provided, the script will ask for input') +parser.add_argument('-k', '--key', help='the key to be added. optional - if ' + 'not provided, the script will ask for input') +parser.add_argument('-v', '--value', help='the value to be added. optional - ' + 'if not provided, the script will ask for input') +parser.add_argument('-l', '--language', help='the language tag to be added. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-i', '--handle', help='handle of the community. optional ' + '- if not provided, the script will ask for input') args = parser.parse_args() if args.key: diff --git a/addNewItemsToCollection.py b/addNewItemsToCollection.py index 74fb3c1..15a7e9a 100644 --- a/addNewItemsToCollection.py +++ b/addNewItemsToCollection.py @@ -20,12 +20,15 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-d', '--directory', help='the directory of files to be \ -ingested. optional - if not provided, the script will ask for input') -parser.add_argument('-e', '--fileExtension', help='the extension of files to \ -be ingested. optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the object to retreive. \ -optional - if not provided, the script will ask for input') +parser.add_argument('-d', '--directory', help='the directory of files to be ' + 'ingested. optional - if not provided, the script will ' + 'ask for input') +parser.add_argument('-e', '--fileExtension', help='the extension of files to ' + 'be ingested. optional - if not provided, the script will ' + 'ask for input') +parser.add_argument('-i', '--handle', help='handle of the object to retreive. ' + 'optional - if not provided, the script will ask for ' + 'input') args = parser.parse_args() if args.directory: diff --git a/checkInventory.py b/checkInventory.py index fa1caa9..a2a8e2a 100644 --- a/checkInventory.py +++ b/checkInventory.py @@ -9,17 +9,17 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument('-i', '--inventory', required=True, - help='csv file containing the inventory. the path, if \ - given, can be absolute or relative to this script') + help='csv file containing the inventory. the path, if ' + 'given, can be absolute or relative to this script') parser.add_argument('-d', '--dataDir', - help='directory containing the data. if omitted, data \ - will be read from the directory containing the \ - inventory file') + help='directory containing the data. if omitted, data ' + 'will be read from the directory containing the ' + 'inventory file') parser.add_argument('-f', '--field', - help='field in the csv containing the fileNames. \ - default: name') + help='field in the csv containing the fileNames. ' + 'default: name') parser.add_argument('-v', '--verbose', action='store_true', help='increase output verbosity') diff --git a/compareTwoKeysInCommunity.py b/compareTwoKeysInCommunity.py index 3fb96be..7d68180 100644 --- a/compareTwoKeysInCommunity.py +++ b/compareTwoKeysInCommunity.py @@ -16,12 +16,15 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-1', '--key', help='the first key to be output. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-2', '--key2', help='the second key to be output. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the community to \ -retreive. optional - if not provided, the script will ask for input') +parser.add_argument('-1', '--key', help='the first key to be output. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-2', '--key2', help='the second key to be output. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-i', '--handle', help='handle of the community to ' + 'retreive. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.key: diff --git a/deleteKeyFromCollection.py b/deleteKeyFromCollection.py index 83655a2..685bbc6 100644 --- a/deleteKeyFromCollection.py +++ b/deleteKeyFromCollection.py @@ -18,10 +18,12 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--deletedKey', help='the key to be deleted. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the collection to \ -retreive. optional - if not provided, the script will ask for input') +parser.add_argument('-k', '--deletedKey', help='the key to be deleted. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-i', '--handle', help='handle of the collection to ' + 'retreive. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.deletedKey: diff --git a/deleteKeyFromCommunity.py b/deleteKeyFromCommunity.py index 72a8b01..a57c777 100644 --- a/deleteKeyFromCommunity.py +++ b/deleteKeyFromCommunity.py @@ -18,10 +18,12 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--deletedKey', help='the key to be deleted. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the community to \ -retreive. optional - if not provided, the script will ask for input') +parser.add_argument('-k', '--deletedKey', help='the key to be deleted. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-i', '--handle', help='handle of the community to ' + 'retreive. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.deletedKey: diff --git a/deleteKeyValuePairFromCollection.py b/deleteKeyValuePairFromCollection.py index e17e01d..a27a851 100644 --- a/deleteKeyValuePairFromCollection.py +++ b/deleteKeyValuePairFromCollection.py @@ -18,12 +18,15 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--deletedKey', help='the key to be deleted. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-v', '--deletedValue', help='the value to be deleted. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the community to \ -retreive. optional - if not provided, the script will ask for input') +parser.add_argument('-k', '--deletedKey', help='the key to be deleted. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-v', '--deletedValue', help='the value to be deleted. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-i', '--handle', help='handle of the community to ' + 'retreive. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.deletedKey: diff --git a/editBitstreamsNames.py b/editBitstreamsNames.py index f571288..ed20863 100644 --- a/editBitstreamsNames.py +++ b/editBitstreamsNames.py @@ -18,9 +18,9 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-f', '--fileName', help='the name of the CSV with the \ -bitstream name changes. optional - if not provided, the script will ask for \ -input') +parser.add_argument('-f', '--fileName', help='the name of the CSV with the ' + 'bitstream name changes. optional - if not provided, the ' + 'script will ask for input') args = parser.parse_args() if args.uri: fileName = args.fileName diff --git a/exportCollectionMetadataToCSV.py b/exportCollectionMetadataToCSV.py index 4deb6cb..8709c3a 100644 --- a/exportCollectionMetadataToCSV.py +++ b/exportCollectionMetadataToCSV.py @@ -16,8 +16,9 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-i', '--handle', help='handle of the collection to \ -retreive. optional - if not provided, the script will ask for input') +parser.add_argument('-i', '--handle', help='handle of the collection to ' + 'retreive. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.handle: @@ -29,17 +30,9 @@ # authentication startTime = time.time() -data = {'email': email, 'password': password} -header = {'content-type': 'application/json', 'accept': 'application/json'} -session = requests.post(baseURL + '/rest/login', headers=header, - verify=verify, params=data).cookies['JSESSIONID'] -cookies = {'JSESSIONID': session} +cookies, header = dsFunc.auth(email, password, baseURL, verify) - -status = requests.get(baseURL + '/rest/status', headers=header, - cookies=cookies, verify=verify).json() -userFullName = status['fullname'] -print('authenticated', userFullName) +uName, authEmail = dsFunc.authConfirm(cookies, baseURL, header, verify) endpoint = baseURL + '/rest/handle/' + handle collection = requests.get(endpoint, headers=header, cookies=cookies, diff --git a/exportSelectedRecordMetadataToCSV.py b/exportSelectedRecordMetadataToCSV.py index b340057..bedf21c 100644 --- a/exportSelectedRecordMetadataToCSV.py +++ b/exportSelectedRecordMetadataToCSV.py @@ -16,15 +16,16 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-f', '--fileName', help='the CSV file of record handles. \ -optional - if not provided, the script will ask for input') +parser.add_argument('-f', '--fileName', help='the CSV file of record handles. ' + 'optional - if not provided, the script will ask for ' + 'input') args = parser.parse_args() if args.fileName: fileName = filePath + args.fileName else: - fileName = filePath + input('Enter the CSV file of record handles \ - (including \'.csv\'): ') + fileName = filePath + input('Enter the CSV file of record handles ' + '(including \'.csv\'): ') urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) diff --git a/fileListMetadataReconcile.py b/fileListMetadataReconcile.py index 98d8c42..7a648f6 100644 --- a/fileListMetadataReconcile.py +++ b/fileListMetadataReconcile.py @@ -6,12 +6,15 @@ import dsFunc parser = argparse.ArgumentParser() -parser.add_argument('-d', '--directory', help='the directory of the files. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-f', '--fileNameCSV', help='the metadata CSV file. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-e', '--fileExtension', help='the file extension. \ -optional - if not provided, the script will ask for input') +parser.add_argument('-d', '--directory', help='the directory of the files. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-f', '--fileNameCSV', help='the metadata CSV file. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-e', '--fileExtension', help='the file extension. ' + 'optional - if not provided, the script will ask for ' + 'input') args = parser.parse_args() if args.directory: diff --git a/findDuplicateKeys.py b/findDuplicateKeys.py index 4f042bd..4350889 100644 --- a/findDuplicateKeys.py +++ b/findDuplicateKeys.py @@ -17,8 +17,8 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--key', help='the key to be searched. optional - if \ -not provided, the script will ask for input') +parser.add_argument('-k', '--key', help='the key to be searched. optional - ' + 'if not provided, the script will ask for input') args = parser.parse_args() if args.key: diff --git a/generateCollectionLevelAbstract.py b/generateCollectionLevelAbstract.py index 4ed1209..37262a0 100644 --- a/generateCollectionLevelAbstract.py +++ b/generateCollectionLevelAbstract.py @@ -16,10 +16,12 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-f', '--fileNameCSV', help='the metadata CSV file. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the collection. \ -optional - if not provided, the script will ask for input') +parser.add_argument('-f', '--fileNameCSV', help='the metadata CSV file. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-i', '--handle', help='handle of the collection. ' + 'optional - if not provided, the script will ask for ' + 'input') args = parser.parse_args() if args.fileNameCSV: diff --git a/getBitstreams.py b/getBitstreams.py index 150dfca..cbdf467 100644 --- a/getBitstreams.py +++ b/getBitstreams.py @@ -30,8 +30,8 @@ def main(): help='increase output verbosity') parser.add_argument('-i', '--handle', - help='handle of the object to retreive. optional - if \ - not provided, the script will ask for input') + help='handle of the object to retreive. optional - if ' + 'not provided, the script will ask for input') # bitstream formats: # REM: set number of args @@ -40,61 +40,63 @@ def main(): # '?' == 0 or 1. # An int is an explicit number of arguments to accept. parser.add_argument('-f', '--formats', nargs='*', - help='optional list of bitstream formats. will return \ - all formats if not provided') + help='optional list of bitstream formats. will return '' + 'all formats if not provided') parser.add_argument('-b', '--bundles', nargs='*', - help='optional list of bundles (e.g. ORIGINAL or \ - LICENSE). will return all bundles if not provided') + help='optional list of bundles (e.g. ORIGINAL or ' + 'LICENSE). will return all bundles if not provided') parser.add_argument('-dl', '--download', action='store_true', - help='download bitstreams (rather than just retreive \ - metadata about them). default: false') + help='download bitstreams (rather than just retreive ' + 'metadata about them). default: false') parser.add_argument('-rt', '--rtimeout', type=int, - help='response timeout - number of seconds to wait for \ - a response. not a timeout for a download or run of \ - the entire script. default: ' + help='response timeout - number of seconds to wait ' + 'for a response. not a timeout for a download or run ' + 'of the entire script. default: ' + str(default_response_timeout)) parser.add_argument('-l', '--limit', type=int, - help='limit to the number of objects to return in a \ - given request. default: ' + str(default_limit)) + help='limit to the number of objects to return in a ' + 'given request. default: ' + str(default_limit)) parser.add_argument('-u', '--baseURL', - help='url of the dspace instance. can be read from \ - the secrets file') + help='url of the dspace instance. can be read from ' + 'the secrets file') parser.add_argument('-e', '--email', - help='email of an authorized dspace user. can be \ - read from the secrets file') + help='email of an authorized dspace user. can be ' + 'read from the secrets file') parser.add_argument('-p', '--password', - help='password of an authorized dspace user. can be \ - read from the secrets file') + help='password of an authorized dspace user. can be ' + 'read from the secrets file') parser.add_argument('-d', '--filePath', - help='directory into which output files will be \ - written. can be read from the secrets file') + help='directory into which output files will be ' + 'written. can be read from the secrets file') parser.add_argument('-s', '--verify', - help='ssl verification enabled (boolean) OR the path \ - to a CA_BUNDLE file or directory with certificates \ - of trusted CAs. use false if using an ssh tunnel to \ - connect to the dspace api. can be read from the \ + help='ssl verification enabled (boolean) OR the path ' + 'to a CA_BUNDLE file or directory with certificates ' + 'of trusted CAs. use false if using an ssh tunnel to ' + 'connect to the dspace api. can be read from the ' secrets file') args = parser.parse_args() - inst = input('To edit production server, enter the name of the secrets file: ') -secrets = dsFunc.instSelect(inst) + inst = input('To edit production server, enter the name of the secrets ' + 'file: ') -baseURL = secrets.baseURL -email = secrets.email -password = secrets.password -filePath = secrets.filePath -verify = secrets.verify -skipColl = secrets.skipColl + secrets = dsFunc.instSelect(inst) + + baseURL = secrets.baseURL + email = secrets.email + password = secrets.password + filePath = secrets.filePath + verify = secrets.verify + skipColl = secrets.skipColl if not args.rtimeout: args.rtimeout = default_response_timeout @@ -129,14 +131,14 @@ def main(): print('retreiving object with handle {}'.format(args.handle)) if args.formats: - print('filtering results to the following bitstream \ - formats: {}'.format(args.formats)) + print('filtering results to the following bitstream ' + 'formats: {}'.format(args.formats)) else: print('returning bitstreams of any format') if args.bundles: - print('filtering results to the following bundles: \ - {}'.format(args.bundles)) + print('filtering results to the following bundles: ' + '{}'.format(args.bundles)) else: print('returning bitstreams from any bundle') @@ -189,8 +191,9 @@ def main(): processItem(dsObject, args) else: - print('object is of an invalid type for this script ({}). please \ - enter the handle of an item or a collection.'.format(dsObject['type'])) + print('object is of an invalid type for this script ({}). please ' + 'enter the handle of an item or a ' + 'collection.'.format(dsObject['type'])) logout = requests.post(args.baseURL + '/rest/logout', headers=header, cookies=cookies, verify=args.verify, @@ -226,8 +229,8 @@ def processItem(dsObject, args): # don't retreive more bitstreams than we have left if limit > bitstreamCount: limit = bitstreamCount - print('bitstreamCount: {0} offset: {1} \ - limit: {2}'.format(bitstreamCount, offset, limit)) + print('bitstreamCount: {0} offset: {1} ' + 'limit: {2}'.format(bitstreamCount, offset, limit)) bitstreams = requests.get(args.baseURL + '/rest/items/' + str(itemID) + '/bitstreams?limit=' + str(limit) + '&offset=' + str(offset), headers=header, diff --git a/getFacultyNamesFromETDs.py b/getFacultyNamesFromETDs.py index bba1321..f1dd4de 100644 --- a/getFacultyNamesFromETDs.py +++ b/getFacultyNamesFromETDs.py @@ -17,8 +17,9 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-i', '--handle', help='handle of the community to \ -retreive. optional - if not provided, the script will ask for input') +parser.add_argument('-i', '--handle', help='handle of the community to ' + 'retreive. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.handle: diff --git a/getRecordsAndValuesForKey.py b/getRecordsAndValuesForKey.py index c2437f9..af79ccd 100644 --- a/getRecordsAndValuesForKey.py +++ b/getRecordsAndValuesForKey.py @@ -16,8 +16,8 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--key', help='the key to be searched. optional - \ -if not provided, the script will ask for input') +parser.add_argument('-k', '--key', help='the key to be searched. optional - ' + 'if not provided, the script will ask for input') args = parser.parse_args() if args.key: diff --git a/getRecordsAndValuesForKeyInCollection.py b/getRecordsAndValuesForKeyInCollection.py index c71bc59..3f2b005 100644 --- a/getRecordsAndValuesForKeyInCollection.py +++ b/getRecordsAndValuesForKeyInCollection.py @@ -16,10 +16,11 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--key', help='the key to be searched. optional - if \ -not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the collection to \ -retreive. optional - if not provided, the script will ask for input') +parser.add_argument('-k', '--key', help='the key to be searched. optional - ' + 'if not provided, the script will ask for input') +parser.add_argument('-i', '--handle', help='handle of the collection to ' + 'retreive. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.key: diff --git a/getRecordsWithKeyAndValue.py b/getRecordsWithKeyAndValue.py index 4ec3931..335e404 100644 --- a/getRecordsWithKeyAndValue.py +++ b/getRecordsWithKeyAndValue.py @@ -16,10 +16,10 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--key', help='the key to be searched. optional - if \ -not provided, the script will ask for input') -parser.add_argument('-v', '--value', help='the value to be searched. optional \ -- if not provided, the script will ask for input') +parser.add_argument('-k', '--key', help='the key to be searched. optional - ' + 'if not provided, the script will ask for input') +parser.add_argument('-v', '--value', help='the value to be searched. optional ' + '- if not provided, the script will ask for input') args = parser.parse_args() if args.key: diff --git a/identifyItemsMissingKeyInCommunity.py b/identifyItemsMissingKeyInCommunity.py index 5540b33..ffa7d0a 100644 --- a/identifyItemsMissingKeyInCommunity.py +++ b/identifyItemsMissingKeyInCommunity.py @@ -17,10 +17,11 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--key', help='the key to be searched. optional - if \ -not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the community to \ -retreive. optional - if not provided, the script will ask for input') +parser.add_argument('-k', '--key', help='the key to be searched. optional - ' + 'if not provided, the script will ask for input') +parser.add_argument('-i', '--handle', help='handle of the community to ' + 'retreive. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.key: diff --git a/overwriteExistingMetadata.py b/overwriteExistingMetadata.py index 1a66b80..ab15143 100644 --- a/overwriteExistingMetadata.py +++ b/overwriteExistingMetadata.py @@ -18,9 +18,9 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-f', '--fileName', help='the name of the CSV with handles \ -and file identifiers. optional - if not provided, the script will ask for \ -input') +parser.add_argument('-f', '--fileName', help='the name of the CSV with ' + 'handles and file identifiers. optional - if not ' + 'provided, the script will ask for input') args = parser.parse_args() if args.fileName: fileName = args.fileName @@ -71,8 +71,8 @@ uriElement['key'] = 'dc.identifier.uri' uriElement['value'] = 'http://jhir.library.jhu.edu/handle/' + v updatedItemMetadataList.append(uriElement) - provNote = 'Item metadata updated through a batch process on ' \ - + datetime.now().strftime('%Y-%m-%d %H:%M:%S') + '.' + provNote = ('Item metadata updated through a batch process on ' + + datetime.now().strftime('%Y-%m-%d %H:%M:%S') + '.') provNoteElement = {} provNoteElement['key'] = 'dc.description.provenance' provNoteElement['value'] = provNote diff --git a/postCollection.py b/postCollection.py index bdc072c..845e865 100644 --- a/postCollection.py +++ b/postCollection.py @@ -19,14 +19,18 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-d', '--directory', help='the directory of the files. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-e', '--fileExtension', help='the file extension. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--communityHandle', help='handle of the community. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-n', '--collectionName', help='the name of the \ -collection. optional - if not provided, the script will ask for input') +parser.add_argument('-d', '--directory', help='the directory of the files. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-e', '--fileExtension', help='the file extension. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-i', '--communityHandle', help='handle of the community. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-n', '--collectionName', help='the name of the ' + 'collection. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.directory: @@ -168,30 +172,34 @@ headers=header, cookies=cookies, verify=verify).json() bitstreamCount = len(bitstreams) - provNoteValue = 'Submitted by ' + userFullName + ' (' + email + ') \ - on ' + utcTime + ' (GMT). No. of bitstreams: ' + str(bitstreamCount) + provNoteValue = ('Submitted by ' + userFullName + ' (' + email + ')' + + ' on ' + utcTime + ' (GMT). No. of bitstreams: ' + + str(bitstreamCount)) for bitstream in bitstreams: fileName = bitstream['name'] size = str(bitstream['sizeBytes']) checksum = bitstream['checkSum']['value'] algorithm = bitstream['checkSum']['checkSumAlgorithm'] - provNoteValue = provNoteValue + ' ' + fileName + ': ' + size + ' \ - bytes, checkSum: ' + checksum + ' (' + algorithm + ')' + provNoteValue = (provNoteValue + ' ' + fileName + ': ' + size + + ' bytes, checkSum: ' + checksum + ' (' + + algorithm + ')') provNote['value'] = provNoteValue provNote2 = {} provNote2['key'] = 'dc.description.provenance' provNote2['language'] = 'en_US' - provNote2Value = 'Made available in DSpace on ' + utcTime + ' (GMT). \ - No. of bitstreams: ' + str(bitstreamCount) + provNote2Value = ('Made available in DSpace on ' + utcTime + + ' (GMT). No. of bitstreams: ' + + str(bitstreamCount)) for bitstream in bitstreams: fileName = bitstream['name'] size = str(bitstream['sizeBytes']) checksum = bitstream['checkSum']['value'] algorithm = bitstream['checkSum']['checkSumAlgorithm'] - provNote2Value = provNote2Value + ' ' + fileName + ': ' + size + ' \ - bytes, checkSum: ' + checksum + ' (' + algorithm + ')' + provNote2Value = (provNote2Value + ' ' + fileName + ': ' + size + + ' bytes, checkSum: ' + checksum + ' (' + + algorithm + ')') provNote2['value'] = provNote2Value # Post provenance notes diff --git a/replaceKey.py b/replaceKey.py index 7fc633c..01ffc7e 100644 --- a/replaceKey.py +++ b/replaceKey.py @@ -18,10 +18,12 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-1', '--replacedKey', help='the key to be replaced. \ - optional - if not provided, the script will ask for input') -parser.add_argument('-2', '--replacementKey', help='the replacement key. \ - optional - if not provided, the script will ask for input') +parser.add_argument('-1', '--replacedKey', help='the key to be replaced. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-2', '--replacementKey', help='the replacement key. ' + 'optional - if not provided, the script will ask for ' + 'input') args = parser.parse_args() if args.replacedKey: diff --git a/replaceKeyForCollection.py b/replaceKeyForCollection.py index 6856017..f91e58c 100644 --- a/replaceKeyForCollection.py +++ b/replaceKeyForCollection.py @@ -18,12 +18,15 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-1', '--replacedKey', help='the key to be replaced. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-2', '--replacementKey', help='the replacement key. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the collection to \ -retreive. optional - if not provided, the script will ask for input') +parser.add_argument('-1', '--replacedKey', help='the key to be replaced. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-2', '--replacementKey', help='the replacement key. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-i', '--handle', help='handle of the collection to ' + 'retreive. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.replacedKey: diff --git a/replaceKeyForCommunity.py b/replaceKeyForCommunity.py index 594e32b..e98957b 100644 --- a/replaceKeyForCommunity.py +++ b/replaceKeyForCommunity.py @@ -18,12 +18,15 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-1', '--replacedKey', help='the key to be replaced. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-2', '--replacementKey', help='the replacement key. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the community to \ -retreive. optional - if not provided, the script will ask for input') +parser.add_argument('-1', '--replacedKey', help='the key to be replaced. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-2', '--replacementKey', help='the replacement key. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-i', '--handle', help='handle of the community to ' + 'retreive. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.replacedKey: diff --git a/replaceKeyValuePairsFromCSV.py b/replaceKeyValuePairsFromCSV.py index 42f273b..fd7618b 100644 --- a/replaceKeyValuePairsFromCSV.py +++ b/replaceKeyValuePairsFromCSV.py @@ -18,15 +18,16 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-f', '--fileName', help='the CSV file of changes. optional \ -- if not provided, the script will ask for input') +parser.add_argument('-f', '--fileName', help='the CSV file of changes. ' + 'optional - if not provided, the script will ask for ' + 'input') args = parser.parse_args() if args.fileName: fileName = filePath + args.fileName else: - fileName = filePath + input('Enter the CSV of changes \ - (including \'.csv\'): ') + fileName = filePath + input('Enter the CSV of changes ' + '(including \'.csv\'): ') urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) diff --git a/replaceValueInCollection.py b/replaceValueInCollection.py index 781528f..2a37fd7 100644 --- a/replaceValueInCollection.py +++ b/replaceValueInCollection.py @@ -18,14 +18,17 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--key', help='the key to be searched. optional - if \ -not provided, the script will ask for input') -parser.add_argument('-1', '--replacedValue', help='the value to be replaced. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-2', '--replacementValue', help='the replacement value. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-i', '--handle', help='handle of the collection to \ -retreive. optional - if not provided, the script will ask for input') +parser.add_argument('-k', '--key', help='the key to be searched. optional - ' + 'if not provided, the script will ask for input') +parser.add_argument('-1', '--replacedValue', help='the value to be replaced. ' + 'optional - if not provided, the script will ask for' + 'input') +parser.add_argument('-2', '--replacementValue', help='the replacement value. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-i', '--handle', help='handle of the collection to ' + 'retreive. optional - if not provided, the script will ' + 'ask for input') args = parser.parse_args() if args.key: diff --git a/replaceValueInCommunityFromCSV.py b/replaceValueInCommunityFromCSV.py index 9f6e789..15b81b4 100644 --- a/replaceValueInCommunityFromCSV.py +++ b/replaceValueInCommunityFromCSV.py @@ -19,10 +19,11 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-i', '--handle', help='handle of the community. optional \ -- if not provided, the script will ask for input') -parser.add_argument('-f', '--fileName', help='the CSV file of changes. \ -optional - if not provided, the script will ask for input') +parser.add_argument('-i', '--handle', help='handle of the community. optional ' + '- if not provided, the script will ask for input') +parser.add_argument('-f', '--fileName', help='the CSV file of changes. ' + 'optional - if not provided, the script will ask for ' + 'input') args = parser.parse_args() if args.fileName: diff --git a/splitFieldIntoMultipleFields.py b/splitFieldIntoMultipleFields.py index b804223..4492e3f 100644 --- a/splitFieldIntoMultipleFields.py +++ b/splitFieldIntoMultipleFields.py @@ -20,10 +20,12 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-r', '--replacedKey', help='the key to be replaced. \ -optional - if not provided, the script will ask for input') -parser.add_argument('-f', '--fileName', help='the CSV file of changes. \ -optional - if not provided, the script will ask for input') +parser.add_argument('-r', '--replacedKey', help='the key to be replaced. ' + 'optional - if not provided, the script will ask for ' + 'input') +parser.add_argument('-f', '--fileName', help='the CSV file of changes. ' + 'optional - if not provided, the script will ask for ' + 'input') args = parser.parse_args() if args.replacedKey: @@ -33,8 +35,8 @@ if args.fileName: fileName = filePath + args.fileName else: - fileName = filePath + input('Enter the file name of the CSV of changes \ - (including \'.csv\'): ') + fileName = filePath + input('Enter the file name of the CSV of changes ' + '(including \'.csv\'): ') urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) diff --git a/updateLanguageTagsForKey.py b/updateLanguageTagsForKey.py index 4ab80cc..c8453c0 100644 --- a/updateLanguageTagsForKey.py +++ b/updateLanguageTagsForKey.py @@ -18,8 +18,8 @@ skipColl = secrets.skipColl parser = argparse.ArgumentParser() -parser.add_argument('-k', '--key', help='the key to be updated. optional - if \ -not provided, the script will ask for input') +parser.add_argument('-k', '--key', help='the key to be updated. optional - if ' + 'not provided, the script will ask for input') args = parser.parse_args() if args.key: From abe370a5f5ee9a956e0aa9379b015ab7c855f230 Mon Sep 17 00:00:00 2001 From: Eric Hanson Date: Tue, 21 May 2019 16:09:03 -0400 Subject: [PATCH 4/5] Update tests.py --- tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests.py b/tests.py index 246debd..b576d59 100644 --- a/tests.py +++ b/tests.py @@ -28,6 +28,21 @@ def testInstaSelect(self): secrets = dsFunc.instSelect(inst) self.assertTrue(secrets.__name__ == 'secrets') + def testAuth(self): + """Return email to confirm acceptance of credentials.""" + instArray = ['secretsProd', '', 'secrets', '#$%#%##@'] + for inst in instArray: + secrets = dsFunc.instSelect(inst) + email = secrets.email + baseURL = secrets.baseURL + password = secrets.password + verify = secrets.verify + cookies, header = dsFunc.auth(email, password, baseURL, verify) + + uName, authEmail = dsFunc.authConfirm(cookies, baseURL, header, + verify) + self.assertIn(email, authEmail) + if __name__ == '__main__': unittest.main(warnings='ignore') From 876203a08c3810c1a58df6c6f1671cce1bdb2b54 Mon Sep 17 00:00:00 2001 From: Eric Hanson Date: Mon, 26 Aug 2019 10:50:23 -0400 Subject: [PATCH 5/5] pipfile and gitignore updates --- .gitignore | 3 +-- Pipfile | 2 ++ Pipfile.lock | 36 ++++++++++++++++++++++++++---------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index f20d595..cd37cec 100644 --- a/.gitignore +++ b/.gitignore @@ -45,8 +45,7 @@ $RECYCLE.BIN/ Network Trash Folder Temporary Items .apdisk -secrets.py -secretsProd.py +secrets* *.pyc data/* local/* diff --git a/Pipfile b/Pipfile index c50dea4..4639c37 100644 --- a/Pipfile +++ b/Pipfile @@ -7,6 +7,8 @@ verify_ssl = true [packages] requests = "*" +click = "*" +attrs = "*" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock index 1fc79f4..1b7c2af 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "bb57e0d7853b45999e47c163c46b95bc2fde31c527d8d7b5b5539dc979444a6d" + "sha256": "01dc55cd69a2df69f74a7428d6c916635a02376ce9d212768bbb2065001068d1" }, "pipfile-spec": 6, "requires": { @@ -16,12 +16,20 @@ ] }, "default": { + "attrs": { + "hashes": [ + "sha256:69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79", + "sha256:f0b870f674851ecbfbbbd364d6b5cbdff9dcedbc7f3f5e18a6891057f21fe399" + ], + "index": "pypi", + "version": "==19.1.0" + }, "certifi": { "hashes": [ - "sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", - "sha256:b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae" + "sha256:046832c04d4e752f37383b628bc601a7ea7211496b4638f6514d0e5b9acc4939", + "sha256:945e3ba63a0b9f577b1395204e13c3a231f9bc0223888be653286534e5873695" ], - "version": "==2019.3.9" + "version": "==2019.6.16" }, "chardet": { "hashes": [ @@ -30,6 +38,14 @@ ], "version": "==3.0.4" }, + "click": { + "hashes": [ + "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13", + "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7" + ], + "index": "pypi", + "version": "==7.0" + }, "idna": { "hashes": [ "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", @@ -39,18 +55,18 @@ }, "requests": { "hashes": [ - "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", - "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" + "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", + "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" ], "index": "pypi", - "version": "==2.21.0" + "version": "==2.22.0" }, "urllib3": { "hashes": [ - "sha256:4c291ca23bbb55c76518905869ef34bdd5f0e46af7afe6861e8375643ffee1a0", - "sha256:9a247273df709c4fedb38c711e44292304f73f39ab01beda9f6b9fc375669ac3" + "sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", + "sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232" ], - "version": "==1.24.2" + "version": "==1.25.3" } }, "develop": {}