-
Notifications
You must be signed in to change notification settings - Fork 25
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
10 changed files
with
92 additions
and
9 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
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,3 1,5 @@ | ||
from main.libs.task import jobs | ||
|
||
""" | ||
警告: | ||
本文件内所有内容均属于敏感信息 | ||
|
@@ -25,6 27,7 @@ class Base(object): | |
MAIL_USERNAME = "[email protected]" # 邮箱账户 | ||
MAIL_PASSWORD = "" # 邮箱密码或授权码 | ||
|
||
JOBS = jobs | ||
|
||
class PriProduction(Base): | ||
""" | ||
|
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,33 @@ | ||
import datetime | ||
|
||
from main.models.exts import scheduler | ||
from main.libs.db_api import UserNodesTable, UserTable | ||
|
||
|
||
def check_user(): | ||
with scheduler.app.app_context(): | ||
user_api = UserTable() | ||
user_node_api = UserNodesTable() | ||
|
||
for i in user_api.get_all_user(): | ||
username = i["username"] | ||
quota = i.get("quota") | ||
expiry_date = i.get("expiry_date") | ||
nodes = user_node_api.get_node_for_user_name(username) | ||
user_node_api.restore_user_traffic(username, nodes) | ||
if expiry_date and expiry_date < datetime.datetime.now(): | ||
if expiry_date < datetime.datetime.now(): | ||
user_node_api.limit_user_traffic(username, nodes) | ||
if quota > 0: | ||
total = user_api.get_user_use(username, nodes) | ||
if (quota * 1024 * 1024 * 1024) < total: | ||
user_node_api.limit_user_traffic(username, nodes) | ||
|
||
|
||
jobs = [{ | ||
'id': 'check_user', | ||
'func': check_user, | ||
'trigger': 'cron', | ||
'hour': 21, | ||
'minute': 33 | ||
}] |
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,5 1,8 @@ | ||
from flask_sqlalchemy import SQLAlchemy | ||
from flask_bcrypt import Bcrypt | ||
from flask_apscheduler import APScheduler | ||
|
||
|
||
bcrypt = Bcrypt() | ||
db = SQLAlchemy() | ||
bcrypt = Bcrypt() | ||
scheduler = APScheduler() |
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
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
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 |
---|---|---|
|
@@ -2,6 2,7 @@ Flask | |
Flask-Bcrypt | ||
Flask-Cors | ||
Flask-SQLAlchemy | ||
Flask-Apscheduler | ||
PyMySQL | ||
requests | ||
uWSGI |