예제 #1
0
파일: sanity.py 프로젝트: maximerobin/Ufwi
def check_and_correct_lo(logger):
    """
    @type logger: logging.Logger
    @return: bool
    """
    try:
        ok, msg = check_if_up('lo')
    except IOError:
        return False

    if ok:
        return True
    logger.critical("%s - Bringing lo up..." % msg)
    process = createProcess(
        logger,
        '/sbin/ip l set lo up'.split(),
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
        env={}
        )
    retcode = waitProcess(logger, process, 120)

    try:
        re_ok, re_msg = check_if_up('lo')
    except IOError:
        #FIXME: if we go here, what happened ? Shouldn't we have the problem at the beginning of the function
        return False
    if re_ok:
        logger.info("Could bring lo up!")
        return True

    logger.critical("Could NOT bring lo up!")
    return False
예제 #2
0
    def createRepository(self, repository_directory, checkout_directory):
        process = createProcess(self, ["svnadmin", "create", repository_directory])
        result = waitProcess(self, process, 20)
        if result != 0:
            raise VersionningError("error creating repository %s" % repository_directory)

        self.client.checkout("file://%s" % repository_directory, checkout_directory)
예제 #3
0
파일: process.py 프로젝트: maximerobin/Ufwi
def runCommand(logger, command, timeout=DEFAULT_TIMEOUT, **popen_args):
    """
    use only if stdin/stdout/stderr are NOT pipes (instead use createProcess
    and communicateProcess)
    """
    process = createProcess(logger, command, **popen_args)
    status = waitProcess(logger, process, timeout)
    return (process, status)
예제 #4
0
 def apply(self):
     process = createProcess(self, self.arguments, stdout=PIPE, stderr=STDOUT)
     exitcode = waitProcess(self, process, TIMEOUT)
     if exitcode:
         lines = readProcessOutput(process.stdout, 100)
         lines = u'\n\n' + u'\n'.join(lines)
         raise RulesetError(tr("Ruleset script error (exitcode %s):%s"),
             exitcode, lines)
예제 #5
0
파일: openvpn.py 프로젝트: maximerobin/Ufwi
    def buildConfig(self):
        try:
            file(self.DH1024_FILE)
        except IOError:
            with open(os.path.devnull, 'wb') as devnull:
                self.info('Generating a new DH Parameter key.')
                process = createProcess(self, ['/usr/bin/openssl', 'dhparam',
                                               '-out', self.DH1024_FILE,
                                               '1024'],
                                              stdout=devnull,
                                              stderr=devnull)
                if waitProcess(self, process, 60.0 * 10) != 0:
                    raise OpenVPNError('Unable to generate a DH Parameter key.')

        return """daemon