コード例 #1
0
def find_ip_ishave(filename):
    cf = IniConfig()
    cf.read(filename)
    ip = cf.get("STB", "IP")
    if ip == "":
        return 0
    return 1
コード例 #2
0
ファイル: modbc.py プロジェクト: y00273676/music_manager
def set_my_sql(filename, jsondata, strcode):
    item = jsondata
    cf = IniConfig()
    cf.readfp(codecs.open(filename, "r", strcode))
    cf.set("MYSQL", "SERVER", item['DataBaseServerIp'])
    cf.set("MYSQL", "USER", item['UserName'])
    cf.write(codecs.open(filename, "w", strcode))
コード例 #3
0
ファイル: modbc.py プロジェクト: y00273676/music_manager
def set_ktv(jsondata, strcode):
    item = jsondata
    mypath = read_path_ini()
    cf = IniConfig()
    cf.readfp(codecs.open(mypath['systemparh'], "r", strcode))
    cf.set("KTV", "Version", item['Version'])
    cf.set("KTV", "DataBaseName", item['DataBaseName'])
    cf.write(codecs.open(mypath['systemparh'], "w", strcode))
コード例 #4
0
def find_stbip_name(filename):
    cf = IniConfig()
    cf.read(filename)
    ip = cf.get("STB", "IP")
    if ip:
        return ip
    else:
        return None
コード例 #5
0
def update_set_ini(filename, option):
    cf = IniConfig()
    cf.read(filename)
    for item in option:
        if item['optionvalue'] == "":
            if get_all_config_no_filename(item['appvalue']):
                cf.set("PROSET", item['appvalue'], '1')
        else:
            cf.set("PROSET", item['appvalue'], item['optionvalue'])
    cf.write(open(filename, "w"))
コード例 #6
0
def set_misc(filename, jsondata, strcode):
    item = jsondata
    cf = IniConfig()
    cf.readfp(codecs.open(filename, "r", strcode))

    cf.set("Misc", "Salutatory", item['Salutatory'])
    cf.set("Misc", "StayTime", item['StayTime'])

    #     cf.set("Misc", "LoginPhoto", item['LoginPhoto'])
    cf.write(codecs.open(filename, "w", strcode))
コード例 #7
0
def set_ktv(filename, jsondata, strcode):
    item = jsondata
    cf = IniConfig()
    cf.readfp(codecs.open(filename, "r", strcode))
    cf.set("KTV", "Version", item['Version'])
    #     cf.set("KTV", "DataBaseName", item['DataBaseName'])
    cf.write(codecs.open(filename, "w", strcode))
コード例 #8
0
def update_init_ini(filename):
    cf = IniConfig()
    f = open(filename, "r")
    data = f.read()
    cf.readfp(codecs.open(filename, "r", chardet.detect(data)['encoding']))
    #     cf.read(filename)
    #检查是否含有下面一个标签
    sections = cf.sections()
    if len(sections) == 1:
        cf.add_section("PROSET")
        cf.write(codecs.open(filename, "w", "utf8"))
コード例 #9
0
def delete_file_ini(filename):
    cf = IniConfig()
    cf.read('path.ini')

    #获取路径的基本地址
    str_val = cf.get("sec_a", "boxpath")
    print str_val
    mname = str_val + filename + ".ini"
    print mname

    if os.path.exists(mname):
        os.remove(mname)
        if os.path.exists(mname):
            return False

    return True
コード例 #10
0
def _get_dbinfo():
    cf = IniConfig()
    cf.readfp(codecs.open('/opt/thunder/thunder.ini', "r", 'utf8'))
    ini_master = cf.items("MainServer")
    dbinfo = {}
    dbinfo['host'] = '127.0.0.1'
    dbinfo['passwd'] = 'Thunder#123'
    dbinfo['user'] = '******'
    dbinfo['port'] = 3306
    dbinfo['db'] = 'karaok'
    for item in ini_master:
        if item[0] == 'UserName':
            dbinfo['user'] = item[1]
        elif item[0] == 'Password':
            dbinfo['passwd'] = item[1]
        elif item[0] == 'DataBaseServerIp':
            dbinfo['host'] = item[1]

    return dbinfo
コード例 #11
0
def set_erp_conf(ip):
    try:
        cf = IniConfig()
        cf.readfp(
            codecs.open("/usr/local/freetds/etc/freetds.conf", "r", "utf8"))
        #     cf.readfp(codecs.open("orm/freetds.conf", "r", "utf8"))
        cf.set("ThunderERP", "host", ip)
        cf.write(
            codecs.open("/usr/local/freetds/etc/freetds.conf", "w", "utf8"))
        return 0
    except:
        return 1
