Skip to content

Commit

Permalink
load additional plugs on manager startup (#2537)
Browse files Browse the repository at this point in the history
* load additional plugs on manager startup

* cleanup
  • Loading branch information
sainak authored Oct 14, 2024
1 parent a7fb6ea commit 02c9056
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
15 changes: 0 additions & 15 deletions install_plugins.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
import json
import logging
import os

from plug_config import manager
from plugs.plug import Plug

logger = logging.getLogger(__name__)


if ADDITIONAL_PLUGS := os.getenv("ADDITIONAL_PLUGS"):
try:
for plug in json.loads(ADDITIONAL_PLUGS):
manager.add_plug(Plug(**plug))
except json.JSONDecodeError:
logger.error("ADDITIONAL_PLUGS is not a valid JSON")

manager.install()
13 changes: 13 additions & 0 deletions plugs/manager.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import json
import logging
import os
import subprocess
import sys
from collections import defaultdict

from plugs.plug import Plug

logger = logging.getLogger(__name__)


class PlugManager:
"""
Expand All @@ -13,6 +18,14 @@ class PlugManager:
def __init__(self, plugs: list[Plug]):
self.plugs: list[Plug] = plugs

# load additional plugs from environment variable
if additional_plugs := os.getenv("ADDITIONAL_PLUGS"):
try:
for plug in json.loads(additional_plugs):
self.add_plug(Plug(**plug))
except json.JSONDecodeError:
logger.error("ADDITIONAL_PLUGS is not a valid JSON")

def install(self) -> None:
packages: list[str] = [f"{x.package_name}{x.version}" for x in self.plugs]
if packages:
Expand Down

0 comments on commit 02c9056

Please sign in to comment.