Exemple #1
0
def pump_events():
    lib.SpPumpEvents()
    spawn_later(0.1, pump_events)
Exemple #2
0
            lib.SpConnectionLoginBlob(username.encode(), blob.encode())
        else:
            raise ValueError("Must specify a login method (password, blob)")


def signal_handler(signal, frame):
    lib.SpConnectionLogout()
    lib.SpFree()
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)

# Only run if script is run directly and not by an import
if __name__ == "__main__":

    @ffi.callback("void(SpError err, void *userdata)")
    def console_error_callback(error, userdata):
        if error == lib.kSpErrorLoginBadCredentials:
            print("Invalid username or password")
            # sys.exit() doesn't work inside of a ffi callback
            C.exit(1)
        else:
            error_callback(msg)

    connect = Connect(console_error_callback)

    while 1:
        lib.SpPumpEvents()