chore: Improve script import mechanism and remove boilerplate
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import init_paths
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import re
|
||||
from datetime import datetime
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
from db.database import db
|
||||
|
||||
def add_user(username, traffic_gb, expiration_days, password=None, creation_date=None, unlimited_user=False):
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import init_paths
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import argparse
|
||||
import re
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
from db.database import db
|
||||
|
||||
def add_bulk_users(traffic_gb, expiration_days, count, prefix, start_number, unlimited_user):
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import init_paths
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
from db.database import db
|
||||
|
||||
def edit_user(username, new_username=None, new_password=None, traffic_gb=None, expiration_days=None, creation_date=None, blocked=None, unlimited_user=None):
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import init_paths
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
import getopt
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
from db.database import db
|
||||
|
||||
def get_user_info(username):
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import init_paths
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
@ -7,8 +8,6 @@ import fcntl
|
||||
import datetime
|
||||
import logging
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
from db.database import db
|
||||
from hysteria2_api import Hysteria2Client
|
||||
from paths import CONFIG_FILE
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import init_paths
|
||||
import sys
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
from hysteria2_api import Hysteria2Client
|
||||
except ImportError:
|
||||
sys.exit("Error: hysteria2_api library not found. Please install it.")
|
||||
|
||||
sys.path.append(str(Path(__file__).resolve().parent.parent))
|
||||
from db.database import db
|
||||
from paths import CONFIG_FILE, API_BASE_URL
|
||||
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import init_paths
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
from db.database import db
|
||||
|
||||
def remove_user(username):
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import init_paths
|
||||
import sys
|
||||
import os
|
||||
from datetime import date
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
from db.database import db
|
||||
|
||||
def reset_user(username):
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import init_paths
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
@ -9,7 +10,6 @@ import re
|
||||
import qrcode
|
||||
from io import StringIO
|
||||
from typing import Tuple, Optional, Dict, List, Any
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
from db.database import db
|
||||
from paths import *
|
||||
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import init_paths
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import argparse
|
||||
from functools import lru_cache
|
||||
from typing import Dict, List, Any
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
from db.database import db
|
||||
from paths import *
|
||||
|
||||
|
||||
Reference in New Issue
Block a user