PushBullet plugin (Pako)

Questions and comments specific to a particular plugin should go here.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: PushBullet plugin (Pako)

Post by Pako » Thu Nov 09, 2017 10:31 am

jachin99 wrote:
Wed Oct 11, 2017 2:30 pm
Does eventghost show up under devices?
Yes, the Eventghost plugin should also be visible in the list of connected devices.
As you describe it, something is wrong in the version for 0.5.0.

Pako

piert
Experienced User
Posts: 295
Joined: Tue Jun 14, 2011 2:53 pm

Re: PushBullet plugin (Pako)

Post by piert » Tue Apr 24, 2018 11:11 am

I did not migrate to 0.5.0 in order to avoid issues with PB but since a few days the EG PB plugin is not working anymore and I get the 'no connectivity' issue in the EG log when trying to send a Push from within EG.
PushBullet between my other devices (Android tablet and iPhone) are still working as expected.

Is anybody else experiencing problems too?

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: PushBullet plugin (Pako)

Post by Pako » Tue Apr 24, 2018 2:40 pm

piert wrote:
Tue Apr 24, 2018 11:11 am
but since a few days the EG PB plugin is not working anymore
I do not know what's going on on your side, but everything works for me as expected.
What does not work for you?
Please set logging level = 5 and attach the appropriate part of the EventGhost log here (of course I recommend editing it so that privacy is not compromised).

Pako

piert
Experienced User
Posts: 295
Joined: Tue Jun 14, 2011 2:53 pm

Re: PushBullet plugin (Pako)

Post by piert » Wed Apr 25, 2018 6:20 am

Thanks, good to know that it should be working. As for the log: I hope to be able to look into it this weekend.

Phil
Experienced User
Posts: 110
Joined: Tue Apr 15, 2014 10:42 am
Location: Merseyside, UK

Re: PushBullet plugin (Pako)

Post by Phil » Mon Apr 30, 2018 3:14 pm

After using the plugin for a long time I am also now getting this error. I changed my phone and wanted to connect my new one receive the alterts but get the same no connectivity error. I've tried changing API keys and encryption password but no joy.
The list of devices isnt getting pulled in any more either.

With logging on 5 I get no more information as to what the error is.

Phil
Experienced User
Posts: 110
Joined: Tue Apr 15, 2014 10:42 am
Location: Merseyside, UK

Re: PushBullet plugin (Pako)

Post by Phil » Tue May 01, 2018 8:19 am

Ive removed the plugin and readded it, I now get this error

09:17:20 Exception in thread Thread-8:
09:17:20 Traceback (most recent call last):
09:17:20 File "threading.pyc", line 801, in __bootstrap_inner
09:17:20 File "threading.pyc", line 754, in run
09:17:20 File "C:\ProgramData\EventGhost\plugins\PushBullet\__init__.py", line 3798, in updateDevices
09:17:20 self.getAccount()
09:17:20 File "C:\ProgramData\EventGhost\plugins\PushBullet\__init__.py", line 3681, in getAccount
09:17:20 account, flag = self.request("GET", API + 'users/me')
09:17:20 File "C:\ProgramData\EventGhost\plugins\PushBullet\__init__.py", line 3641, in request
09:17:20 c.perform()
09:17:20 error: (60, 'SSL certificate problem: unable to get local issuer certificate')
09:17:20

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: PushBullet plugin (Pako)

Post by Pako » Tue May 01, 2018 12:04 pm

It seems that pycurl has a problem with the certificate.
I have some idea how this could be solved. However, I have no opportunity to try it because I do not know how I could bring this problem to me.

Pako

User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: PushBullet plugin (Pako)

Post by yokel22 » Tue May 01, 2018 3:07 pm

What version of e.g. are you running? This type of error was in e.g. 5.0 rc4 & WIP builds. I was getting it with both the pycurl & requests modules. It's since been fixed. If your using either of those, try redownloading/installing & see if it doesn't fix the problem.

User avatar
kgschlosser
Site Admin
Posts: 4652
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: PushBullet plugin (Pako)

Post by kgschlosser » Tue May 01, 2018 9:41 pm

The issue has been fixed in the most recent build of EG which can be downloaded by clicking on the build button at the top of the forum.


If you do not want to run a test build and would rather run a release. you will need to add the following code to a python script. and place that script at the top of your autostart group

Code: Select all

import eg
import os

os.environ['REQUESTS_CA_BUNDLE'] = os.path.join(
    eg.sitePackagesDir,
    'requests',
    'cacert.pem'
)
and this will fix the issue with certificates and the requests module.
If you like the work I have been doing then feel free to Image

User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: PushBullet plugin (Pako)

Post by yokel22 » Tue May 01, 2018 10:16 pm

Kg, this plugin uses pycurl. Will that work if he changes requests to pycurl in the script?

User avatar
kgschlosser
Site Admin
Posts: 4652
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: PushBullet plugin (Pako)

Post by kgschlosser » Wed May 02, 2018 4:48 am

Not sure. I can look into pycurl and see if there is a potential issue with it as well. For some reason i think that pycurl does look for this same environment variable and if it finds it it will use it. I have to double check tho
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4652
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: PushBullet plugin (Pako)

Post by kgschlosser » Wed May 02, 2018 5:03 am

ok so this would be directed at Pako.

Code: Select all

import pycurl
import certifi

curl = pycurl.Curl()
curl.setopt(pycurl.CAINFO, certifi.where())

or you can use the cert bundle with requests.

Code: Select all

import pycurl
import os

curl = pycurl.Curl()
curl.setopt(pycurl.CAINFO, os.path.join(eg.sitePackagesDir, 'requests', 'cacert.pem'))
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4652
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: PushBullet plugin (Pako)

