コード例 #1
0
ファイル: spawn.py プロジェクト: kant/4bars
    def local_run_long_until_success(name, cmd):
        attempt = 1
        while attempt < 101:
            try:
                if attempt > 1:
                    Static.msg("RETRYING", "VALIDATE in 15s")
                    time.sleep(15)

                Cmd.local_run_long(name, cmd)
                return
            except:
                attempt += 1
コード例 #2
0
ファイル: spawn.py プロジェクト: kant/4bars
    def local_run_get_out_raw(name, cmd):
        proc1 = subprocess.Popen(cmd,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 shell=True,
                                 preexec_fn=os.setsid)
        out = proc1.communicate()

        if proc1.returncode != 0:
            Static.msg_bold("FAIL", name.upper())
            sys.stdout.write(out[1])
            raise SystemExit(32)

        return out[0]
コード例 #3
0
ファイル: spawn.py プロジェクト: kant/4bars
    def local_run_long(name, cmd):
        proc1 = subprocess.Popen(cmd,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 shell=True,
                                 preexec_fn=os.setsid)

        while proc1.returncode is None:
            for line in proc1.stdout:
                sys.stdout.write(line)
            proc1.poll()

        if proc1.returncode != 0:
            Static.msg_bold("FAIL", name.upper())
            for line in iter(proc1.stderr.readline, ''):
                sys.stdout.write(line)
            raise SystemExit(32)
コード例 #4
0
ファイル: spawn.py プロジェクト: kant/4bars
    def local_run_realtime_continue_on_fail(name, cmd):
        proc1 = subprocess.Popen(cmd,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 shell=True)

        # Poll process for new output until finished
        while True:
            nextline = proc1.stdout.readline()
            if nextline == '' and proc1.poll() is not None:
                break
            sys.stdout.write(nextline)
            sys.stdout.flush()

        output = proc1.communicate()
        if proc1.returncode != 0:
            Static.msg_bold("FAIL {0}".format(name.upper()), output[1])
コード例 #5
0
ファイル: spawn.py プロジェクト: kant/4bars
    def local_run_long_until_ready(name, cmd):
        result = False
        while not result:
            proc1 = subprocess.Popen(cmd,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE,
                                     shell=True,
                                     preexec_fn=os.setsid)
            proc1.wait()

            for line in iter(proc1.stdout.readline, ''):
                if not "ready: true" in line:
                    Static.msg("Waiting for", name.upper())
                    time.sleep(10)
                    continue

            Static.msg("Success for", name.upper())
            return
コード例 #6
0
ファイル: spawn.py プロジェクト: kant/4bars
    def local_sudo_prompt_run(name, cmd):
        password = None
        if not os.geteuid() == 0:
            print()
            print("You must be root to run this command.")
            print()
            password = getpass.getpass()
            print()

        #proc1 = subprocess.Popen(['sudo', '-p', '-k', '-S', cmd], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        proc1 = subprocess.Popen('/usr/bin/sudo -p -k -S {0}'.format(cmd),
                                 shell=True,
                                 stdin=subprocess.PIPE,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
        out = proc1.communicate(input='{0}\n'.format(password))

        if proc1.returncode != 0:
            Static.msg_bold(
                "Password failed most likely. Possibly some other error. Inspect below.",
                name.upper())
            print(out)
            raise SystemExit(32)