Skip to content

Commit

Permalink
moved logs to user home dir (#315)
Browse files Browse the repository at this point in the history
* moved logs to user home dir

---------

Co-authored-by: Josef Haupt <[email protected]>
  • Loading branch information
Josef-Haupt and Josef Haupt authored Apr 17, 2024
1 parent 8b1da28 commit a1fbf62
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion BirdNET-Anaylzer-setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DisableProgramGroupPage=yes
LicenseFile=LICENSE
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=commandline
PrivilegesRequiredOverridesAllowed=commandline dialog
OutputDir=installers
OutputBaseFilename=BirdNET-Analyzer-setup
SetupIconFile=docs\favicon.ico
Expand Down
29 changes: 24 additions & 5 deletions gui.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
import concurrent.futures
import os
import sys
from pathlib import Path

import config as cfg

if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
# divert stdout & stderr to logs.txt file since we have no console when deployed
sys.stderr = sys.stdout = open("logs.txt", "w")
userdir = Path.home()

if sys.platform == "win32":
userdir /= "AppData/Roaming"
elif sys.platform == "linux":
userdir /= ".local/share"
elif sys.platform == "darwin":
userdir /= "Library/Application Support"

logsdir = userdir / "BirdNET-Analyzer-GUI"

try:
logsdir.mkdir(parents=True)
except FileExistsError:
pass

sys.stderr = sys.stdout = open(str(logsdir / "logs.txt"), "w")
cfg.ERROR_LOG_FILE = str(logsdir / cfg.ERROR_LOG_FILE)


import multiprocessing
from pathlib import Path

import gradio as gr
import librosa
import webview

import analyze
import config as cfg
import segments
import species
import utils
Expand Down Expand Up @@ -946,8 +965,8 @@ def select_directory_on_empty():

if res[1]:
if len(res[1]) > 100:
return [res[0], res[1][:100] + [["..."]]] # hopefully fixes issue#272
return [res[0], res[1][:100] + [["..."]]] # hopefully fixes issue#272

return res

return [res[0], [["No files found"]]]
Expand Down

0 comments on commit a1fbf62

Please sign in to comment.