Post by kgschlosser » Wed May 02, 2018 7:32 am

now for those of you that want it working now. you will need to add the following code to a python script and place it in the autostart group at the very top

Code: Select all

import eg
import sys

def _excepthook(tpe, value, tb=None):
    lines = traceback.format_exception(tpe, value, tb)
        
    for i, line in enumerate(lines[:]):
        if "self.__dict__['_curl']" in line:
            lines.pop(i)
            lines.pop(i - 1)
    for line in lines:
        sys.stderr.write(line)


eg.globals._traceback_buffer = []

def print_error(*args, **kwargs):
    args = list(args)
    msg = args[0]
        
    if 'Traceback' in msg:
        if eg.globals._traceback_buffer:
            for line in eg.globals._traceback_buffer:
                eg.globals._print_error(line)
            eg.globals._traceback_buffer = []
        eg.globals._traceback_buffer += [msg]
    elif eg.globals._traceback_buffer:
        if "self.__dict__['_curl']" in msg:
            eg.globals._traceback_buffer = eg.globals._traceback_buffer[:-1]
        else:
            eg.globals._traceback_buffer += [msg]
        if 'Error:' in msg:
            for line in eg.globals._traceback_buffer:
                eg.globals._print_error(line)
            eg.globals._traceback_buffer = []
        
if hasattr(eg.globals, '_old_excepthook'):
    sys.excepthook = eg.globals._old_excepthook
    
if hasattr(eg.globals, '_print_error'):
    eg.__dict__['PrintError'] = eg.globals._print_error
    
eg.globals._print_error = eg.__dict__['PrintError']
eg.__dict__['PrintError'] = print_error
eg.globals._old_excepthook = sys.excepthook
sys.excepthook = _excepthook

import os
import traceback


for mod_name in sys.modules.keys():
    if mod_name.startswith('pycurl'):
        try:
            del sys.modules[mod_name]
        except KeyError:
            pass


import pycurl
_curl = pycurl.Curl

class PyCurlWrapper(object):

    def __init__(self, *args, **kwargs):
        self.__dict__['_curl'] = _curl(*args, **kwargs)
        self.__dict__['_curl'].setopt(pycurl.CAINFO, os.path.join(eg.sitePackagesDir, 'requests', 'cacert.pem'))
        
    def __getattr__(self, item):
        return getattr(self.__dict__['_curl'], item)
    
    def __setattr__(self, key, value):
        setattr(self.__dict__['_curl'], key, value)
            
    def __getitem__(self, item):
        return self.__dict__['_curl'][item]
    
    def __setitem__(self, key, value):
        self.__dict__['_curl'][key] = value
        
    def __del__(self):
        del(self.__dict__['_curl'])
        
    def reset():
        self.__dict__['_curl'].reset()
        self.__dict__['_curl'].setopt(pycurl.CAINFO, os.path.join(eg.sitePackagesDir, 'requests', 'cacert.pem'))
        
    def __repr__(self):
        return str(self.__dict__['_curl'])
    
    def __str__(self):
        return str(self.__dict__['_curl']) 
    
    def __unicode__(self):
        return unicode(str(self))
        
sys.modules['pycurl'].Curl = PyCurlWrapper
This should work if someone wants to give it a go. You will have to save and restart EG for it to take hold.

Let me know if it does. because in all reality this is not the fault of the plugin it is the fault of the included module in EG and should be handled in the core of EG and the plugin should not have to worry about handling this. It will be something i submit to have the code added to the core. well a variation of this. that would also wrap the call to perform and exception catch if there is a cert issue and open a dialog so the user can decide if they want EG to go and grab a newer cert file. I will also incorporate the same with requests, urllib and httlib (if the later 2 support ssl connections) so the issues with SSL and connecting to websites can hopefully be stamped as solved.
If you like the work I have been doing then feel free to Image

Phil
Experienced User
Posts: 110
Joined: Tue Apr 15, 2014 10:42 am
Location: Merseyside, UK

Re: PushBullet plugin (Pako)

Post by Phil » Wed May 09, 2018 2:54 pm

thanks for your efforts on this, ive just tried it on 2 versions and not got very far.

On the 0.4.1 1722 release of eg and version 0.2.21 of the plugin im getting this error:

15:48:38 PushBullet: Request error: {"error":{"code":"insufficient_authorization","type":"invalid_request","message":"Insufficient authorization.","cat":"(=^‥^=)"},"error_code":"insufficient_authorization"}


on .0.5.0 RC4 im getting certificate issues

15:44:50 Exception in thread Thread-6:
15:44:50 Traceback (most recent call last):
15:44:50 File "threading.pyc", line 801, in __bootstrap_inner
15:44:50 File "threading.pyc", line 754, in run
15:44:50 File "C:\ProgramData\EventGhost\plugins\PushBullet\__init__.py", line 3798, in updateDevices
15:44:50 self.getAccount()
15:44:50 File "C:\ProgramData\EventGhost\plugins\PushBullet\__init__.py", line 3681, in getAccount
15:44:50 account, flag = self.request("GET", API + 'users/me')
15:44:50 File "C:\ProgramData\EventGhost\plugins\PushBullet\__init__.py", line 3641, in request
15:44:50 c.perform()
15:44:50 error: (60, 'SSL certificate problem: unable to get local issuer certificate')
15:44:50

Hope this helps.

piert
Experienced User
Posts: 295
Joined: Tue Jun 14, 2011 2:53 pm

Re: PushBullet plugin (Pako)

Post by piert » Thu Jul 05, 2018 5:02 am

Kevin, did you ever follow up on this?
Phil, did you find a work around for using Pushbullet?

Post Reply