Ejemplo n.º 1
0
 def setUp(self):
     """
     environment setup
     :return:
     """
     #build && start tablet
     FileUtils.mkdir(util.get('RUNENV_DIR'))
     FileUtils.rm(util.get('RTIDB_LOG'))
     for cmd in [
             'CMD_BUILD', 'CMD_BUILD_JAVA_CLIENT',
             'CMD_BUILD_PYTHON_CLIENT', 'CMD_TABLE_STOP', 'CMD_TABLE_START'
     ]:
         log.info(cmd)
         cmd = util.get(cmd)
         proc = Process()
         proc.run(cmd)
Ejemplo n.º 2
0
    def run(self, failonerror=True, autoidentity=True, logcheck=True):
        """

        :return:
        """
        retStatus = True
        for idx, (taskFunc, taskParam) in enumerate(self.taskList):
            try:
                ret = taskFunc(**taskParam)
                msg = 'Func=%s, Param=%s, ret=%s' % (str(taskFunc),
                                                     str(taskParam), str(ret))
                log.info(msg[:1000])
                # ret = False if 0 == ret else True if 1 == ret else ret
            except Exception as e:
                msg = 'Task start fail, ' \
                  'message=%s, ' \
                  'args=%s, ' \
                  'param=%s' % (e.message, str(e.args), str(taskParam))
                log.info(msg)
                if failonerror:
                    raise Exception(msg)
                else:
                    retStatus = False
            if self.rtidbClient.scan == taskFunc:
                self._scan_parser(ret)
            else:
                if not ret:
                    if failonerror:
                        raise Exception('%s run error:%s' %
                                        (str(taskFunc), str(taskParam)))
                    else:
                        retStatus = False
        # common check
        self._common_check(autoidentity, retStatus, logcheck)

        # save log file
        logfile = util.get('RTIDB_LOG')
        logfileBackup = logfile + '.' + util.inspect_get(
            self.stack, 'function')
        FileUtils.cp(logfile, logfileBackup)

        return retStatus
Ejemplo n.º 3
0
def start_tablet_server(workDir):
    """

    :param workDir:
    :return:
    """
    binDir = get('BIN_DIR')
    logfile = os.path.join(workDir, 'run.log')
    cmd = 'cd %(binDir)s && ./rtidb --role=tablet >%(logfile)s 2>&1 &' % locals()
    p = Process()
    data, error, retCode = p.run(cmd)
    if 0 != retCode:
        raise Exception('Start tablet server error: %s' % FileUtils.read(logfile))
Ejemplo n.º 4
0
 def _parse(dataFile, dataJunkFunc):
     if dataJunkFunc is not None:
         return dataJunkFunc(dataFile)
     else:
         return FileUtils.read(dataFile)
Ejemplo n.º 5
0
 def predict(sourceFile):
     sourceMap = FileUtils.read2(sourceFile)
     sourceMap = filter(lambda x: x.strip() != '', sourceMap)
     sourceMap = [f.split(' ') for f in sourceMap]
     return sourceMap
Ejemplo n.º 6
0
 def yaml(sourceFile):
     return yaml.load(FileUtils.read(sourceFile))