forked from Cl0udG0d/SZhe_Scan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
955 additions
and
244 deletions.
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from flask_sqlalchemy import SQLAlchemy | ||
#专门存放db,防止循环引用问题的出现 | ||
|
||
db=SQLAlchemy() |
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# @Time : 2022/3/26 23:27 | ||
# @Author : Cl0udG0d | ||
# @File : beforeScan.py | ||
# @Github: https://github.com/Cl0udG0d | ||
import importlib | ||
import os | ||
import re | ||
import logging | ||
from pip._internal import main | ||
import sys | ||
|
||
def getPluginDepends(): | ||
pattern = re.compile("^import (.*?)$") | ||
moduleKeys=list(sys.modules.keys()) | ||
currdir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "../plugins/") | ||
for files in os.listdir(currdir): | ||
if os.path.splitext(files)[1] == '.py' and not files.startswith("_"): | ||
filename = os.path.splitext(files)[0] | ||
filepath=currdir+"/"+filename+".py" | ||
logging.info("{} is Checking".format(filepath)) | ||
with open(filepath, 'r') as f: | ||
for line in f.readlines(): | ||
result=pattern.findall(line.strip()) | ||
if result: | ||
name=result[0] | ||
if name and checkLib(name,moduleKeys): | ||
logging.info("{} Lib is Loading".format(name)) | ||
install(name) | ||
else: | ||
print("{} Lib is Loaded".format(name)) | ||
return | ||
|
||
|
||
def install(package,source="https://pypi.tuna.tsinghua.edu.cn/simple"): | ||
main(['install', package,'-i',source]) | ||
|
||
|
||
def checkLib(libName,moduleKeys): | ||
try: | ||
if libName in moduleKeys: | ||
return False | ||
importlib.import_module(libName) | ||
return False | ||
except Exception as e: | ||
logging.warning(e) | ||
return True | ||
|
||
|
||
def test(): | ||
name="import re dd" | ||
pattern=re.compile("^import (.*?)$") | ||
print(pattern.findall(name)) | ||
|
||
|
||
if __name__ == '__main__': | ||
getDepends("../plugins") |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.