Skip to content

Commit

Permalink
docs: consistently rename API key to API token (code unchanged)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Feb 4, 2025
1 parent 0f43362 commit 59291ea
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.16.10
- docs: consistently rename API key to API token (code unchanged)
0.16.9
- enh: don't use global `logging.basicConfig`
- enh: setup INFO logging for `requests` (no more DEBUG logs)
Expand Down
4 changes: 2 additions & 2 deletions dcoraid/api/ckan_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ def get_user_dict(self):
userdata = user
break
else:
raise NoAPIKeyError(
"Could not determine user data. Please check API key.")
raise NoAPIKeyError("Could not determine user data. "
"Please check API token.")
return userdata

def post(self, api_call, data, dump_json=True, headers=None,
Expand Down
2 changes: 1 addition & 1 deletion dcoraid/api/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def dataset_draft_remove_all(api, ignore_dataset_ids=None):
"""Remove all draft datasets
Find and delete all draft datasets for a user. The user
ID is inferred from the API key.
ID is inferred from the API token.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion dcoraid/api/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class APIOutdatedError(APIError):


class NoAPIKeyError(APIError):
"""DCOR does not have an API key"""
"""DCOR does not have an API token"""
pass


Expand Down
2 changes: 1 addition & 1 deletion dcoraid/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def upload_task_parser():
help='DCOR instance to upload to',
default="dcor.mpl.mpg.de")
parser.add_argument('api_key', metavar="API_KEY", type=str,
help='Your DCOR API key or token')
help='Your DCOR API token')
parser.add_argument('--cache_dir', metavar="CACHE_DIR", type=str,
help='Cache directory for data compression')
parser.add_argument('--version', action='version',
Expand Down
2 changes: 1 addition & 1 deletion dcoraid/download/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, api, path_persistent_job_list=None):
"""
self.api = api.copy()
if not api.api_key:
warnings.warn("No API key is set! download may not work!")
warnings.warn("No API token is set! Download may not work!")
self.jobs = []
if path_persistent_job_list is not None:
self.jobs_eternal = PersistentDownloadJobList(
Expand Down
2 changes: 1 addition & 1 deletion dcoraid/gui/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
</action>
<action name="actionSet_API_key">
<property name="text">
<string>Set DCOR API key</string>
<string>Set DCOR API token</string>
</property>
</action>
<action name="actionQuit">
Expand Down
8 changes: 4 additions & 4 deletions dcoraid/gui/preferences/dlg_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def ask_change_server_or_api_key(self):
'DCOR-Aid restart required',
"Changing the server or API token requires a restart of "
+ "DCOR-Aid. If you choose 'No', then the original server "
+ "and API key are NOT changed. Do you really want to quit "
+ "and API token are NOT changed. Do you really want to quit "
+ "DCOR-Aid?",
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
QtWidgets.QMessageBox.No)
Expand Down Expand Up @@ -239,7 +239,7 @@ def on_show_user(self):
self.logger.error(tb.format_exc())
msg = QtWidgets.QMessageBox()
msg.setIcon(QtWidgets.QMessageBox.Warning)
msg.setText("No connection or wrong server or invalid API key!")
msg.setText("No connection or wrong server or invalid API token!")
msg.setWindowTitle("Warning")
msg.setDetailedText(tb.format_exc())
msg.exec_()
Expand Down Expand Up @@ -270,7 +270,7 @@ def on_update_user(self):
self.logger.error(tb.format_exc())
msg = QtWidgets.QMessageBox()
msg.setIcon(QtWidgets.QMessageBox.Warning)
msg.setText("No connection or wrong server or invalid API key!")
msg.setText("No connection or wrong server or invalid API token!")
msg.setWindowTitle("Warning")
msg.setDetailedText(tb.format_exc())
msg.exec_()
Expand Down Expand Up @@ -309,7 +309,7 @@ def on_update_server(self):
self.logger.error(tb.format_exc())
msg = QtWidgets.QMessageBox()
msg.setIcon(QtWidgets.QMessageBox.Critical)
msg.setText("Bad server / API key combination!")
msg.setText("Bad server / API token combination!")
msg.setWindowTitle("Error")
msg.setDetailedText(tb.format_exc())
msg.exec_()
Expand Down
4 changes: 2 additions & 2 deletions dcoraid/gui/status_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ def run(self):
icon = "ban"
elif not api.api_key:
text = "Anonymous"
tip = "Click here to enter your API key."
tip = "Click here to enter your API token."
icon = "user"
elif not api.is_available(with_api_key=True):
text = "API token incorrect"
tip = "Click here to update your API key."
tip = "Click here to update your API token."
icon = "user-times"
else:
try:
Expand Down
10 changes: 5 additions & 5 deletions dcoraid/gui/wizard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def get_dcor_dev_api_key():
"""Return a valid DCOR-dev user API key
"""Return a valid DCOR-dev user API token
If there are no credentials available in the settings file,
then a new user is created on DCOR-dev.
Expand Down Expand Up @@ -90,10 +90,10 @@ def _finalize(self):
or old_api_key != api_key
or old_server != server):
if old_api_key:
msg = "Changing the server or API key requires a restart of " \
+ "DCOR-Aid. If you choose 'No', then the original " \
+ "server and API key are NOT changed. Do you really " \
+ "want to quit DCOR-Aid?"
msg = "Changing the server or API token requires a restart " \
+ "of DCOR-Aid. If you choose 'No', then the original " \
+ "server and API token are NOT changed. Do you " \
+ "really want to quit DCOR-Aid?"
button_reply = QtWidgets.QMessageBox.question(
self,
'DCOR-Aid restart required',
Expand Down
6 changes: 3 additions & 3 deletions dcoraid/gui/wizard/wizard.ui
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Please visit &lt;a href=&quot;https://dcor.mpl.mpg.de/user/register&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://dcor.mpl.mpg.de/user/register&lt;/span&gt;&lt;/a&gt; and create a new user account. You should specify a valid email address in case you lose your password.&lt;/p&gt;&lt;p&gt;After registration, please go to your profile page (click on your name at the top of the page) and copy-paste your API key (located at the bottom of the left panel on your profile page) here:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Please visit &lt;a href=&quot;https://dcor.mpl.mpg.de/user/register&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://dcor.mpl.mpg.de/user/register&lt;/span&gt;&lt;/a&gt; and create a new user account. You should specify a valid email address in case you lose your password.&lt;/p&gt;&lt;p&gt;After registration, please go to your profile page (click on your name at the top of the page) and copy-paste your API token (located at the bottom of the left panel on your profile page) here:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand All @@ -367,7 +367,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>API key</string>
<string>API token</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -405,7 +405,7 @@
<item row="1" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>API key</string>
<string>API token</string>
</property>
</widget>
</item>
Expand Down
2 changes: 1 addition & 1 deletion dcoraid/upload/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def __init__(self, api, path_persistent_job_list=None, cache_dir=None):
self.logger = logging.getLogger(__name__)
self.api = api.copy()
if not api.api_key:
warnings.warn("No API key is set! Upload will not work!")
warnings.warn("No API token is set! Upload will not work!")
self.cache_dir = cache_dir
self.jobs = []
if path_persistent_job_list is not None:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def mw(qtbot):
QtWidgets.QApplication.processEvents(QtCore.QEventLoop.AllEvents, 5000)


@pytest.mark.filterwarnings("ignore::UserWarning", match="No API key is set!")
@pytest.mark.filterwarnings("ignore::UserWarning",
match="No API token is set!")
def test_gui_anonymous(qtbot):
"""Start DCOR-Aid in anonymous mode"""
QtCore.QCoreApplication.setOrganizationName("DCOR")
Expand Down

0 comments on commit 59291ea

Please sign in to comment.