fjxmlzn / FindMyHistory

Track your Apple devices and look up their past location, battery levels, and more
MIT License
308 stars 34 forks source link

curses.error when running as a service, main.py seems fail when it can't output to a terminal #20

Open emilyboda opened 1 year ago

emilyboda commented 1 year ago

I'm using this handy guide to have main.py run as a service. I want main.py to run when the Mac is booted. One quick thing to note, to make this work I had to go into the Security and Privacy settings on Mac and give Python full disk access.

When I try to run main.py as a service, I get this error:

Traceback (most recent call last):
  File "/Users/boda/Documents/FindMyHistory/main.py", line 125, in <module>
    curses.wrapper(partial(main, args=args))
  File "/usr/local/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/curses/__init__.py", line 73, in wrapper
    stdscr = initscr()
             ^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/curses/__init__.py", line 29, in initscr
    setupterm(term=_os.environ.get("TERM", "unknown"),
_curses.error: setupterm: could not find terminal

When I run main.py directly from the terminal I don't get this error. I can't figure out what's going on. When I run echo $TERM I get xterm-256color.

I think this might be an issue with the curses package, but I'm not familiar with how it works. Is it possible to modify the last line of main.py curses.wrapper(partial(main, args=args)) so that it doesn't fail if it can't output the result to a terminal?