# coding=utf-8 from model.position import Position_Image from model.device import Device import sys def connect_db(): import transwarp.db as dbutil dbutil.create_engine('sonic513', 'sonic513', 'tobacco_monitor', port=3306) if __name__=="__main__": connect_db() mac = sys.argv[1] position = sys.argv[2] object_name = sys.argv[3] duration = sys.argv[4] dev = Device.find_first("where mac=?", mac) if not dev: print "device with mac not found!" pos = Position_Image(position = int(position), object_name=object_name, device_id = dev.id, duration = duration) id= pos.create() if id: print "add image pos %s OK!" % position else: print "add image pos error!"
# coding=utf-8 from model.device import Device from model.user import User from model.device_observed import Device_Observed import sys def connect_db(): import transwarp.db as dbutil dbutil.create_engine('sonic513', 'sonic513', 'tobacco_monitor', port=3306) if __name__=="__main__": connect_db() user_name = sys.argv[1] mac = sys.argv[2] dev = Device.find_first("where mac = ?", mac.strip()) usr = User.find_first("where name = ?", user_name.strip()) dev_obs = Device_Observed() if dev_obs.observe(usr.id, dev.id): print "dev observe success!" else: print "dev observe fail!"
# coding=utf-8 from model.position import Position_Image from model.device import Device import sys def connect_db(): import transwarp.db as dbutil dbutil.create_engine('sonic513', 'sonic513', 'tobacco_monitor', port=3306) if __name__ == "__main__": connect_db() mac = sys.argv[1] position = sys.argv[2] object_name = sys.argv[3] duration = sys.argv[4] dev = Device.find_first("where mac=?", mac) if not dev: print "device with mac not found!" pos = Position_Image(position=int(position), object_name=object_name, device_id=dev.id, duration=duration) id = pos.create() if id: print "add image pos %s OK!" % position else: print "add image pos error!"
# coding=utf-8 from model.device import Device from model.user import User from model.device_observed import Device_Observed import sys def connect_db(): import transwarp.db as dbutil dbutil.create_engine('sonic513', 'sonic513', 'co2_monitor', port=3306) if __name__ == "__main__": connect_db() user_name = sys.argv[1] mac = sys.argv[2] dev = Device.find_first("where mac = ?", mac.strip()) usr = User.find_first("where name = ?", user_name.strip()) dev_obs = Device_Observed() if dev_obs.observe(usr.id, dev.id): print "dev observe success!" else: print "dev observe fail!"