diff --git a/app/funct.py b/app/funct.py index 53f1cdf6..2cad4a82 100644 --- a/app/funct.py +++ b/app/funct.py @@ -11,9 +11,17 @@ from configparser import ConfigParser, ExtendedInterpolation form = cgi.FieldStorage() serv = form.getvalue('serv') +def get_app_dir(): + d = sys.path[0] + d = d.split('/')[-1] + if d == "app": + return sys.path[0] + else: + return os.path.dirname(sys.path[0]) + def get_config_var(sec, var): try: - path_config = "haproxy-webintarface.config" + path_config = get_app_dir()+"/haproxy-webintarface.config" config = ConfigParser(interpolation=ExtendedInterpolation()) config.read(path_config) except: diff --git a/app/viewlogs.py b/app/viewlogs.py index 7046e4b1..39ae8741 100644 --- a/app/viewlogs.py +++ b/app/viewlogs.py @@ -1,11 +1,10 @@ #!/usr/bin/env python3 -import os -import sql +import os, sys import http, cgi -import funct -import sql import glob import datetime +import funct +import sql from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('templates/')) template = env.get_template('logs.html') @@ -52,7 +51,7 @@ except: def get_files(): file = [] - for files in glob.glob(os.path.join(log_path,'*.log')): + for files in glob.glob(os.path.join(log_path,'*.log*')): file += [(files.split('/')[5], files.split('/')[5])] return sorted(file, reverse=True)