thess / callattendant

A python-based automated call attendant, call blocker, and voice messaging system running on a Raspberry Pi or equivalent. Screens callers and block robocalls and scams with a low-cost system and modem.
https://thess.github.io/callattendant/
MIT License
11 stars 5 forks source link

Problem trying to use Early 2.0 #44

Closed whitedavidp closed 6 days ago

whitedavidp commented 1 week ago

I think I have done things right. And I have configured the MQTT items to send caller id info.

But when a call comes in, CA crashes and I see this:

May 05 11:06:21 callattendant[6151]: > New call log entry #539
May 05 11:06:21 callattendant[6151]: ['WIRELESS CALLER',
May 05 11:06:21 callattendant[6151]:  'xxxxxxxxxx',
May 05 11:06:21 callattendant[6151]:  'Permitted',
May 05 11:06:21 callattendant[6151]:  'Mobile',
May 05 11:06:21 callattendant[6151]:  '05-May',
May 05 11:06:21 callattendant[6151]:  '11:06 AM',
May 05 11:06:21 callattendant[6151]:  '2024-05-05 11:06:21']
May 05 11:06:21 callattendant[6151]: RuntimeError('Working outside of application context.\n\nThis typically means that you attempted to use functionality that needed\nthe current application. To solve this, set up an application context\nwith app.app_context(). See the documentation for more information.')
May 05 11:06:21 callattendant[6151]: ** Error running callattendant
May 05 11:06:21 callattendant[6151]: Shutting down...
May 05 11:06:21 callattendant[6151]: -> Stopping modem
May 05 11:06:21 callattendant[6151]: Modem thread exiting
May 05 11:06:21 callattendant[6151]: -> Closing modem serial port
May 05 11:06:21 callattendant[6151]: -> Stopping voice mail
May 05 11:06:21 callattendant[6151]: Message Event triggered
May 05 11:06:21 callattendant[6151]: -> Releasing resources
May 05 11:06:21 callattendant[6151]: -> Stopping MQTT client
May 05 11:06:21 callattendant[6151]: Shutdown finished
May 05 11:06:21 systemd[1]: callattendant.service: Main process exited, code=exited, status=1/FAILURE

I have googled "python Working outside of application context" and most of what I see refers to Flask.

Does this ring any bells?

Thanks

whitedavidp commented 1 week ago

BTW - I did as shown here.

thess commented 1 week ago

Well, the application webUI is Flask - so the error was somehow earned. Never seen this before so it was take some digging. In the meantime, some environment information would be a good start.

Was this a fresh install (new venv) or an upgrade? Need to find what version of flask is installed too. Set DEBUG=True and re-test - log may have a better hint where we died.

whitedavidp commented 1 week ago

This was an "upgrade" as shown in your post...

$ source venv/bin/activate
$ pip3 install "callattendant@git+https://github.com/thess/callattendant@mqtt-dev"

but I use pip, not pip3 on my Ubuntu.

Here is a snap on the flask stuff under my site-packages...

Capture

Note that on my Ubuntu, I have only python 3.1 and I saw somewhere that CA is looking for 3.5. I tried to update from 3.1 to 3.5 but 3.5 doesn't seem to be in the repositories for my Ubuntu.

whitedavidp commented 1 week ago

Here is more info. I have found that as long as I leave this config line alone, all works as expected...

MQTT_CALLERID_FORMAT = "RAW"

Change it to "DISPLAY" and the above reported problem occurs...

I can live with it this way. Best

thess commented 1 week ago

but I use pip, not pip3 on my Ubuntu.

In most Python 3 installations now-a-days pip and pip3 are the same - as is python and python3 (they are links)

I have only python 3.1 and I saw somewhere that CA is looking for 3.5.

You are using Python 3.10 not 3.1 - so no need to downgrade to 3.5 (min required)

The part about using DISPLAY for CALLERID_FORMAT is a big hint - thanks. Stay tuned.

whitedavidp commented 1 week ago

As always thanks. I am getting old and in the way - can't ever read any more :-(

whitedavidp commented 1 week ago

FYI - moved to 2.0.1 and changed to DISPLAY. No longer crashing. Most excellent!

thess commented 1 week ago

Thanks for verifying the fix. Will close this after 2.x release

thess commented 6 days ago

V2.0.4 released