コード例 #1
0
    def get(self):
        rc = {}
        rc['result'] = 'ok'
        rc['info'] = ''

        cmd = self.__param('command')
        if cmd is None:
            rc['result'] = 'err'
            rc['info'] = '"command" MUST be suppiled!'
            self.write(rc)
            return

        if cmd == 'version':
            ver = {}
            ver['version'] = VERSION
            ver['descr'] = VERSION_INFO
            data = {}
            data['type'] = 'version'
            data['data'] = ver
            rc['value'] = data
            self.write(rc)

        if cmd == 'exit':
            global _ioloop
            rc['info'] = 'exit!!!'
            rh.join()
            self.write(rc)
            _ioloop.stop()

        if cmd == 'dump':
            db = DBHlp()
            db.dump("ns.db")
            self.write(rc)
コード例 #2
0
ファイル: query.py プロジェクト: dong777/zkonvif
def getServicesByHost(params):
    ''' 返回指定 host 的所有服务,offline 可选 '''
    offline = False
    if 'offline' in params and params['offline'] == '1':
        offline = True

    if 'host' not in params:
        return { 'result': 'err', 'info': 'host MUST be supplied' }
        
    s = 'select * from services where host="%s"' % (params['host'])
    if not offline:
        s = 'select services.host, servics.name, services.type, services.url from services join \
            states on (services.host=states.host and services.name=states.name and services.type=states.type) \
            where services.host="%s"' % (params['host'])
    db = DBHlp()
    rc = db.query(s)
    value = []
    for rec in rc:
        item = {}
        item['host'] = rec[0]
        item['name'] = rec[1]
        item['type'] = rec[2]
        item['url'] = rec[3]
        value.append(item)
    return { 'result': 'ok', 'info':'', 'value': value }
コード例 #3
0
ファイル: query.py プロジェクト: zonekey/zkonvif
def getAllServices(params):
    ''' 返回服务列表, offline 可选 '''
    offline = False
    if 'offline' in params and params['offline'] == '1':
        offline = True

    s = 'select * from services'
    if not offline:
        s = 'select services.host, services.name, services.type, services.url from services join \
            states on (services.host=states.host and services.name=states.name and \
                    services.type=states.type)'

    db = DBHlp()
    rc = db.query(s)

    value = []
    for rec in rc:
        item = {}
        item['host'] = rec[0]
        item['name'] = rec[1]
        item['type'] = rec[2]
        item['url'] = rec[3]
        value.append(item)

    return {'result': 'ok', 'info': '', 'value': value}
コード例 #4
0
ファイル: query.py プロジェクト: zonekey/zkonvif
def getServicesByHost(params):
    ''' 返回指定 host 的所有服务,offline 可选 '''
    offline = False
    if 'offline' in params and params['offline'] == '1':
        offline = True

    if 'host' not in params:
        return {'result': 'err', 'info': 'host MUST be supplied'}

    s = 'select * from services where host="%s"' % (params['host'])
    if not offline:
        s = 'select services.host, servics.name, services.type, services.url from services join \
            states on (services.host=states.host and services.name=states.name and services.type=states.type) \
            where services.host="%s"' % (params['host'])
    db = DBHlp()
    rc = db.query(s)
    value = []
    for rec in rc:
        item = {}
        item['host'] = rec[0]
        item['name'] = rec[1]
        item['type'] = rec[2]
        item['url'] = rec[3]
        value.append(item)
    return {'result': 'ok', 'info': '', 'value': value}
コード例 #5
0
ファイル: server.py プロジェクト: dong777/zkonvif
    def get(self):
        rc = {}
        rc['result'] = 'ok'
        rc['info'] = ''

        cmd = self.__param('command')
        if cmd is None:
            rc['result'] = 'err'
            rc['info'] = '"command" MUST be suppiled!'
            self.write(rc)
            return

        if cmd == 'version':
            ver = {}
            ver['version'] = VERSION
            ver['descr'] = VERSION_INFO
            data = {}
            data['type'] = 'version'
            data['data'] = ver
            rc['value'] = data
            self.write(rc)

        if cmd == 'exit':
            global _ioloop
            rc['info'] = 'exit!!!'
            rh.join()
            self.write(rc)
            _ioloop.stop()

        if cmd == 'dump':
            db = DBHlp()
            db.dump("ns.db")
            self.write(rc)
コード例 #6
0
ファイル: query.py プロジェクト: zonekey/zkonvif
def getServicesByType(params):
    ''' 返回 type 指定的服务列表,offline, host 可选
    '''
    offline = False
    if 'offline' in params and params['offline'] == '1':
        offline = True

    t = ''
    if 'type' not in params:
        return {'result': 'err', 'info': 'type MUST be supplied'}
    else:
        t = params['type']

    s = 'select * from services where type="%s"' % (t)

    # 四种可能: offline X host
    if 'host' in params:
        host = params['host']
        if not offline:
            s = 'select services.host, services.name, services.type, services.url from services join \
                states on (services.host=states.host and services.name=states.name and \
                        services.type=states.type) where (services.host="%s" and services.type="%s")' % (
                host, t)
        else:
            s = 'select * from services where host="%s" and type="%s"' % (host,
                                                                          t)
    elif not offline:
        s = 'select services.host, services.name, services.type, services.url from services join \
            states on (services.host=states.host and services.name=states.name and \
                    services.type=states.type) where services.type="%s"' % (t)

    db = DBHlp()
    rc = db.query(s)
    value = []
    for rec in rc:
        item = {}
        item['host'] = rec[0]
        item['name'] = rec[1]
        item['type'] = rec[2]
        item['url'] = rec[3]
        value.append(item)
    return {'result': 'ok', 'info': '', 'value': value}
