Пример #1
0
 def backup(self, strBaseFolder):
     s.GotoFolder(strBaseFolder)
     connFTP = self._FTP_Conn
     lstCFGFile = ['automap.cfg', 'cm.cfg', 'san.cfg']
     for strCFGFile in lstCFGFile:
         if connFTP.GetFile('bin_conf', '.', strCFGFile,
                            'backup_{}_{}'.format(self._host, strCFGFile)):
             print('{} Backup Completely for {}'.format(
                 strCFGFile.ljust(12), self._host))
             continue
         else:
             print('{} Backup Failed for {}'.format(strCFGFile.ljust(12),
                                                    self._host))
             break
         time.sleep(0.25)
Пример #2
0
 def periodic_check(self, lstCommand, strResultFolder, strResultFile):
     tn = self._TN_Conn
     s.GotoFolder(strResultFolder)
     if tn.exctCMD('\n'):
         with open(strResultFile, 'w') as f:
             for strCMD in lstCommand:
                 time.sleep(0.25)
                 strResult = tn.exctCMD(strCMD)
                 if strResult:
                     print(strResult)
                     f.write(strResult)
                 else:
                     strErr = '\n*** Execute Command "{}" Failed\n'.format(
                         strCMD)
                     # print(strErr)
                     f.write(strErr)
Пример #3
0
    def get_trace(self, strBaseFolder, intTraceLevel):
        tn = self._TN_Conn
        connFTP = self._FTP_Conn

        def _get_oddCommand(intTraceLevel):
            oddCMD = OrderedDict()
            if intTraceLevel == 1 or intTraceLevel == 2 or intTraceLevel == 3:
                oddCMD['Trace'] = 'ftpprep trace'
                if intTraceLevel == 2 or intTraceLevel == 3:
                    oddCMD['Primary'] = 'ftpprep coredump primary all'
                    if intTraceLevel == 3:
                        oddCMD['Secondary'] = 'ftpprep coredump secondary all'
                return oddCMD
            else:
                print('Trace Level: 1 or 2 or 3')

        def _get_trace_file(command, strTraceDes):
            # TraceDes = Trace Description
            def _get_trace_name():
                result = tn.exctCMD(command)
                reTraceName = re.compile(r'(ftp_data_\d{8}_\d{6}.txt)')
                strTraceName = reTraceName.search(result)
                if strTraceName:
                    return strTraceName.group()
                else:
                    print('Generate Trace "{}" File Failed for "{}"'.format(
                        strTraceDes, self._host))

            trace_name = _get_trace_name()
            if trace_name:
                time.sleep(0.1)
                local_name = 'Trace_{}_{}.log'.format(self._host, strTraceDes)
                if connFTP.GetFile('mbtrace', '.', trace_name, local_name):
                    print('Get Trace "{:<10}" for "{}" Completely ...'.format(
                        strTraceDes, self._host))
                    return True
                else:
                    print(
                        'Get Trace "{:<10}" for Engine "{}" Failed...\
                        '.format(strTraceDes, self._host))
                #     s.ShowErr(self.__class__.__name__,
                #               sys._getframe().f_code.co_name,
                #               'Get Trace "{:<10}" for Engine "{}" Failed...\
                #               '.format(strTraceDes, self._host))

        oddCommand = _get_oddCommand(intTraceLevel)
        lstCommand = list(oddCommand.values())
        lstDescribe = list(oddCommand.keys())

        if s.GotoFolder(strBaseFolder):
            for i in range(len(lstDescribe)):
                try:
                    if _get_trace_file(lstCommand[i], lstDescribe[i]):
                        continue
                    else:
                        break
                except Exception as E:
                    # s.ShowErr(self.__class__.__name__,
                    #           sys._getframe().f_code.co_name,
                    #           'Get Trace "{}" Failed for Engine "{}",\
                    # Error:'.format(
                    #               lstDescribe[i], self._host),
                    #           E)
                    break
                time.sleep(0.1)
Пример #4
0
# from test import mkdir
# import os

# mkdir('abc')
# print(os.getcwd())

import Source as s
s.GotoFolder('wwd')