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