mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-02-06 15:05:00 +00:00
Merge pull request #27 from gnh1201/importlib_with_env
Change the `Extension.register()` process / 확장 등록 프로세스 변경
This commit is contained in:
commit
83b46d3ede
|
@ -36,6 +36,7 @@ CERT_KEY=cert.key
|
|||
CERT_DIR=certs/
|
||||
OPENSSL_BINPATH=openssl
|
||||
CLIENT_ENCODING=utf-8
|
||||
USE_EXTENSIONS=wayback.Wayback,bio.PyBio
|
||||
```
|
||||
|
||||
- (Optional) Create a certificate for SSL decryption
|
||||
|
|
9
base.py
9
base.py
|
@ -7,7 +7,7 @@
|
|||
# Namyheon Go (Catswords Research) <gnh1201@gmail.com>
|
||||
# https://github.com/gnh1201/caterpillar
|
||||
# Created at: 2024-05-20
|
||||
# Updated at: 2024-07-06
|
||||
# Updated at: 2024-07-09
|
||||
#
|
||||
|
||||
import hashlib
|
||||
|
@ -72,13 +72,16 @@ class Extension():
|
|||
cls.buffer_size = _buffer_size
|
||||
|
||||
@classmethod
|
||||
def register(cls, module_path, class_name):
|
||||
def register(cls, s):
|
||||
module_name, class_name = s.strip().split('.')[0:2]
|
||||
module_path = 'plugins.' + module_name
|
||||
|
||||
try:
|
||||
module = importlib.import_module(module_path)
|
||||
_class = getattr(module, class_name)
|
||||
cls.extensions.append(_class())
|
||||
except (ImportError, AttributeError) as e:
|
||||
raise ImportError(class_name + " in " + module_path)
|
||||
raise ImportError(class_name + " in the extension " + module_name)
|
||||
|
||||
@classmethod
|
||||
def get_filters(cls):
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# Namyheon Go (Catswords Research) <gnh1201@gmail.com>
|
||||
# https://github.com/gnh1201/caterpillar
|
||||
# Created at: 2022-10-06
|
||||
# Updated at: 2024-07-04
|
||||
# Updated at: 2024-07-09
|
||||
#
|
||||
|
||||
import argparse
|
||||
|
@ -47,6 +47,7 @@ try:
|
|||
client_encoding = config('CLIENT_ENCODING', default='utf-8')
|
||||
local_domain = config('LOCAL_DOMAIN', default='')
|
||||
proxy_pass = config('PROXY_PASS', default='')
|
||||
use_extensions = config('USE_EXTENSIONS', default='')
|
||||
except KeyboardInterrupt:
|
||||
print("\n[*] User has requested an interrupt")
|
||||
print("[*] Application Exiting.....")
|
||||
|
@ -498,10 +499,8 @@ def start(): #Main Program
|
|||
|
||||
if __name__== "__main__":
|
||||
# load extensions
|
||||
#Extension.register("plugins.fediverse", "Fediverse")
|
||||
#Extension.register("plugins.container", "Container")
|
||||
Extension.register("plugins.wayback", "Wayback")
|
||||
#Extension.register("plugins.bio", "PyBio")
|
||||
for s in use_extensions.split(','):
|
||||
Extension.register(s)
|
||||
|
||||
# start Caterpillar
|
||||
start()
|
||||
|
|
5
web.py
5
web.py
|
@ -7,7 +7,7 @@
|
|||
# Namyheon Go (Catswords Research) <gnh1201@gmail.com>
|
||||
# https://github.com/gnh1201/caterpillar
|
||||
# Created at: 2024-05-20
|
||||
# Updated at: 2024-07-06
|
||||
# Updated at: 2024-07-10
|
||||
#
|
||||
|
||||
from flask import Flask, request, redirect, url_for, render_template
|
||||
|
@ -94,6 +94,7 @@ if __name__ == "__main__":
|
|||
Extension.set_protocol('http')
|
||||
|
||||
# load extensions
|
||||
#Extension.register("plugins.YOUR_OWN_MODULE_NAME", "YOUR_OWN_CLASS_NAME");
|
||||
for s in use_extensions.split(','):
|
||||
Extension.register(s)
|
||||
|
||||
app.run(debug=True, host='0.0.0.0', port=listening_port)
|
||||
|
|
Loading…
Reference in New Issue
Block a user