Skip to content

Commit

Permalink
Applying changes to get_installation_url and check_api_endpoint funct…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
jggautier committed Dec 24, 2023
1 parent e04ad92 commit 35f417e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def __init__(self, theWindow, *args, **options):
progressLabel=self.labelProgressTextDeleteDatasets,
notDeletedText=self.notDeletedText,
notDeletedLabel=self.labelNotDeletedDatasets,
installationUrl=get_installation_url(self.comboboxInstallationUrl.get().strip()),
installationUrl=check_installation_url_status(self.comboboxInstallationUrl.get().strip())['installationUrl'],
datasetPidString=self.textBoxCollectionDatasetPIDs.get('1.0', END),
apiKey=self.entryApiToken.get().strip()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def __init__(self, theWindow, *args, **options):
text='Get locked datasets report',
bg=appPrimaryGreyColor, fg='white',
command=lambda: save_locked_dataset_report(
installationUrl=get_installation_url(self.comboboxInstallationUrl.get().strip()),
installationUrl=check_installation_url_status(self.comboboxInstallationUrl.get().strip())['installationUrl'],
apiKey=self.entryApiToken.get().strip(),
# self.entryApiToken.get().strip()
directoryPath=get_directory_path()) # function that asks user for directory
Expand Down Expand Up @@ -288,7 +288,7 @@ def __init__(self, theWindow, *args, **options):
progressLabel=self.labelProgressTextGetMetadata,
notUnlockedText=self.fieldsWithNoMetadataText,
notUnlockedLabel=self.labelFieldsWithNoMetadata,
installationUrl=get_installation_url(self.comboboxInstallationUrl.get().strip()),
installationUrl=check_installation_url_status(self.comboboxInstallationUrl.get().strip())['installationUrl'],
datasetPidString=self.textBoxCollectionDatasetPIDs.get('1.0', END),
# parentFieldTitleList=get_listbox_values(self.listboxSelectFieldNames),
# directoryPath=get_directory_path(), # function that asks user for directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def __init__(self, theWindow, *args, **options):
bg=appPrimaryGreyColor, fg='white',
command=lambda: get_parent_field_names(
metadatablockData=get_metadatablock_data(
installationUrl=get_installation_url(self.comboboxInstallationUrl.get().strip()),
installationUrl=check_installation_url_status(self.comboboxInstallationUrl.get().strip())['installationUrl'],
metadatablockName='citation'),
listbox=self.listboxSelectFieldNames))

Expand Down Expand Up @@ -437,7 +437,7 @@ def __init__(self, theWindow, *args, **options):
progressLabel=self.labelProgressTextGetMetadata,
noMetadataText=self.fieldsWithNoMetadataText,
noMetadataLabel=self.labelFieldsWithNoMetadata,
installationUrl=get_installation_url(self.comboboxInstallationUrl.get().strip()),
installationUrl=check_installation_url_status(self.comboboxInstallationUrl.get().strip())['installationUrl'],
datasetPidString=self.textBoxCollectionDatasetPIDs.get('1.0', END),
parentFieldTitleList=get_listbox_values(self.listboxSelectFieldNames),
directoryPath=get_directory_path(), # function that asks user for directory
Expand Down
8 changes: 4 additions & 4 deletions other_scripts/get_dataset_metadata_of_all_installations.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def check_exports(jsonDirectory, spreadsheetFilePath):
# Use the "Get Version" endpoint to get installation's Dataverse version (or set version as 'NA')
getInstallationVersionApiUrl = f'{installationUrl}/api/v1/info/version'
getInstallationVersionApiUrl = getInstallationVersionApiUrl.replace('//api', '/api')
getInstallationVersionApiStatus = check_api_endpoint(getInstallationVersionApiUrl, headers, verify=False, json_response=True)
getInstallationVersionApiStatus = check_api_endpoint(getInstallationVersionApiUrl, headers, verify=False, json_response_expected=True)

if getInstallationVersionApiStatus == 'OK':
response = requests.get(getInstallationVersionApiUrl, headers=headers, timeout=20, verify=False)
Expand All @@ -300,7 +300,7 @@ def check_exports(jsonDirectory, spreadsheetFilePath):
# Check if Search API works for the installation
searchApiCheckUrl = f'{installationUrl}/api/v1/search?q=*&fq=-metadataSource:"Harvested"&type=dataset&per_page=1&sort=date&order=desc'
searchApiCheckUrl = searchApiCheckUrl.replace('//api', '/api')
searchApiStatus = check_api_endpoint(searchApiCheckUrl, headers, verify=False, json_response=True)
searchApiStatus = check_api_endpoint(searchApiCheckUrl, headers, verify=False, json_response_expected=True)

# If Search API works, from Search API query results, get count of local (non-harvested) datasets
if searchApiStatus == 'OK':
Expand Down Expand Up @@ -332,7 +332,7 @@ def check_exports(jsonDirectory, spreadsheetFilePath):
if testDatasetPid != 'NA':
getJsonApiUrl = f'{installationUrl}/api/v1/datasets/:persistentId/?persistentId={testDatasetPid}'
getJsonApiUrl = getJsonApiUrl.replace('//api', '/api')
getDataverseJsonApiStatus = check_api_endpoint(getJsonApiUrl, headers, verify=False, json_response=True)
getDataverseJsonApiStatus = check_api_endpoint(getJsonApiUrl, headers, verify=False, json_response_expected=True)

else:
getDataverseJsonApiStatus = 'NA'
Expand Down Expand Up @@ -374,7 +374,7 @@ def check_exports(jsonDirectory, spreadsheetFilePath):
# Check API endpoint for getting metadatablock data
metadatablocksApiEndpointUrl = f'{installationUrl}/api/v1/metadatablocks'
metadatablocksApiEndpointUrl = metadatablocksApiEndpointUrl.replace('//api', '/api')
getMetadatablocksApiStatus = check_api_endpoint(metadatablocksApiEndpointUrl, headers, verify=False, json_response=True)
getMetadatablocksApiStatus = check_api_endpoint(metadatablocksApiEndpointUrl, headers, verify=False, json_response_expected=True)

metadatablockNames = 'API call failed'

Expand Down

0 comments on commit 35f417e

Please sign in to comment.