コード例 #12
0
def get_doginfo_by_local():
    read_path = '/opt/thunder/bin/mainktvserver/'
    filename = os.path.join(read_path, 'licenseinfo')

    cf = IniConfig()

    f = open(filename, "r")
    data = f.read()
    cf.readfp(codecs.open(filename, 'r', 'gbk'))

    doginfo = cf.items("DOGINFO")
    print('^' * 17)
    print("%s" % doginfo)

    mdata = {}
    for colum in doginfo:
        mdata[colum[0]] = colum[1]
    mdata['dogip'] = getLocalIp("eth0")
    #set_dog_info(getLocalIp("eth0"),mdata['describe'])
    return mdata
コード例 #13
0
def read_all_setting(filename, strcode):
    datajson = {}
    cf = IniConfig()

    f = open(filename, "r")
    data = f.read()
    print chardet.detect(data)
    # cf.read(filename)
    cf.readfp(codecs.open(filename))
    sections = cf.sections()
    mainserver = cf.items("MainServer")
    erpserver = cf.items("ErpServer")
    misc = cf.items("Misc")
    ktv = cf.items("KTV")
    erp = cf.items("ERP")

    _mjson = {}
    _mprjson = {}
    _mmijson = {}
    _mktvjson = {}
    _merpjson = {}

    for colum in mainserver:
        _mjson[colum[0]] = colum[1]
    for columone in erpserver:
        _mprjson[columone[0]] = columone[1]

    for columtwo in misc:
        _mmijson[columtwo[0]] = columtwo[1]
    for columtwo in ktv:
        _mktvjson[columtwo[0]] = columtwo[1]
    for columtwo in erp:
        _merpjson[columtwo[0]] = columtwo[1]

    datajson['mainserver'] = _mjson
    datajson['erpserver'] = _mprjson
    datajson['misc'] = _mmijson
    datajson['erp'] = _merpjson
    datajson['ktv'] = _mktvjson
    print 'xxxx', type(datajson['mainserver']['DataBaseServerIp'])
    print datajson
    return datajson
コード例 #14
0
def read_all_info_init(filename, strcode):
    datajson = {}
    cf = IniConfig()
    # cf.read(filename)
    cf.readfp(codecs.open(filename, "r", strcode))
    sections = cf.sections()
    mainserver = cf.items("Boxtype")

    _mjson = {}
    for colum in mainserver:
        _mjson[colum[0]] = colum[1]

    return _mjson
コード例 #15
0
def get_all_set_list_ini(filename):
    datajson = {}
    cf = IniConfig()
    cf.read(filename)
    stb = cf.items("STB")
    proset = cf.items("PROSET")
    _mjson = {}
    _mprjson = {}
    for colum in stb:
        _mjson[colum[0]] = (colum[1])  #.decode('gb2312').encode('utf8')
    for columone in proset:
        _mprjson[columone[0]] = columone[1]

    #需要转换编码
    datajson['box'] = _mjson
    datajson['option'] = _mprjson
    return datajson
コード例 #16
0
def get_all_set_list_ini(filename):
    datajson = {}
    cf = IniConfig()
    f = open(filename, "r")
    data = f.read()
    print chardet.detect(data)
    cf.readfp(codecs.open(filename, "r", chardet.detect(data)['encoding']))
    sections = cf.sections()
    stb = cf.items("STB")
    proset = cf.items("PROSET")
    _mjson = {}
    _mprjson = {}
    for colum in stb:
        _mjson[colum[0]] = colum[1]
    for columone in proset:
        _mprjson[columone[0]] = columone[1]

    datajson['box'] = _mjson
    datajson['option'] = _mprjson
    print datajson
    return datajson
コード例 #17
0
ファイル: modbc.py プロジェクト: y00273676/music_manager
def read_all_setting(filename, strcode):
    datajson = {}
    cf = IniConfig()
    # cf.read(filename)
    cf.readfp(codecs.open(filename, "r", strcode))
    sections = cf.sections()
    mainserver = cf.items("MainServer")
    #erpserver=cf.items("ErpServer")
    misc = cf.items("Misc")
    #ktv=cf.items("KTV")
    #erp=cf.items("ERP")

    _mjson = {}
    _mprjson = {}
    _mmijson = {}
    _mktvjson = {}
    _merpjson = {}

    for colum in mainserver:
        _mjson[colum[0]] = colum[1]
    #for columone in erpserver:
    #    _mprjson[columone[0]]=columone[1]

    for columtwo in misc:
        _mmijson[columtwo[0]] = columtwo[1]
    #for columtwo in ktv:
    #    _mktvjson[columtwo[0]]=columtwo[1]
    #for columtwo in erp:
    #    _merpjson[columtwo[0]]=columtwo[1]

    datajson['mainserver'] = _mjson
    #datajson['erpserver']=_mprjson
    datajson['misc'] = _mmijson
    #datajson['erp']=_merpjson
    #datajson['ktv']=_mktvjson

    return datajson
コード例 #18
0
def set_main_server(filename, jsondata, strcode):
    item = jsondata
    cf = IniConfig()

    cf.readfp(codecs.open(filename, "r", strcode))
    cf.set("MainServer", "DataBaseServerName", item['DataBaseServerName'])
    cf.set("MainServer", "DataBaseServerIp", item['DataBaseServerIp'])
    cf.set("MainServer", "UserName", item['UserName'])
    cf.set("MainServer", "Password", item['Password'])
    localIP = getLocalIp("eth0")
    cf.set("MainServer", "FileServerIP", localIP)
    cf.write(codecs.open(filename, "w", strcode))
コード例 #19
0
def set_video_server(filename, jsondata, strcode):
    cf = IniConfig()
    cf.readfp(codecs.open(filename, "r", strcode))
    cf.set("VideoServer", "AssignMethod", item['AssignMethod'])
    cf.set("VideoServer", "LoadMethod", item['LoadMethod'])
    cf.set("VideoServer", "Hosttask", item['Hosttask'])
    cf.set("VideoServer", "RandPlayType", item['RandPlayType'])
    cf.write(codecs.open(filename, "w", strcode))
コード例 #20
0
ファイル: modbc.py プロジェクト: y00273676/music_manager
def set_main_server_first(jsondata, strcode):

    try:
        item = jsondata
        mypath = read_path_ini()
        cf = IniConfig()

        cf.readfp(codecs.open(mypath['systemparh'], "r", strcode))
        cf.set("MainServer", "DataBaseServerIp", item['DataBaseServerIp'])
        cf.set("MainServer", "UserName", item['UserName'])
        cf.set("MainServer", "Password", item['Password'])
        cf.set("MainServer", "FileServerIP", item['FileServerIP'])
        #获取本机ip的地址
        #     cf.set("MainServer", "FileServerIP", item['FileServerIp'])
        cf.write(codecs.open(mypath['systemparh'], "w", strcode))
        set_odbc_ini(mypath['odbcpath'], jsondata, strcode)
        set_my_sql(mypath['odbcinstpath'], jsondata, strcode)
        return 0
    except:
        return 1
コード例 #21
0
ファイル: modbc.py プロジェクト: y00273676/music_manager
def set_modbc_erpserver(jsondata, strcode):
    item = jsondata
    mypath = read_path_ini()
    cf = IniConfig()
    cf.readfp(codecs.open(mypath['systemparh'], "r", strcode))
    cf.set("ErpServer", "DataBaseServerName", item['DataBaseServerName'])
    cf.set("ErpServer", "DataBaseServerIp", item['DataBaseServerIp'])
    cf.set("ErpServer", "UserName", item['UserName'])
    cf.set("ErpServer", "Password", item['Password'])
    cf.write(codecs.open(mypath['systemparh'], "w", strcode))
コード例 #22
0
def set_erp(filename, jsondata, strcode):
    item = jsondata
    cf = IniConfig()
    cf.readfp(codecs.open(filename, "r", strcode))
    cf.set("ERP", "DataBaseName", item['DataBaseName'])
    cf.write(codecs.open(filename, "w", strcode))
コード例 #23
0
ファイル: modbc.py プロジェクト: y00273676/music_manager
def set_misc(jsondata, strcode):
    item = jsondata
    mypath = read_path_ini()
    cf = IniConfig()
    cf.readfp(codecs.open(mypath['systemparh'], "r", strcode))

    cf.set("Misc", "Salutatory", item['Salutatory'])
    cf.set("Misc", "StayTime", item['StayTime'])

    cf.set("Misc", "LoginPhoto", item['LoginPhoto'])
    cf.write(codecs.open(mypath['systemparh'], "w", strcode))
コード例 #24
0
def set_erpserver(filename, jsondata, strcode):
    item = jsondata
    cf = IniConfig()
    cf.readfp(codecs.open(filename, "r", strcode))
    cf.set("ErpServer", "DataBaseServerName", item['DataBaseServerName'])
    cf.set("ErpServer", "DataBaseServerIp", item['DataBaseServerIp'])
    cf.set("ErpServer", "UserName", item['UserName'])
    cf.set("ErpServer", "Password", item['Password'])
    cf.write(codecs.open(filename, "w", strcode))
    set_erp_conf(item['DataBaseServerIp'])
コード例 #25
0
def set_main_server_ip(filename, ip, strcode):
    cf = IniConfig()
    cf.readfp(codecs.open(filename, "r", strcode))
    cf.set("MainServer", "DataBaseServerIp", ip)
    cf.write(codecs.open(filename, "w", strcode))
コード例 #26
0
def update_dhcp_ini(room_mac, roominfo):
    ini_path = os.path.join(DHCP_CONFIG_PATH, 'STBs/%s.ini' % room_mac)
    if os.path.exists(ini_path):
        os.remove(ini_path)
    cf = IniConfig()
    #默认信息:
    if not cf.has_section('STB'):
        cf.add_section('STB')
    cf.set("STB", "CLIENTTYPE", 0)
    cf.set("STB", "DYNCONFIG", 0)
    cf.set("STB", "SCREENMODE", 1)
    cf.set("STB", "VGARES", 1)
    cf.set("STB", "TVMODE", 1)
    cf.set("STB", "OtherSettings", "")
    cf.set("STB", "BootFile", "pxelinux.0")
    cf.set("STB", "DefaultRouter", "")
    cf.set("STB", "DomainName", "")
    cf.set("STB", "STBType", 0)
    cf.set("STB", "VGATYPE", "")

    #基本信息
    cf.set("STB", "IP", roominfo['room_ip'])
    cf.set("STB", "MAC", room_mac)
    cf.set("STB", "NMASK", roominfo['room_mask'])
    cf.set("STB", "SERVER", roominfo['room_svr'])
    cf.set("STB", "STBType", 1)
    cf.set("STB", "RecordSvr", roominfo['room_recordsvr'])
    cf.set("STB", "Name", roominfo['room_name'])

    if not cf.has_section('PROSET'):
        cf.add_section('PROSET')
    try:
        options = json.loads(roominfo['room_profile'])
    except Exception as ex:
        logger.error(str(ex))
        options = []
    for op in options:
        cf.set("PROSET", op['appvalue'], op['optionvalue'])

    cf.write(open(ini_path, "w"))
    return True
コード例 #27
0
ファイル: modbc.py プロジェクト: y00273676/music_manager
def set_video_server(jsondata, strcode):
    item = jsondata
    mypath = read_path_ini()
    cf = IniConfig()
    cf.readfp(codecs.open(mypath['systemparh'], "r", strcode))
    cf.set("VideoServer", "AssignMethod", item['AssignMethod'])
    cf.set("VideoServer", "LoadMethod", item['LoadMethod'])
    cf.set("VideoServer", "Hosttask", item['Hosttask'])
    cf.set("VideoServer", "RandPlayType", item['RandPlayType'])
    cf.write(codecs.open(mypath['systemparh'], "w", strcode))
コード例 #28
0
def remove_update_ini(filename, section, option, args):
    cf = IniConfig()
    cf.read(filename)

    cf.set("STB", "IP", args['ipaddress'])
    cf.set("STB", "NMASK", args['subnetmask'])
    cf.set("STB", "SERVER", args['serviceip'])
    cf.set("STB", "STBType", args['devicetype'])
    cf.set("STB", "RecordSvr", args['iprecond'])
    cf.set("STB", "Name", args['name'])

    sections = cf.sections()
    if len(sections) == 1:
        cf.add_section("PROSET")
    else:
        cf.remove_section(section)
        cf.add_section(section)

    for item in option:
        if item['optionvalue'] == "":
            if get_all_config_no_filename(item['appvalue']):
                cf.set("PROSET", item['appvalue'], '1')
        else:
            cf.set("PROSET", item['appvalue'], item['optionvalue'])
    cf.write(open(filename, "w"))
コード例 #29
0
def remove_set_ini(filename, section):
    cf = IniConfig()
    cf.read(filename)
    sections = cf.sections()
    if len(sections) == 1:
        cf.add_section("PROSET")
    else:
        cf.remove_section(section)
        cf.add_section(section)
    cf.write(open(filename, "w"))
コード例 #30
0
ファイル: modbc.py プロジェクト: y00273676/music_manager
def set_odbc_ini(filename, jsondata, strcode):
    item = jsondata
    cf = IniConfig()
    cf.readfp(codecs.open(filename, "r", strcode))
    cf.set("krok", "SERVER", item['DataBaseServerIp'])
    cf.set("krok", "USER", item['UserName'])
    cf.set("krok", "PASSWORD", item['Password'])

    cf.set("mysql", "SERVER", item['DataBaseServerIp'])
    cf.set("mysql", "USER", item['UserName'])
    cf.write(codecs.open(filename, "w", strcode))