update apphub

This commit is contained in:
zhaojing1987 2024-01-10 10:31:16 +08:00
parent dd1fc361d1
commit 973e85349e
5 changed files with 48 additions and 9 deletions

View file

@ -1,22 +1,22 @@
[nginx_proxy_manager]
base_url = http://websoft9-proxy:81/api
user_name = help@websoft9.com
user_pwd = nIhBWI96qlXRyn5I
user_pwd = gtBi82ljgJLOBdIv
nike_name = admin
[gitea]
base_url = http://websoft9-git:3000/api/v1
user_name = websoft9
user_email = help@websoft9.com
user_pwd = 7iWUyLn103aH
user_pwd = lDaCDO8gASjB
[portainer]
base_url = http://websoft9-deployment:9000/api
user_name = admin
user_pwd = j4FYLqfisbv4vkYY
user_pwd = p$(kww3otq8aTMnN
[api_key]
key = 3553f2f8746a7a59a98b7c1fd0f3410bc347f6af3eeb1aa6df130848bbb7785f
key = 8b13560946c48e6f545a9adcf33c3441f798c59a81b3f241bdfeb179cfbc0ff8
[domain]
wildcard_domain = test.websoft9.cn

View file

@ -1,7 +1,5 @@
import requests
from src.core.logger import logger
class APIHelper:
"""
Helper class for making API calls

View file

@ -54,8 +54,10 @@ class Logger(metaclass=SingletonMeta):
log_folder = os.path.join(os.getcwd(), "logs")
os.makedirs(log_folder, exist_ok=True)
current_time = datetime.now().strftime('%Y_%m_%d')
log_file = os.path.join(log_folder, f"{log_type}_{current_time}.log")
# current_time = datetime.now().strftime('%Y_%m_%d')
# log_file = os.path.join(log_folder, f"{log_type}_{current_time}.log")
log_file = os.path.join(log_folder, f"apphub_{log_type}.log")
file_handler = TimedRotatingFileHandler(
filename=log_file,

View file

@ -402,6 +402,12 @@ class AppManger:
envHelper.set_value("W9_DIST", "community")
envHelper.set_value("W9_VERSION", app_version)
# Verify if a rcode needs to be set
is_set_rcode = envHelper.get_value("W9_RCODE")
if is_set_rcode is not None:
# Set the rcode to env file
envHelper.set_value("W9_RCODE", PasswordGenerator.generate_random_string_with_rules(12))
# Verify if a password needs to be set
is_set_password = envHelper.get_value("W9_POWER_PASSWORD")
if is_set_password is not None:

View file

@ -47,3 +47,36 @@ class PasswordGenerator:
"""
characters = string.ascii_lowercase + string.digits
return ''.join(random.choice(characters) for _ in range(length))
@staticmethod
def generate_random_string_with_rules(min_length:int=8):
"""
Generate a random string with at least two uppercase letters, and a mix of lowercase letters and digits.
Args:
min_length (int, optional): Minimum length of the string. Defaults to 8.
Returns:
str: A random string with the specified rules.
"""
# At least two uppercase letters
uppercase_chars = ''.join(random.choices(string.ascii_uppercase, k=2))
# At least one lowercase letter
lowercase_char = random.choice(string.ascii_lowercase)
# At least one digit
digit_char = random.choice(string.digits)
# Ensure the total length is met, subtract 3 for the mandatory characters
remaining_length = max(min_length - 3, 1) # Ensure there's room for additional characters
# The rest can be a mix of uppercase, lowercase, and digits
other_chars = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase + string.digits, k=remaining_length))
# Combine and shuffle
password_list = list(uppercase_chars + lowercase_char + digit_char + other_chars)
random.shuffle(password_list)
# Convert list to string
return ''.join(password_list)