Beispiel #1
0
def getObj(key):
    r = _get_redis()
    key = _cachekeypre % key
    json = r.get(key)
    if None == json:
        return None
    return str_helper.json_decode(json)
Beispiel #2
0
def getObj(key):
    r = _get_redis()
    key = _cachekeypre % key
    json = r.get(key)
    if None == json:
        return None
    return str_helper.json_decode(json)
Beispiel #3
0
def _http_get(url, params):
    url = _format_url(url, params)
    json = http_helper.get(url)
    obj = str_helper.json_decode(json)

    if None == obj or obj['code'] != 0:
        return None
    return obj['data']
Beispiel #4
0
def _http_get(url, params):
    url = _format_url(url, params)
    json = http_helper.get(url)

    if None == json:
        return None
    obj = str_helper.json_decode(json)
    if obj['code'] != 0:
        return None
    return obj['data']
Beispiel #5
0
def execut_file(filepath, L):
    for f in search_file(filepath, L):
        cmd = "{0} -v quiet -print_format json -show_format -i {1}{2}".format(
		ffscpt, filepath, f)
        res = os.popen(cmd)
        infos = str_helper.json_decode(res.read().strip())
        if infos.get('format', None) is not None:
            du = infos['format']['duration']
            params = (f, du,)
            print params
            id = mysql_helper.insert_or_update_or_delete(sqlup, params, True)
Beispiel #6
0
def _check_customJson(customJson):
    if None == customJson or '' == customJson:
        return True
    try:
        ls = str_helper.json_decode(customJson)            
        for m in ls:
            keys = m.keys()
            if ('k' not in keys) or ('v' not in keys) or (not isinstance(m['k'], str) and not isinstance(m['k'], unicode)) or (not str_helper.check_num_abc_port__(m['k'])):
                return False
    except:
        return False
    return True
Beispiel #7
0
def init_func_right( funcs):
    #初始化功能的权限信息
    if None == funcs or len(funcs) <= 0:
        return None

    for func in funcs:
        if func.get('right', None) == None:
            func['right'] = 0
        if func.get('customJson','') != '' and (isinstance(func['customJson'], str) or isinstance(func['customJson'], unicode)):
            func['customJson'] = str_helper.json_decode(func['customJson'])
            for j in func['customJson']:
                j['right'] = False
        else:
            func['customJson'] = None
    return funcs
Beispiel #8
0
def init_func_right(funcs):
    #初始化功能的权限信息
    if None == funcs or len(funcs) <= 0:
        return None

    for func in funcs:
        if func.get('right', None) == None:
            func['right'] = 0
        if func.get('customJson',
                    '') != '' and (isinstance(func['customJson'], str)
                                   or isinstance(func['customJson'], unicode)):
            func['customJson'] = str_helper.json_decode(func['customJson'])
            for j in func['customJson']:
                j['right'] = False
        else:
            func['customJson'] = None
    return funcs
Beispiel #9
0
def collect_server_info():
    ''' 采集服务器信息 '''
    global _ip, _id
    url = config.collect_url % {'ip': _ip}
    params = {
        'id' : _id,        
        'time' : date_helper.get_now_datetimestr3(),
    }

    re = http_helper.get(url, params = params)
    if 200 == re.status_code:
        re.encoding = 'utf-8'
        log = 'collect_server_info:%s;result:%s' % (re.url, re.text)
        logger().info(log)
        return str_helper.json_decode(re.text)

    log = 'collect_server_info:%s;resultcode:%d' % (re.url, re.status_code)
    logger().info(log)
    return None
Beispiel #10
0
    def get_new_log(self):
        url = config.ucmq_path
        params = {
            'name' : self.mqName,
            'opt' : 'get',
            'ver' : 2,
        }

        re = http_helper.get(url, params = params)
        if 200 == re.status_code:
            re.encoding = 'utf-8'
            log = 'log_info:%s;result:%s' % (re.url, re.text)
            self.get_run_logger().info(log)
            if 'QUE_EMPTY' in re.text:
                return None
            json = re.text[13:].strip()
            self.get_collect_logger().info(json)
            return str_helper.json_decode(json)

        log = 'log_info:%s;resultcode:%d' % (re.url, re.status_code)
        self.get_run_logger().info(log)
        return None