def statProc(pid, Q):

    # Get the fix point of a function f
    def fix(f, x):
        r = f(x)
        if x == r:
            return r
        return fix(f, r)

    # Collect stats using top from the processing running
    # inferencing and the display process
    while True:
        try:
            p = proc(["top", "-p", pid[0], "-b", "-n", "1"], stdout=PIPE)
            out, _ = p.communicate()
            lines = out.decode().split('\n')
            lines = list(filter(lambda x: len(x) > 0, lines))

            s = lines[-1]
            s = s.replace('\t', ' ')
            s = fix(lambda x: x.replace('  ', ' '), s)
            s = s.split(' ')
            if '%' in s[-4]:
                break
            #print(s[-4])
            Q.put(s[-4])

            p = proc(["top", "-p", pid[1], "-b", "-n", "1"], stdout=PIPE)
            out, _ = p.communicate()
            lines = out.decode().split('\n')
            lines = list(filter(lambda x: len(x) > 0, lines))

            s = lines[-1]
            s = s.replace('\t', ' ')
            s = fix(lambda x: x.replace('  ', ' '), s)
            s = s.split(' ')
            if '%' in s[-4]:
                break
            #print(s[-4])
            Q.put(s[-4])
        except:
            pass
    Q.put(None)
def statProc(pid, Q):

    # Get the fix point of a function f
    def fix(f, x):
        r = f(x)
        if x == r:
            return r
        return fix(f, r)

    # Collect stats using top from the processing running
    # inferencing and the display process
    while True:
        try:
            p = proc(["top", "-p", pid[0], "-b", "-n", "1"], stdout=PIPE)
            out, _ = p.communicate()
            lines = out.decode().split('\n')
            lines = list(filter(lambda x:len(x)>0, lines))
       
            s = lines[-1] 
            s = s.replace('\t', ' ')
            s = fix(lambda x:x.replace('  ', ' '), s)
            s = s.split(' ')
            if '%' in s[-4]:
              break
            #print(s[-4])
            Q.put(s[-4])

            p = proc(["top", "-p", pid[1], "-b", "-n", "1"], stdout=PIPE)
            out, _ = p.communicate()
            lines = out.decode().split('\n')
            lines = list(filter(lambda x:len(x)>0, lines))
       
            s = lines[-1] 
            s = s.replace('\t', ' ')
            s = fix(lambda x:x.replace('  ', ' '), s)
            s = s.split(' ')
            if '%' in s[-4]:
              break
            #print(s[-4])
            Q.put(s[-4])
        except:
            pass
    Q.put(None)
Beispiel #3
0
def process(name):
    with open("docs/" + name + ".yaml") as f:
        dmap = yaml.safe_load(f)
        tex = create_tex(dmap["metadata"], dmap["projects"])
        if not tex:
            return
        with open("tmp/" + name + ".tex", "w") as f2:
            f2.write(tex)
        os.chdir("tmp")
        proc(["pdflatex", name + ".tex"]).wait()
        proc(["pdflatex", name + ".tex"]).wait()
        proc(["mv", name + ".pdf", "../out"]).wait()
        os.chdir("..")
        print("Processing " + name + " complete")