Skip to content

Commit

Permalink
Add default logs folder and allow user to change it
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledk2 committed Feb 21, 2024
1 parent 3d4fe02 commit a237f8e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
20 changes: 17 additions & 3 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,16 @@ def get_search_terms_froget_all_indexes_from_elasticsearchm_log(logs_folder=None

@manager.command
@manager.option("-p", "--password", help="username password to be hashed")
def create_hash_password_for_admin(password):
def create_hash_password_for_admin(password=None):
from werkzeug.security import generate_password_hash

h_pass = generate_password_hash(password)
add_admin_hashed_password(h_pass)
if password:
h_pass = generate_password_hash(password)
print(h_pass)
print("==============")
add_admin_hashed_password(h_pass)
else:
search_omero_app.logger.info("No attribute is provided")


@manager.command
Expand All @@ -389,5 +394,14 @@ def add_admin_hashed_password(sh_password=None):
search_omero_app.logger.info("No attribute is provided")


@manager.command
@manager.option("-l", "--logs_folder", help="hased password")
def set_logs_folder(logs_folder=None):
if logs_folder:
update_config_file({"SEARCHENGINE_LOGS_FOLDER": logs_folder})
else:
search_omero_app.logger.info("No attribute is provided")


if __name__ == "__main__":
manager.run()
7 changes: 7 additions & 0 deletions omero_search_engine/api/stats/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def search_terms():
each resource has a sheet inside the excel book
"""
logs_folder = search_omero_app.config.get("SEARCHENGINE_LOGS_FOLDER")
if not logs_folder or not os.path.isdir(logs_folder):
logs_folder = "/etc/searchengine/logs"
if not os.path.isdir(logs_folder):
logs_folder = os.path.expanduser("~/logs")
if not os.path.isdir(logs_folder):
return "No logs files are found"

max_top_values = request.args.get("return_values")
if not max_top_values:
max_top_values = 5
Expand Down

0 comments on commit a237f8e

Please sign in to comment.