I have a few imports and statements needed to get some crypto modules from gdata to load into my GAE Python SDK:
from google.appengine.tools.dev_appserver import HardenedModulesHook
HardenedModulesHook._WHITE_LIST_C_MODULES += ['_counter']
But this import does not work (nor is it needed) while deployed on GAE, only local.
How can I test if the code is running on GAE or local so I can conditionally perform this import or other local-specific stuff?
If the import actually doesn’t work because it throws an
ImportErrorthen your best choice it to just try/except the error.You could just
passin the except block but doing it this way lets you check theHardenedModulesHookreference and perform some application logic.