Repository: scoutapp/scout_apm_python
Pull request #479 (2020-02-17 14:17:28)

Move to PyPI API token
As per https://pyfound.blogspot.com/2020/01/start-using-2fa-and-api-tokens-on-pypi.html .



Patch:
diff --git a/.travis.yml b/.travis.yml
index 517b984..2c733a2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -40,9 +40,9 @@ jobs:
       env:
         - CIBW_SKIP="cp33-*"
         - TWINE_NON_INTERACTIVE=1
-        - TWINE_USERNAME=scout
+        - TWINE_USERNAME=__token__
         # TWINE_PASSWORD:
-        - secure: "ohvspT59/b71SdnIFf/HA5552tGaYWLYTUV2IQ/ZNxrTiJd/hcm5eBbfAkOUiC6l2cxdHt+cAyRh27us32z7F29qzlSzrWkTD18pvFKjSGtaa2X0aBTiollfiGgiXpdT5wiDoyjyGWti3q4CpwOZjrpB/rZx0DUxdRejf0cQfs/6W8xqei/PeSTAY+58eRxKUo9JOsEObDgpjJFSWTHVip6Rm0C8zG5fEal6OEMozP+LncSzxIPZiaA0x82nYSMSBQiJXqgX6x1iNDUVl9W1wwghPjCxhz1n6kUtoKOnLcz2VhtmzR+rFDXcdgIr3l9HsSaj8t/jRIPwyUuB1DDamKWuEC0dFrqeTraOKz/t7eZkSpKa+jRaNUC4RLPSSNJVC3hEH8WlNIAyCGyvYv0RAGEYzrWcl0QZQgn1s205uIVKF8v3bepAV4oPUOEjhAk3+kVhBDLrUHWnDtLzQxPJOcC/PpMIkXx5+ZCADJrkmppEAtv+gAbHIE5gcodvyGgUc1ynp/Ul2LQxUX7KUopZBkBtFomRJWOXli5rV9tc8It+m91Xua6+jRB8UePyHw2KLGoABulNNoGSvr+uRdH8Ph/4des33iikTEnEDBk740NAsMW1pExMMlXAdaYScpBjCu7z3MrSCs4oraCVJ1g9nqbc7ugxVqMPC97fu7XKpe8="
+        - secure: "M4qjfKwZzEEGFLnOOuxcWzL7QibJmbg28uHw0puN2UzwUHBMLmgIMHcBVExMF8GmzFy3Wd1CFPukBRSvgAnxI8q42SlGXczs6GzAEPuNs9f+DkUEq2QC4msPTTyEyPVxHPwSJAvbg9kBOR+ELtQnaZg+xOlS4RAsqCqOS6bNMFMLf7jop44r7w441ZCaOLs4doI9T1hqq3XWRJ9YyP3KEPy3kMs343r9oURE+z7lqzJ3OYXLCml/ZdsHjDQI3kQja3q3PIotJK3brUMXBF+p9ECrVQwtolU2TNh4rO93m2O9EvMacEunlXoW6JB9/tXi/9K0Gee5KXtOfGu4I11GbWlj7FcExxLy+axI3i1r22mF1eer7aalid+6xFP7/UTJivvLaYpxPyMGBF7muUnqflhyQA1UpWc0z7jmY+IjjvBwJ/HGGkK1Du6xP9tP0Ksw97n7Fqo1XHNIm2IevJl2Jqp5hgl/FjcpJRMhYerITcbiYnj9MwlwvRYL6bvRIca29PoC7CwBXGzc6xBQwwnsq2RWbUnENmvjjJFvYX+nteuPUEeDHhQApPngXG4Nqf+dszouNlyIcDl4r1tRnLjBernDealGhmbR6fpW+eBt17LA3WKUKqRnTyeQN7ckIW+nOCCOsizH59dooOTtFu+P26KnmokpP9M3YcA8c9rk1tA="
       script:
         - python setup.py sdist
         - pip install --upgrade cibuildwheel twine
diff --git a/src/scout_apm/bottle.py b/src/scout_apm/bottle.py
index 44e73b8..e81a18f 100644
--- a/src/scout_apm/bottle.py
+++ b/src/scout_apm/bottle.py
@@ -22,10 +22,12 @@ class ScoutPlugin(object):
 
     def set_config_from_bottle(self, app):
         bottle_configs = {}
-        for key in scout_config.known_keys():
-            value = app.config.get("scout.{}".format(key))
-            if value is not None and value != "":
-                bottle_configs[key] = value
+        prefix = "scout."
+        prefix_len = len(prefix)
+        for key, value in app.config.items():
+            if key.startswith(prefix) and len(key) > prefix_len:
+                scout_key = key[prefix_len:]
+                bottle_configs[scout_key] = value
         scout_config.set(**bottle_configs)
 
     def setup(self, app):


Test patch:
diff --git a/tests/integration/test_bottle.py b/tests/integration/test_bottle.py
index 5189f7c..f87583e 100644
--- a/tests/integration/test_bottle.py
+++ b/tests/integration/test_bottle.py
@@ -10,6 +10,7 @@ from webtest import TestApp
 from scout_apm.api import Config
 from scout_apm.bottle import ScoutPlugin
 from scout_apm.compat import datetime_to_timestamp, kwargs_only
+from scout_apm.core.config import scout_config
 from tests.integration.util import (
     parametrize_filtered_params,
     parametrize_queue_time_header_name,
@@ -67,6 +68,20 @@ def app_with_scout(config=None, catchall=False):
         Config.reset_all()
 
 
+def test_config_copied():
+    with app_with_scout(config={"scout.foo": "bar"}):
+        value = scout_config.value("foo")
+
+    assert value == "bar"
+
+
+def test_empty_config_not_copied():
+    with app_with_scout(config={"scout.": "foo"}):
+        value = scout_config.value("")
+
+    assert value is None
+
+
 def test_home(tracked_requests):
     with app_with_scout() as app:
         response = TestApp(app).get("/")