コード例 #7
0
ファイル: LogServer.py プロジェクト: dong777/zkonvif
    def get(self):
        rc = {}
        rc['result'] = 'ok'
        rc['info'] = ''

        p = self.request.arguments
        project = self.__param('project', p)
        level = self.__param('level', p)
        stamp_begin = self.__param('stamp_begin', p)
        if stamp_begin is None:
            stamp_begin = str(time.time() - 600) # 缺省返回最近十分钟的日志
        stamp_end = self.__param('stamp_end', p)
        db = DBHlp()
        logs = db.query(project, level, stamp_begin, stamp_end)
        value = {}
        value['type'] = 'list'
        value['data'] = logs
        rc['value'] = value
        self.add_header('Access-Control-Allow-Origin', '*') # to enable cross domain calling
        self.write(rc)
コード例 #8
0
ファイル: query.py プロジェクト: dong777/zkonvif
def getHosts(params):
    ''' 返回匹配的注册的主机,  host, type 为可选 
    '''
    s = 'select * from hosts'
    if 'host' in params and 'type' in params:
        s = 'select * from hosts where host="%s" and type="%s"' % (params['host'], params['type'])
    elif 'host' in params:
        s = 'select * from hosts where host="%s"' % (params['host'])
    elif 'type' in params:
        s = 'select * from hosts where type="%s"' % (params['type'])
    
    db = DBHlp()
    rc = db.query(s)
    value = []
    for rec in rc:
        item = {}
        item['host'] = rec[0]
        item['type'] = rec[1]
        value.append(item)
    return { 'result': 'ok', 'info':'', 'value':value }
コード例 #9
0
ファイル: query.py プロジェクト: zonekey/zkonvif
def getHosts(params):
    ''' 返回匹配的注册的主机,  host, type 为可选 
    '''
    s = 'select * from hosts'
    if 'host' in params and 'type' in params:
        s = 'select * from hosts where host="%s" and type="%s"' % (
            params['host'], params['type'])
    elif 'host' in params:
        s = 'select * from hosts where host="%s"' % (params['host'])
    elif 'type' in params:
        s = 'select * from hosts where type="%s"' % (params['type'])

    db = DBHlp()
    rc = db.query(s)
    value = []
    for rec in rc:
        item = {}
        item['host'] = rec[0]
        item['type'] = rec[1]
        value.append(item)
    return {'result': 'ok', 'info': '', 'value': value}
コード例 #10
0
ファイル: LogServer.py プロジェクト: zonekey/zkonvif
    def get(self):
        rc = {}
        rc['result'] = 'ok'
        rc['info'] = ''

        p = self.request.arguments
        project = self.__param('project', p)
        level = self.__param('level', p)
        stamp_begin = self.__param('stamp_begin', p)
        if stamp_begin is None:
            stamp_begin = str(time.time() - 600)  # 缺省返回最近十分钟的日志
        stamp_end = self.__param('stamp_end', p)
        db = DBHlp()
        logs = db.query(project, level, stamp_begin, stamp_end)
        value = {}
        value['type'] = 'list'
        value['data'] = logs
        rc['value'] = value
        self.add_header('Access-Control-Allow-Origin',
                        '*')  # to enable cross domain calling
        self.write(rc)
コード例 #11
0
ファイル: query.py プロジェクト: dong777/zkonvif
def getServicesByType(params):
    ''' 返回 type 指定的服务列表,offline, host 可选
    '''
    offline = False
    if 'offline' in params and params['offline'] == '1':
        offline = True

    t = ''
    if 'type' not in params:
        return { 'result': 'err', 'info': 'type MUST be supplied' }
    else:
        t = params['type']

    s = 'select * from services where type="%s"' % (t)

    # 四种可能: offline X host
    if 'host' in params:
        host = params['host']
        if not offline:
            s = 'select services.host, services.name, services.type, services.url from services join \
                states on (services.host=states.host and services.name=states.name and \
                        services.type=states.type) where (services.host="%s" and services.type="%s")' % (host, t)
        else:
            s = 'select * from services where host="%s" and type="%s"' % (host, t)
    elif not offline:
        s = 'select services.host, services.name, services.type, services.url from services join \
            states on (services.host=states.host and services.name=states.name and \
                    services.type=states.type) where services.type="%s"' % (t)

    db = DBHlp()
    rc = db.query(s)
    value = []
    for rec in rc:
        item = {}
        item['host'] = rec[0]
        item['name'] = rec[1]
        item['type'] = rec[2]
        item['url'] = rec[3]
        value.append(item)
    return { 'result': 'ok', 'info':'', 'value':value }
コード例 #12
0
ファイル: query.py プロジェクト: dong777/zkonvif
def getAllServices(params):
    ''' 返回服务列表, offline 可选 '''
    offline = False
    if 'offline' in params and params['offline'] == '1':
        offline = True

    s = 'select * from services'
    if not offline:
        s = 'select services.host, services.name, services.type, services.url from services join \
            states on (services.host=states.host and services.name=states.name and \
                    services.type=states.type)'
    db = DBHlp()
    rc = db.query(s)

    value = []
    for rec in rc:
        item = {}
        item['host'] = rec[0]
        item['name'] = rec[1]
        item['type'] = rec[2]
        item['url'] = rec[3]
        value.append(item)

    return { 'result': 'ok', 'info': '', 'value':value }