from const import Const ## Constants defining packet types PacketTypes = Const() PacketTypes.Ping = "ping" PacketTypes.PingReply = "pingreply" PacketTypes.GetRandomProduct = "randomproduct" PacketTypes.AddCredit = "addcredit" PacketTypes.AddProduct = "addproduct" PacketTypes.Transaction = "transaction" PacketTypes.GetUser = "******" PacketTypes.GetProduct = "getproduct" PacketTypes.ProductData = "productdata" PacketTypes.UserData = "userdata" PacketTypes.UnknownProduct = "unknownproduct" PacketTypes.UnknownUser = "******" PacketTypes.RandomProduct = "randomproduct" PacketTypes.Result = "result" class InputException(Exception): """ To be raised when a packet could not be created due to bad input """ pass class Packet: """ Implements a single command, data or request for passing between client and server""" def __init__(self, packettype, data_dict = None): self.type = packettype self.data = data_dict