platformsh / config-reader-python Goto Github PK
View Code? Open in Web Editor NEWConfiguration reader library for Platform.sh hosting - Python version.
License: MIT License
Configuration reader library for Platform.sh hosting - Python version.
License: MIT License
https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping
particularly the automatic methods from Mapping
such as get
Today, I upgraded from version 2.1.1 to version 2.2.3. The following code started throwing an exception on our queue worker:
def allowed_hosts(self) -> List[str]:
allowed_hosts: List[str] = ["localhost", "127.0.0.1", "[::1]"]
if self.is_valid_platform() and self.in_runtime():
try:
for url, route in self.routes().items():
host: str = urlparse(url).netloc
if (
host not in allowed_hosts
and route["type"] == "upstream"
and route["upstream"] == self.applicationName
):
allowed_hosts.append(host)
except AttributeError:
"""
The Huey worker doesn't have access to routes.
"""
pass
return allowed_hosts
The following exception was raised:
platformshconfig.config.NotValidPlatformException: No routes are defined. Are you sure you are running on Platform.sh?
By replacing AttributeError
with NotValidPlatformException
(and adding the required import
statement), the problem was resolved.
This caused our transactional emails to not be taken out of the queue while I fixed the issue. Not a huge issue this time because I tested manually and discovered the problem quickly, but not ideal either.
In L421 of config.py the prod_branch
variable is set based on whether or not the environment is called master
.
Since Platform.sh now allows for renaming the default / production branch, this no longer produces an accurate value because it can be called anything (defaulting to main
).
A more accurate way of determining whether or not the current branch is a production branch is to query the PLATFORM_ENVIRONMENT_TYPE
environmental variable, which will return the correct environment type regardless of its name.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.