-
Notifications
You must be signed in to change notification settings - Fork 0
Feature implement config file override for webqueue2api configs #46
Merged
campb303
merged 8 commits into
staging
from
feature-implement-config-file-override-for-webqueue2api-configs
Aug 2, 2021
+22
−2
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3ec46b8
Added basic logic to check if the webqueue2api_config file exists in …
benne238 7dc383b
Logic to overwrite the queue_directory if the configuration file cont…
benne238 b11d2a8
Logic to overwrite the queues_to_ignore if it exists in the configura…
benne238 e8115fc
Added logic to overwrite the environment variable if it exists in the…
benne238 0a30503
Added logic to overwrite the jwt_secret_key if the variable exists in…
benne238 462182d
Simplify config overrides and change config ext
campb303 1600b7c
Fix config environment reference
campb303 0c4523f
Remove testing config and rename config ext
campb303 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,24 @@ | ||
from webqueue2api.parser import Item, Queue, load_queues | ||
from .config import config | ||
from .config import config | ||
import configparser, sys | ||
from pathlib import Path as path | ||
import webqueue2api.parser | ||
import webqueue2api.api | ||
|
||
config_parser_object = configparser.ConfigParser() | ||
config_file_location = path.joinpath(path(sys.executable).parent.parent.parent, "webqueue2api_config") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename |
||
|
||
if path(config_file_location).exists(): | ||
config_parser_object.read(config_file_location) | ||
|
||
if config_parser_object.has_section("parser"): | ||
if config_parser_object.has_option("parser", "queue_directory"): | ||
webqueue2api.parser.config.queue_directory = config_parser_object["parser"]["queue_directory"] | ||
if config_parser_object.has_option("parser", "queues_to_ignore"): | ||
webqueue2api.parser.config.queues_to_ignore = config_parser_object["parser"]["queues_to_ignore"] | ||
|
||
if config_parser_object.has_section("api"): | ||
if config_parser_object.has_option("api", "environment"): | ||
webqueue2api.api.config.environment = config_parser_object["api"]["environment"] | ||
if config_parser_object.has_option("api", "jwt_secret_key"): | ||
webqueue2api.api.config.jwt_secret_key = config_parser_object["api"]["jwt_secret_key"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename
config_parser_object
toconfig_parser