def __init__(self): """ Require valid cookie in the file '/cookie.txt'""" working_dir = os.getcwd() f = open(working_dir + '/cookie.txt', "r+") text = f.read() self.cookie = {'PHPSESSID': str(text).strip()} f.close() try: self.xsrf_token = self.__get_xsrf_token() except: logger.error("Invalid cookie") raise InvalidCookieException() self.points = self.__get_current_points() self.db = SgDb(self.sqlite_db_name) self.notif = Notif()
def __init__(self): notif = Notif() notif.receive() self.bytes = notif.get() #check preabmle self.preamble = self.bytes[0] if (self.preamble != RESPONSE_PREAMBLE[0]): _print("Invalid Response Preamble.", WARNING) raise error.PreambleErr #get opcode self.opcode = self.bytes[1] #get length and check self.length = self.bytes[2] #check arg length self.args = self.bytes[3:3 + self.length] self.print()
def __init__(self, payload): _print("Sending Command, Payload=: " + str(payload), DEBUG) self.bytes = COMMAND_PREAMBLE + payload #check preabmle self.preamble = self.bytes[0] #get opcode self.opcode = self.bytes[1] #get length and check self.length = self.bytes[2] #check arg length self.args = self.bytes[3:3 + self.length] self.print() notif = Notif() notif.set(self.bytes) notif.send()
def __init__(self): notif = Notif() notif.receive() self.bytes = notif.get() self.motion = None #check preabmle self.preamble = self.bytes[0] if (self.preamble != DATA_PREAMBLE[0]): _print("Invalid Data Preamble.", ERROR) raise error.PreambleErr #get opcode self.data_flags = self.bytes[1] #get length and check self.packet_number = self.bytes[2] #check arg length self.args = self.bytes[3:] self.parse() self.print()