mddub / nightscout-osx-menubar

View Nightscout data in the OS X menu bar.
MIT License
53 stars 42 forks source link

Requires manual refresh for new data? #1

Closed danamlewis closed 9 years ago

danamlewis commented 9 years ago

Menubar correctly pulls in data on configuration, but doesn't automatically refresh. (Going to configure and hitting "ok" pulls in new data, though.)

mddub commented 9 years ago

Oh, weird. The code paths for updating after configuration and updating every 20 seconds are identical. Which versions of OS X and Python are you using?

Are you running it standalone or from the command line? If standalone, can you check Applications > Utilities > Console for error messages (may have to filter on "nightscout")? If command line, can you run it with --debug and see if maybe there are messages from rumps/PyObjC about failing to set the timer?

danamlewis commented 9 years ago

I'm 10.8.4 for OS X and Python 2.7.2

I ended up running it standalone. Looking in console and don't see any error messages from today when I was running it, they look like the errors I was getting before I had it working (after getting XCode).

mddub commented 9 years ago

Try replacing your current standalone with v0.2.1? I put that up this morning; it catches a broader set of exceptions.

If that doesn't work, can you paste the debug output? It turns out you can get it from standalone too. Assuming it's in /Applications, try running the app from the terminal like this:

cd /Applications
./Nightscout\ Menubar.app/Contents/MacOS/Nightscout\ Menubar --debug
danamlewis commented 9 years ago

Tried v0.2.1 just now, and get "Can't Connect to NIghtscout!" (whereas it was working minutes ago to at least manually fresh/have the data on launching, now it won't get the data at all).

Here's the debug output from terminal (it's still running, but repetitive): 2015-10-15 14:21:55.134 Nightscout Menubar[63171:707] <Timer: [callback: 'update_data'; interval: 20; status: ON]> Retried too many times: SSLError(SSLError(SSLError(8, '_ssl.c:503: EOF occurred in violation of protocol'),),) 2015-10-15 14:21:56.492 Nightscout Menubar[63171:707] given function <function update_data at 0x103532050> is outside an App subclass definition 2015-10-15 14:22:15.050 Nightscout Menubar[63171:707] <Timer: [callback: 'update_data'; interval: 20; status: ON]> Retried too many times: SSLError(SSLError(SSLError(8, '_ssl.c:503: EOF occurred in violation of protocol'),),) 2015-10-15 14:22:15.257 Nightscout Menubar[63171:707] given function <function update_data at 0x103532050> is outside an App subclass definition 2015-10-15 14:22:35.040 Nightscout Menubar[63171:707] <Timer: [callback: 'update_data'; interval: 20; status: ON]> Retried too many times: SSLError(SSLError(SSLError(8, '_ssl.c:503: EOF occurred in violation of protocol'),),) 2015-10-15 14:22:35.316 Nightscout Menubar[63171:707] given function <function update_data at 0x103532050> is outside an App subclass definition 2015-10-15 14:22:55.030 Nightscout Menubar[63171:707] <Timer: [callback: 'update_data'; interval: 20; status: ON]> Retried too many times: SSLError(SSLError(SSLError(8, '_ssl.c:503: EOF occurred in violation of protocol'),),) 2015-10-15 14:22:55.236 Nightscout Menubar[63171:707] given function <function update_data at 0x103532050> is outside an App subclass definition 2015-10-15 14:23:15.020 Nightscout Menubar[63171:707] <Timer: [callback: 'update_data'; interval: 20; status: ON]> Retried too many times: SSLError(SSLError(SSLError(8, '_ssl.c:503: EOF occurred in violation of protocol'),),) 2015-10-15 14:23:15.226 Nightscout Menubar[63171:707] given function <function update_data at 0x103532050> is outside an App subclass definition 2015-10-15 14:23:35.010 Nightscout Menubar[63171:707] <Timer: [callback: 'update_data'; interval: 20; status: ON]> Retried too many times: SSLError(SSLError(SSLError(8, '_ssl.c:503: EOF occurred in violation of protocol'),),) 2015-10-15 14:23:35.243 Nightscout Menubar[63171:707] given function <function update_data at 0x103532050> is outside an App subclass definition

mddub commented 9 years ago
  1. Is your Nightscout instance hosted on Azure?
  2. Would you mind trying something? Right-click on the app and "Show Package Contents". Open Contents/Resources/nightscout_osx_menubar.py in a text editor, and comment out line 39 (i.e. change it to # verify=False). Then reopen the app from the command line and see what the error is, if any?
danamlewis commented 9 years ago
  1. No.
  2. Same errors it looks like:

/Users/DanaLewis/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning /Users/DanaLewis/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning /Users/DanaLewis/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning Retried too many times: SSLError(SSLError(SSLError(8, 'ssl.c:503: EOF occurred in violation of protocol'),),) /Users/DanaLewis/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning /Users/DanaLewis/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning /Users/DanaLewis/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning Retried too many times: SSLError(SSLError(SSLError(8, 'ssl.c:503: EOF occurred in violation of protocol'),),) /Users/DanaLewis/Library/Python/2.7/lib/python/site-packages/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning

(etc etc)

mddub commented 9 years ago

Ah, I figured. I think this is caused by a mismatch between the supported SSL protocols on your Nightscout server and the (older) default protocol used by your version of Python and/or the version of the ssl package the py2app-packaged app ends up using.

I wonder if forcing the client to use TLSv1 would work as implied in this SO thread. Can you try pasting this in its entirety to replace nightscout_osx_menubar.py in the app package contents as above? https://gist.github.com/mddub/f5d4509b2f807adb9802

(Sorry this troubleshooting is so roundabout... I'm discovering that supporting this on different desktop environments plus different servers is more complex than a 200 line Python file would suggest.)

danamlewis commented 9 years ago

Hey! Fixed! ...all because I took the s from https and just made it http since our SSL isn't set up properly. So, I think your fix from this morning fixed it? (I originally set up as http last night and that's when I encountered the problem, but when I did v.0.2.1 I think I did https and all subsequent troubleshoots as such). So, sorry for the extra trouble shooting beyond the update you provided this morning to fix, and thanks for the help :)

mddub commented 9 years ago

Sounds good. I'll consider this fixed since SSL is confirmed working on a standard Azure install, and I'm assuming for now that non-standard installs can just use http in the event of SSL errors.