Skip to content

TypeError: __init__() takes at least 2 arguments (2 given) #14

@jinnatar

Description

@jinnatar

Running latest HEAD the api.pushes() interface crashes:

Traceback (most recent call last):
  File "./receiver.py", line 59, in <module>
    for push in api.pushes():
  File "/usr/local/lib/python2.7/dist-packages/pushybullet.py", line 1221, in <genexpr>
    return (self.make_push(o) for o in it if bool(o.get('type', None)))
  File "/usr/local/lib/python2.7/dist-packages/pushybullet.py", line 1100, in make_push
    push = pushcls(pusharg, **pushargs) if pusharg else pushcls(**pushargs)
TypeError: __init__() takes at least 2 arguments (2 given)

This is my "backlog" loop so the relevant code is very simple:

api = pb.PushBullet(API_KEY)
receiver = api['receiver'].iden
try:
    for push in api.pushes():
        target = getattr(push, 'target_device_iden', 'broadcast')
        if target == receiver: # only act on ones directed at us
            acquirePush(push)
except Exception as inst:
    logger.warn('Failed to pull from pushbullet: %s' % inst)
    raise

Normally the loop handles url and file type pushes and even does so successfully if I push new items into the queue. But eventually it always crashes and burns like this. So almost 100% sure there's something funny in the queue that kills processing, I just can't see it from anywhere.

The same issue repeats with the pb client:

 %> pb --apikey $(cat apikey) pushes
[..snip a ton of pushes..]
Traceback (most recent call last):
  File "/usr/local/bin/pb", line 147, in <module>
    main()
  File "/usr/local/bin/pb", line 144, in main
    command(api, args)
  File "/usr/local/bin/pb", line 71, in command_pushes
    for push in pushes:
  File "/usr/local/lib/python2.7/dist-packages/pushybullet.py", line 1221, in <genexpr>
    return (self.make_push(o) for o in it if bool(o.get('type', None)))
  File "/usr/local/lib/python2.7/dist-packages/pushybullet.py", line 1100, in make_push
    push = pushcls(pusharg, **pushargs) if pusharg else pushcls(**pushargs)
TypeError: __init__() takes at least 2 arguments (2 given)

So, at a minimum I'd say some basic exception handling needs to be implemented to catch some whiff of the push causing the meltdown, and then can think about working around said meltdown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions