当前位置: 首页>>代码示例>>Python>>正文


Python MyUtil类代码示例

本文整理汇总了Python中MyUtil的典型用法代码示例。如果您正苦于以下问题:Python MyUtil类的具体用法?Python MyUtil怎么用?Python MyUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MyUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SvcDoRun

    def SvcDoRun(self):
        try:
            global LOG,DBIP,DBPort,_3ds,log,socksize,innerIP,CPUCores
            socksize = 64000
            _3ds = MyUtil._secret()
            cf1 = ConfigParser.ConfigParser()
            cf1.read(MyUtil.cur_file_dir() + "\\agent.ini")
            agentpath = cf1.get("main", "path").decode('gbk').encode("utf-8")
            agentlogfile = cf1.get("main", "agentlogfile").decode('gbk').encode("utf-8")
            MyUtil.DBIP = cf1.get("main", "DBIP").decode('gbk').encode("utf-8")
            MyUtil.DBPort = cf1.get("main", "DBPort").decode('gbk').encode("utf-8")          
            LOG = os.path.join(agentpath,agentlogfile)
            #创建日志实例
            log = MyUtil.CLogInfo(LOG)        
            
            cf = ConfigParser.ConfigParser()
            cf.read(MyUtil.cur_file_dir()+"\\auto.ini")
            #强制读取配置文件中的IP地址设置,当前的问题是第一次必须手工更改配置文件中的IP,否则传出的IP错误
            innerIP = cf.get("Configuration", "localip").decode('gbk').encode("utf-8")            
            try:
                CPUCores = cf.get("Configuration","cpucores").decode('gbk').encode("utf-8")
                CPUCores = int(CPUCores)
            except:
                CPUCores = int('1')

            rc = runCron()
            rc.run()
        except:
            #print "main Error:"+str(sys.exc_info()[0])+str(sys.exc_info()[1])
            pass
开发者ID:derekzhan,项目名称:ioms,代码行数:30,代码来源:AgentService.py

示例2: make_cid

def make_cid(dirpath, CID_coll, htmlfile, outroot):
    # Get list of DCC documents from a Word file saved as html
    GetUrlWord.get_url_word(dirpath + outroot, dirpath + htmlfile)  

    # Login to DCC
    s = DCC.login(CF.dcc_url + CF.dcc_login)

    json_handlelist = dirpath + outroot + 'bothlist.txt'
    json_ssdata = dirpath + outroot + 'CID.txt'
    get_cid_ssdata(s, json_handlelist, json_ssdata)

    xlfile = dirpath + outroot + 'CID_Analysis.xls'
    write_spreadsheet(json_ssdata, xlfile)

    json_verlist = dirpath + outroot + 'ver_list.txt'
    json_doclist = dirpath + outroot + 'doc_list.txt'
    make_handle_lists(json_ssdata, json_doclist, json_verlist)

    ## Remove the files that are currently located in the collection for the CID

    if MyUtil.get_yn('Remove location (not delete) of files from ' + CID_coll[0] +'(Y/N)?: '):
        doclist = DCC.list_obj_in_coll(s, CID_coll[0],Print=True,Jwrite=False,Depth='infinity',Type='Doc')
        for doc in doclist:
            DCC.dcc_remove_doc_from_coll(s, doc, CID_coll[0])

    ## Add CID files to the collection
    fh = open(json_doclist, 'r')
    dl = json.load(fh)
    fh.close()

    if MyUtil.get_yn('Add CID files to ' + CID_coll[0] +' (Y/N)?: '):
        DCC.add_docs_2_collections(s, dl, CID_coll)

    # Check that the expected docs are in the collection
    DCC.check_docs_in_coll(s, dl, CID_coll)
开发者ID:pbbarnes,项目名称:Library1,代码行数:35,代码来源:CID.py

示例3: cronAdd

def cronAdd(cmds, cmd):
    """增加守护进程列表的方法
    cmd=cronadd,cronadd=*;*;*;*;*;c:\WINDOWS\NOTEPAD.EXE;NOTEPAD.EXE
    """
    try:
        if not 'cronadd' in cmds.keys():
            return "-1", "Lost cronadd.缺少cronadd参数".decode('gbk').encode("utf-8")
        cronNew = cmds['cronadd'].upper() + '\n'
        if not cronNew.find(';'):
            return "-1", "parameter Error.请使用;分号为分隔符".decode('gbk').encode("utf-8")
        cronNew = cronNew.replace(';', ',')
        if os.path.isfile(MyUtil.cur_file_dir() + '\\crontab.ini'):
            f = open(MyUtil.cur_file_dir() + '\\crontab.ini', "r+")
            cronMatch = False
            for eachLine in f:
                if cronNew == eachLine.upper():
                    cronMatch = True
                    break
                else:
                    cronMatch = False
            str1 = 'Find duplicate cron.'
            if not cronMatch:
                f.write(cronNew + '\n')
                str1 = 'cronadd OK.'
            f.close()
            return "1", str1
        else:
            return "-1", 'crontab.ini not found.'
    except:
        return "-1", "CronAdd.Error"
开发者ID:derekzhan,项目名称:ioms,代码行数:30,代码来源:CMDServer.py

示例4: __startSipLib

    def __startSipLib(self):
        isSuccess = True
        global lib
        if lib:
            self.__stopSipLib()

        lib =  pj.Lib()
        self._listCallInfo=[]

        try:
        # if True:
            dao = self.configDao;
            mediaConfig=MediaConfig()
            mediaConfig.enable_ice = MyUtil.db_str2bool(dao.GetIsUseIce())
            mediaConfig.enable_turn =MyUtil.db_str2bool(dao.GetIsUseTurn())
            if mediaConfig.enable_turn:
                mediaConfig.turn_server = str(dao.GetTurnServer())

            uaConfig=UAConfig()
            if (MyUtil.db_str2bool(dao.GetIsUseStun())):
                uaConfig.stun_srv = [str(dao.GetStunServer())]

            lib.init(ua_cfg = uaConfig,log_cfg = pj.LogConfig(level=int(dao.GetLogLevel()), callback=self.log_cb), media_cfg=mediaConfig)
            lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(int(dao.GetSipSendPort())))
            lib.start()
        except:
            isSuccess=False
            self.show_err_msg()

        if isSuccess:
            isSuccess=self.reRegister()


        return isSuccess
开发者ID:advx9600,项目名称:PythonCharm,代码行数:34,代码来源:VideoForm.py

示例5: setLocalIP

def setLocalIP():
    #强写本地IP地址到配置文件中去
    cf1 = ConfigParser.ConfigParser()
    cf1.read(MyUtil.cur_file_dir() + "\\auto.ini")
    ipMac = ServerInfo.GetinnerIPMac()
    innerIP = str(ipMac[0])
    cf1.set("Configuration", "localIP", innerIP)
    cf1.write(open(MyUtil.cur_file_dir() + "\\auto.ini", "w"))
开发者ID:derekzhan,项目名称:ioms,代码行数:8,代码来源:CMDServer.py

示例6: make_cid

def make_cid(dirpath, CID_coll, htmlfile, outroot):
    # Get list of DCC documents from a Word file saved as html
    GetUrlWord.get_url_word(dirpath + outroot, dirpath + htmlfile)  

    # Login to DCC
    prod = ['prod', 'production', 'p', ' ']
    tes = ['test', 'tes', 't']
    checker = False
    print("Would you like to log into the production site or the test site?")
    print("Valid Inputs are as follows: Production, prod, p, test, t :", end="")
    choice = input().lower()
    #while loop to continue asking the user for input until a correct input has been entered
    while (checker == False):
        #Production site login choice
        if(choice in prod):
            print("You are now logging into the Production version of DocuShare")
            s = DCC.login(Site ='Production')
            checker = True
        #test site login choice
        elif(choice in tes):
            print("You are now logging into the test VM DocuShare")
            s = DCC.login(Site ='Test')
            checker = True
        #cf.dcc_url + cf.dcc_login
        #error message alerting user to enter a valid choice
        else:
            print("Please enter a valid choice, (P)roduction or (T)est")
            choice = input().lower()

    json_handlelist = dirpath + outroot + 'bothlist.txt'
    json_ssdata = dirpath + outroot + 'CID.txt'
    get_cid_ssdata(s, json_handlelist, json_ssdata)

    xlfile = dirpath + outroot + 'CID_Analysis.xls'
    write_spreadsheet(json_ssdata, xlfile)

    json_verlist = dirpath + outroot + 'ver_list.txt'
    json_doclist = dirpath + outroot + 'doc_list.txt'
    make_handle_lists(json_ssdata, json_doclist, json_verlist)

    ## Remove the files that are currently located in the collection for the CID

    if MyUtil.get_yn('Remove location (not delete) of files from ' + CID_coll[0] +'(Y/N)?: '):
        doclist = DCC.list_obj_in_coll(s, CID_coll[0],Print=True,Jwrite=False,Depth='infinity',Type='Doc')
        for doc in doclist:
            DCC.dcc_remove_doc_from_coll(s, doc, CID_coll[0])

    ## Add CID files to the collection
    fh = open(json_doclist, 'r')
    dl = json.load(fh)
    fh.close()

    if MyUtil.get_yn('Add CID files to ' + CID_coll[0] +' (Y/N)?: '):
        DCC.add_docs_2_collections(s, dl, CID_coll)

    # Check that the expected docs are in the collection
    DCC.check_docs_in_coll(s, dl, CID_coll)
开发者ID:gtrancho,项目名称:Library,代码行数:57,代码来源:CID.py

示例7: downfile

    def downfile(self,filename,cmdStr):
#        """下载文件
#        """
#        try:
            jieguo = ""
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock.connect((self.host,self.port ))
            sock.sendall('au,'+cmdStr)
            self.response = sock.recv(self.sockSize)
            l = string.split(self.response)
            #如果返回有文件名,而且一致,说明有MD5码
            if l[0] == filename:
                returnMD5=l[1]
                #确认本地存放路径
                MyUtil.mkpath(path)
                # 'please wait...'
                Fname = os.path.join(path,filename)
                f = open(Fname, 'wb')
                #print '开始下载。。。'
                i = 0
                while True:
                    data = sock.recv(10485760)
                    #print '接受文件中。。。。','  ',i
                    i+=1
                    if not data:
                        break
                    if str(data).endswith('4423718C61C4E8A4362D955BBC7B9711'):
                        data = data[:len(data)-len('4423718C61C4E8A4362D955BBC7B9711')]
                        f.write(data)
                        break
                    f.write(data)
                f.flush()    
                f.close()
                #print '接受完毕。。。。'
                FMD5 = string.split(md5sum(Fname))
                if FMD5[0] > int("0"):
                    if FMD5[1] == returnMD5:
                        if 'updateself' in cmdStr:
                            jieguo = 2
                        else:
                            jieguo = 1
                    else:
                        jieguo = -2
                else:
                    jieguo = -3

            elif l[0] == '-1':
                jieguo = -4
            elif l[0] == '-2':
                jieguo = -5
            else:
                jieguo = -6
                
            sock.close()
            #print jieguo
            return jieguo
开发者ID:derekzhan,项目名称:ioms,代码行数:56,代码来源:AgentUpdateClient.py

示例8: log_cb

    def log_cb(self,level, str2, len):
        if (level==1):
            MyUtil.saveErrorLog(str2)
            self.lastErrorInfo += str(str2)

        ### this is the err can't be caught by the program
        if (level ==1):
            if "[status=370004]" in str2:
                self.show_err_msg()
        print str2
开发者ID:advx9600,项目名称:PythonCharm,代码行数:10,代码来源:VideoForm.py

示例9: setValue

    def setValue(self,isUseIce,isUseStun,stunServer,isUseTurn,turnServer):
        if MyUtil.db_str2bool(isUseIce):
            self.useIce.SetValue(True)
        if MyUtil.db_str2bool(isUseStun):
            self.useStun.SetValue(True)
        if MyUtil.db_str2bool(isUseTurn):
            self.useTurn.SetValue(True)

        self.stunServer.SetValue(stunServer)
        self.turnServer.SetValue(turnServer)
开发者ID:advx9600,项目名称:PythonCharm,代码行数:10,代码来源:MyWidget.py

示例10: downfile

    def downfile(self,filename,cmdStr):
        """下载文件
        """
        try:
            jieguo = ""
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock.connect((self.host,self.port ))
            sock.sendall('au,'+cmdStr)
            self.response = sock.recv(self.sockSize)
            l = string.split(self.response)
            #如果返回有文件名,而且一致,说明有MD5码
            if l[0] == filename:
                returnMD5=l[1]
                #确认本地存放路径
                MyUtil.mkpath(path)
                Fname = os.path.join(path,filename)
                f = open(Fname, 'wb')
                i = 0
                while True:
                    data = sock.recv(10485760)
                    i+=1
                    if not data:
                        break
                    if str(data).endswith('4423718C61C4E8A4362D955BBC7B9711'):
                        data = data[:len(data)-len('4423718C61C4E8A4362D955BBC7B9711')]
                        f.write(data)
                        break
                    f.write(data)
                f.flush()    
                f.close()
                FMD5 = string.split(md5sum(Fname))
                if FMD5[0] > int("0"):
                    if FMD5[1] == returnMD5:
                        if 'updateself' in cmdStr:
                            jieguo = 2
                        else:
                            jieguo = 1
                    else:
                        jieguo = -2
                else:
                    jieguo = -3

            elif l[0] == '-1':
                jieguo = -4
            elif l[0] == '-2':
                jieguo = -5
            else:
                jieguo = -6
                
            sock.close()
            return jieguo
            
        except:
            updateselflog("Client.downfile Error:"+str(sys.exc_info()[0])+str(sys.exc_info()[1]))
开发者ID:derekzhan,项目名称:ioms,代码行数:54,代码来源:AgentUpdateClient.py

示例11: modify_dcc_perms

def modify_dcc_perms(s, handle, permdata, **kwargs):
    ask_flag = kwargs.get('Ask',True)
    print('\n   Modifying Permissions to:',handle)
    DCC.print_perms(permdata)       
    if ask_flag == False or MyUtil.get_yn('Change Permissions (Y/N)?'):
        print('Changing permissions...')
        DCC.set_permissions(s, handle, permdata)
开发者ID:pbbarnes,项目名称:Library1,代码行数:7,代码来源:PERM.py

示例12: writeCfgfile

def writeCfgfile(setIP,setinnerMAC,setWAIIP,setOS,setCodeSet,setCPUCores,setHostname,setPlatform,setSysDir,setCPUInfo,setPHMEM):
    #强写本地IP地址到配置文件中去
    cf1 = ConfigParser.ConfigParser()
    cf1.read(MyUtil.cur_file_dir()+"/auto.ini")
    cf1.set("Configuration", "localIP", setIP)
    cf1.set("Configuration","localMACAddress",setinnerMAC)
    cf1.set("Configuration","OuterIP",setWAIIP)
    cf1.set("Configuration","OS",setOS)
    cf1.set("Configuration","CodeSet",setCodeSet)
    cf1.set("Configuration","CPUCores",setCPUCores)
    cf1.set("Configuration","hostname",setHostname)
    cf1.set("Configuration","Platform",setPlatform)
    cf1.set("Configuration","CPUInfo",setCPUInfo)
    cf1.set("Configuration","SystemDirectory",setSysDir)
    cf1.set("Configuration","Physicalmemory",setPHMEM)
    cf1.write(open(MyUtil.cur_file_dir()+"/auto.ini", "w"))
开发者ID:derekzhan,项目名称:ioms,代码行数:16,代码来源:setCfg.py

示例13: updateselflog

def updateselflog(data):
    """写日志方法
    """
    f = open(MyUtil.cur_file_dir()+"\\updateself.log","w")
    f.write(data)
    f.close()
    
开发者ID:derekzhan,项目名称:ioms,代码行数:6,代码来源:AgentUpdateClient.py

示例14: check_perms

def check_perms(s, set, handles, **kwargs):
    ask_flag = kwargs.get('Ask', True)
    if not ask_flag:
        if not MyUtil.get_yn('!!! Warning !!! ask = False: Will not ask to make changes, okay? Enter N to Exit, Y to Continue:'):
            print('exiting...')
            sys.exit(0)
    for handle in handles:
        if 'Document-' in handle:
            fd = DCC.prop_get(s, handle, InfoSet = 'DocBasic')
        elif 'Collection-' in handle:
            fd = DCC.prop_get(s, handle, InfoSet = 'CollData')
        else:
            fd = DCC.prop_get(s, handle, InfoSet = 'Title')    
        fd['permissions'] = DCC.prop_get(s, handle, InfoSet = 'Perms')
#         print(fd['handle'], ':', fd['title'])    
        
        print('\n>>>>>>>>>>>>>>       DCC Information       <<<<<<<<<<<<<<')
        if 'Document-' in handle:
            DCC.print_doc_basic(fd)
        elif 'Collection-' in handle:
            DCC.print_coll_data(fd)
        else:
            print('Not Document or Collection:', handle, ':', fd['title'])   
        print('\n\tDoc Properties URL: ',Tree.url_view(handle))
        print('\tPermissions URL: ',Tree.url_perm(handle))
        print('\tGet Document URL: ',Tree.url_access(handle))

        
        print()
    
        fix_objact(s, fd, handle, set, **kwargs)
        fix_permact(s, fd, handle, set, **kwargs)
开发者ID:TMTSystemsEngineering,项目名称:Library,代码行数:32,代码来源:PERM.py

示例15: fix_objact

def fix_objact(s, fd, handle, set, **kwargs):
    ask_flag = kwargs.get('Ask',True)
    
    if not check_fd_sel(fd, set):
        return
        
    for obj_act in set['ObjAct']:
        if not obj_act['Action']:
            pass

        if Match.parse(obj_act['Criteria'], fd):
            if obj_act['Action']['Action'] == 'SetOwner':
                nu = DCC.prop_get(s, obj_act['Action']['Owner'], InfoSet = 'User')
                print('??? Change Owner from [', fd['owner-userid'], ',', fd['owner-username'], '] to [', 
                                        nu['owner-userid'], ',', nu['owner-username'], ']', sep = '', end = '') 
                if ask_flag == False or MyUtil.get_yn(': (Y/N)? '):
                    DCC.change_owner(s, handle, obj_act['Action']['Owner'])
                    
            elif obj_act['Action']['Action'] == 'AddKeyword':
                print('??? Add Keyword "', obj_act['Action']['Keyword'], '" to "', fd['keywords'].strip(), '"', sep = '', end = '') 
                if ask_flag == False or MyUtil.get_yn(': (Y/N)? '):
                    kw = obj_act['Action']['Keyword'] + fd['keywords'].strip(' ')
                    DCC.set_metadata(s, handle, Keywords = kw)

            elif obj_act['Action']['Action'] == 'DelKeyword':
                print('??? Remove Keyword "', obj_act['Action']['Keyword'], '" from "', fd['keywords'], '"', sep = '', end = '') 
                if ask_flag == False or MyUtil.get_yn(': (Y/N)? '):
                    kw = fd['keywords'].strip(' ').replace(obj_act['Action']['Keyword'], '')
                    DCC.set_metadata(s, handle, Keywords = kw)
                
            elif obj_act['Action']['Action'] == 'RepTitle':
                print('??? Change Title to "', obj_act['Action']['Title'], '" from "', fd['title'], '"', sep = '', end = '') 
                if ask_flag == False or MyUtil.get_yn(': (Y/N)? '):
                    DCC.set_metadata(s, handle, Title = obj_act['Action']['Title'])

            elif obj_act['Action']['Action'] == 'RepTmtNum':
                print('??? Change TmtNum to "', obj_act['Action']['TmtNum'], '" from "', fd['tmtnum'], '"', sep = '', end = '') 
                if ask_flag == False or MyUtil.get_yn(': (Y/N)? '):
                    DCC.set_metadata(s, handle, Summary = obj_act['Action']['TmtNum'])
                pass
                
            elif obj_act['Action']['Action'] == 'Message':
                print(obj_act['Action']['Message'])
                
            else:
                print('Error in PERM.fix_objact: ObjAct Action not recognized:', obj_act['Action']['Action'])
开发者ID:TMTSystemsEngineering,项目名称:Library,代码行数:46,代码来源:PERM.py


注:本文中的MyUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。