def loop(self): self.ensure_configuration_files() pygmail.login(self.conf()['accounts']['mail']['username'], self.conf()['accounts']['mail']['password']) for account in self.conf()['accounts']['vklass']: client.log("Spawning vklass session with username: %s, email: %s" % (account['username'], account['email'])) vklass_session = pyvklass.Vklass() vklass_session.notification_email = account['email'] vklass_session.login(account['username'], account['password']) self.sessions.append(vklass_session) while self.running: for session in self.sessions: for message in session.first_messages(): if json.dumps(message) not in self.saved_messages(): subject = message['title'] body = message['body'] if len(message['posts']) > 0: body += "\n Posts: \n" for post in message['posts']: body += " | %s | %s |\n" % (post['date'], post['username']) body += " --> %s" % post['body'] pygmail.send(session.notification_email, subject, body) client.append(self.conf()['files']['saved_messages'], json.dumps(message) + "\n") time.sleep(120)
r = client.read("foo",0,32) r.next() # connects to master, sends ReadReq master.tick() # get conn master.tick() # get ReadReq r.next() # send ReadChunk to chunkserver chunk.tick() # get ReadChunk, send response s = r.next() log.log("received: %s" %s) expected = "abcdefghijklmnopqrstuvwxyzABCDEF" if s != expected: log.err("got %s expected %s" % (s,expected)) log.log("appending data") data = "1234567890" global a a = client.append("foo",data) a.next() # connect to master, send request master.tick() # get AppendReq, a.next() # connecting to chunkserver, SendData chunk.tick() # recv SendData a.next() # get success for mutate 1, send commit to master master.tick() # send commit msg to chunk chunk.tick() # write data master.tick() # get response, done with commit, master.tick() # send client success res = a.next() # receive success log.log("wrote mutate_id(%i)" % res.mutate_id) log.log("second FileInfo fetch") global fi2r, fi2 fi2r = client.file_info('foo')