Core GNTP Classes

Lower level classes for those who want more control in sending messages

Exceptions

exception gntp.errors.AuthError
exception gntp.errors.ParseError
exception gntp.errors.UnsupportedError

GNTP Messages

Classes representing each of the GNTP message types

class gntp.core.GNTPRegister(data=None, password=None)

Represents a GNTP Registration Command

Parameters:
  • data (string) – (Optional) See decode()
  • password (string) – (Optional) Password to use while encoding/decoding messages
add_notification(name, enabled=True)

Add new Notification to Registration message

Parameters:
  • name (string) – Notification Name
  • enabled (boolean) – Enable this notification by default
add_resource(data)

Add binary resource

Parameters:data (string) – Binary Data
decode(data, password)

Decode existing GNTP Registration message

Parameters:data (string) – Message to decode
encode()

Encode a GNTP Registration Message

Return string:Encoded GNTP Registration message
set_password(password, encryptAlgo='MD5')

Set a password for a GNTP Message

Parameters:
  • password (string) – Null to clear password
  • encryptAlgo (string) – Supports MD5, SHA1, SHA256, SHA512
validate()

Validate required headers and validate notification headers

class gntp.core.GNTPNotice(data=None, app=None, name=None, title=None, password=None)

Represents a GNTP Notification Command

Parameters:
  • data (string) – (Optional) See decode()
  • app (string) – (Optional) Set Application-Name
  • name (string) – (Optional) Set Notification-Name
  • title (string) – (Optional) Set Notification Title
  • password (string) – (Optional) Password to use while encoding/decoding messages
add_resource(data)

Add binary resource

Parameters:data (string) – Binary Data
decode(data, password)

Decode existing GNTP Notification message

Parameters:data (string) – Message to decode.
encode()

Encode a generic GNTP Message

Return string:GNTP Message ready to be sent
set_password(password, encryptAlgo='MD5')

Set a password for a GNTP Message

Parameters:
  • password (string) – Null to clear password
  • encryptAlgo (string) – Supports MD5, SHA1, SHA256, SHA512
validate()

Verify required headers

class gntp.core.GNTPSubscribe(data=None, password=None)

Represents a GNTP Subscribe Command

Parameters:
  • data (string) – (Optional) See decode()
  • password (string) – (Optional) Password to use while encoding/decoding messages
add_resource(data)

Add binary resource

Parameters:data (string) – Binary Data
decode(data, password=None)

Decode GNTP Message

Parameters:data (string) –
encode()

Encode a generic GNTP Message

Return string:GNTP Message ready to be sent
set_password(password, encryptAlgo='MD5')

Set a password for a GNTP Message

Parameters:
  • password (string) – Null to clear password
  • encryptAlgo (string) – Supports MD5, SHA1, SHA256, SHA512
validate()

Verify required headers

class gntp.core.GNTPOK(data=None, action=None)

Represents a GNTP OK Response

Parameters:
  • data (string) – (Optional) See _GNTPResponse.decode()
  • action (string) – (Optional) Set type of action the OK Response is for
add_resource(data)

Add binary resource

Parameters:data (string) – Binary Data
decode(data, password=None)

Decode GNTP Message

Parameters:data (string) –
encode()

Encode a generic GNTP Message

Return string:GNTP Message ready to be sent
set_password(password, encryptAlgo='MD5')

Set a password for a GNTP Message

Parameters:
  • password (string) – Null to clear password
  • encryptAlgo (string) – Supports MD5, SHA1, SHA256, SHA512
validate()

Verify required headers

class gntp.core.GNTPError(data=None, errorcode=None, errordesc=None)

Represents a GNTP Error response

Parameters:
  • data (string) – (Optional) See _GNTPResponse.decode()
  • errorcode (string) – (Optional) Error code
  • errordesc (string) – (Optional) Error Description
add_resource(data)

Add binary resource

Parameters:data (string) – Binary Data
decode(data, password=None)

Decode GNTP Message

Parameters:data (string) –
encode()

Encode a generic GNTP Message

Return string:GNTP Message ready to be sent
set_password(password, encryptAlgo='MD5')

Set a password for a GNTP Message

Parameters:
  • password (string) – Null to clear password
  • encryptAlgo (string) – Supports MD5, SHA1, SHA256, SHA512
validate()

Verify required headers

Helper Functions

gntp.core.parse_gntp(data, password=None)

Attempt to parse a message as a GNTP message

Parameters:
  • data (string) – Message to be parsed
  • password (string) – Optional password to be used to verify the message

Useful Links

Table Of Contents

Previous topic

GNTP Basics

This Page