def update_gunicorns():
global tick<EOL>tick += <NUM_LIT:1><EOL>if (tick * screen_delay) % ps_delay != <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>tick = <NUM_LIT:0><EOL>for pid in gunicorns:<EOL><INDENT>gunicorns[pid].update({"<STR_LIT>": <NUM_LIT:0>, "<STR_LIT>": <NUM_LIT:0>})<EOL><DEDENT>ps = Popen(PS_ARGS, stdout=PIPE).communicate()[<NUM_LIT:0>].split("<STR_LIT:\n>")<EOL>headings = ps.pop(<NUM_LIT:0>).split()<EOL>name_col = headings.index(cmd_heading)<EOL>num_cols = len(headings) - <NUM_LIT:1><EOL>for row in ps:<EOL><INDENT>cols = row.split(None, num_cols)<EOL>if cols and "<STR_LIT>" in cols[name_col]:<EOL><INDENT>if "<STR_LIT>" in cols[name_col]:<EOL><INDENT>is_worker = True<EOL><DEDENT>else:<EOL><INDENT>is_worker = False<EOL><DEDENT>if is_worker:<EOL><INDENT>pid = cols[headings.index("<STR_LIT>")]<EOL><DEDENT>else:<EOL><INDENT>pid = cols[headings.index("<STR_LIT>")]<EOL><DEDENT>if pid not in gunicorns:<EOL><INDENT>gunicorns[pid] = {"<STR_LIT>": <NUM_LIT:0>, "<STR_LIT>": <NUM_LIT:0>, "<STR_LIT:port>": None, "<STR_LIT:name>":<EOL>cols[name_col].strip().split("<STR_LIT:[>",<NUM_LIT:1>)[<NUM_LIT:1>].split("<STR_LIT:]>",<NUM_LIT:1>)[:-<NUM_LIT:1>]}<EOL><DEDENT>gunicorns[pid]["<STR_LIT>"] += int(cols[headings.index("<STR_LIT>")])<EOL>if is_worker:<EOL><INDENT>gunicorns[pid]["<STR_LIT>"] += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>for pid in list(gunicorns.keys())[:]:<EOL><INDENT>if gunicorns[pid]["<STR_LIT>"] == <NUM_LIT:0>:<EOL><INDENT>del gunicorns[pid]<EOL><DEDENT><DEDENT>if not [g for g in list(gunicorns.values()) if g["<STR_LIT:port>"] is None]:<EOL><INDENT>return<EOL><DEDENT>for (pid, port) in ports_for_pids(list(gunicorns.keys())):<EOL><INDENT>if pid in gunicorns:<EOL><INDENT>gunicorns[pid]["<STR_LIT:port>"] = port<EOL><DEDENT><DEDENT>
Updates the dict of gunicorn processes. Run the ps command and parse its
output for processes named after gunicorn, building up a dict of gunicorn
processes. When new gunicorns are discovered, run the netstat command to
determine the ports they're serving on.