예제 #1
0
def _main():
    import sys
    reload(sys)
    sys.setdefaultencoding('utf8')

    tornado.options.parse_command_line()

    _app = MainApplication()

    _app.copy_default_icon()

    _app.load_db_to_cache()

    tornado.httpserver.HTTPServer(_app).listen(
        tornado.options.options.main_port)
    _app.run_periodic()

    #mqtt_message_main()

    _str = "Access http://%s:%d/ to %s PPMessage."
    if _get_config(
    ) == None or _get_config().get("config_status") != CONFIG_STATUS.RESTART:
        logging.info(
            _str %
            (get_ip_address(), tornado.options.options.main_port, "config"))
    else:
        logging.info(
            _str %
            (get_ip_address(), tornado.options.options.main_port, "use"))
    tornado.ioloop.IOLoop.instance().start()
    return
예제 #2
0
파일: main.py 프로젝트: GYGit/ppmessage
def _main():
    import sys
    reload(sys)
    sys.setdefaultencoding('utf8')

    tornado.options.parse_command_line()

    _app = MainApplication()

    _app.copy_default_icon()

    _app.load_db_to_cache()
    
    tornado.httpserver.HTTPServer(_app).listen(tornado.options.options.main_port)
    _app.run_periodic()

    #mqtt_message_main()
    
    _str = "Access http://%s:%d/ to %s PPMessage."
    if _get_config() == None or _get_config().get("config_status") != CONFIG_STATUS.RESTART:
        logging.info(_str % (get_ip_address(), tornado.options.options.main_port, "config"))
    else:
        logging.info(_str % (get_ip_address(), tornado.options.options.main_port, "use"))
    tornado.ioloop.IOLoop.instance().start()
    return
예제 #3
0
    def register_service(self, _port):
        _ip = get_ip_address()
        self.register.update({"host": _ip, "port": _port})
        
        _key = PCSocketInfo.__tablename__ + \
               ".host." + _ip + \
               ".port." + _port
        # existed
        if self.redis.exists(_key):
            _row = PCSocketInfo(uuid=self.redis.get(_key),
                                latest_register_time=datetime.datetime.now())
            _row.update_redis_keys(self.redis)
            _row.async_update(self.redis)
            _key = PCSocketDeviceData.__tablename__ + \
               ".pc_socket_uuid." + _row.uuid + \
               ".device_uuid.*"
            self._remove_device_data_by_pattern(_key)
            self.register["uuid"] = _row.uuid
            return

        # first time run
        _row = PCSocketInfo(uuid=str(uuid.uuid1()),
                            host=_ip,
                            port=_port,
                            latest_register_time=datetime.datetime.now())
        _row.async_add(self.redis)
        _row.create_redis_keys(self.redis)
        self.register["uuid"] = _row.uuid
        return
예제 #4
0
    def register_service(self, _port):
        _ip = get_ip_address()
        self.register.update({"host": _ip, "port": _port})

        _key = PCSocketInfo.__tablename__ + \
               ".host." + _ip + \
               ".port." + _port
        # existed
        if self.redis.exists(_key):
            _row = PCSocketInfo(uuid=self.redis.get(_key),
                                latest_register_time=datetime.datetime.now())
            _row.update_redis_keys(self.redis)
            _row.async_update(self.redis)
            _key = PCSocketDeviceData.__tablename__ + \
               ".pc_socket_uuid." + _row.uuid + \
               ".device_uuid.*"
            self._remove_device_data_by_pattern(_key)
            self.register["uuid"] = _row.uuid
            return

        # first time run
        _row = PCSocketInfo(uuid=str(uuid.uuid1()),
                            host=_ip,
                            port=_port,
                            latest_register_time=datetime.datetime.now())
        _row.async_add(self.redis)
        _row.create_redis_keys(self.redis)
        self.register["uuid"] = _row.uuid
        return
예제 #5
0
    def post(self, id=None):
        _status = {"status": CONFIG_STATUS.NONE, "ip": get_ip_address()}
        if _get_config() != None:
            _status["status"] = _get_config().get("config_status")

        if _status["status"] == CONFIG_STATUS.RESTART:
            logging.error("should not request config for PPMessage already configed.")
            return
        
        self.write(_status)
        self.flush()
        return
예제 #6
0
    def post(self, id=None):
        _status = {"status": CONFIG_STATUS.NONE, "ip": get_ip_address()}
        if _get_config() != None:
            _status["status"] = _get_config().get("config_status")

        if _status["status"] == CONFIG_STATUS.RESTART:
            logging.error("should not request config for PPMessage already configed.")
            return
        
        self.write(_status)
        self.flush()
        return
예제 #7
0
    def post(self):
        _cur = _cur_dir()
        _generic_store = _cur + "/ppmessage/resource/data/generic"
        _identicon_store = _cur + "/ppmessage/resource/data/identicon"            

        _server = {
            "url": "http://" + get_ip_address() + ":8945",
            "generic_store": _generic_store,
            "identicon_store": _identicon_store
        }
        
        if not self._create_server_stores(_server):
            logging.error("config server not run for wrong request: %s." % _server)
            return False
        
        self._dump_server_config(_server)
        return True
예제 #8
0
def _main():
    import sys
    reload(sys)
    sys.setdefaultencoding('utf8')
    tornado.options.parse_command_line()

    _app = MainApplication()
    if _get_config(
    ) == None or _get_config().get("config_status") != CONFIG_STATUS.FIRST:
        logging.error("Need run `config.py` to config PPMessage Lite Server")
        return

    _app.copy_default_icon()
    _app.load_db_to_cache()

    tornado.httpserver.HTTPServer(_app).listen(
        tornado.options.options.main_port)
    _app.run_periodic()

    _str = "Access http://%s:%d/ to use PPMessage."
    logging.info(_str % (get_ip_address(), tornado.options.options.main_port))
    tornado.ioloop.IOLoop.instance().start()
    return
예제 #9
0
파일: ipainfo.py 프로젝트: Bossuo/ppmessage
 def _get_pname(self):
     _pname = get_ip_address()
     _pname = _pname.replace(".", "_")
     _pname = _pname + ".plist"
     return _pname
예제 #10
0
 def _get_pname(self):
     _pname = get_ip_address()
     _pname = _pname.replace(".", "_")
     _pname = _pname + ".plist"
     return _pname