Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions tavern/tomes/process_list/main.eldritch
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
def pad_pid(pid):
pid_column_width = 16
padding = pid_column_width - len(pid)
return pid + " "*padding

def pad_username (username):
username_column_width = 32
padding = username_column_width - len(username)
return username + " "*padding

def process_list(cmd_substring):

if cmd_substring == '*':
cmd_substring = ''

procs = process.list()
print("PID,PPID,username,command\n")

print(pad_pid("PID"))
print(pad_pid("PPID"))
print(pad_username("username"))
print("command\n")

for proc in procs:
if cmd_substring in proc['command']:
tmp_command = proc['command']
if tmp_command == "":
tmp_command = proc['name']
print(str(proc['pid'])+", "+str(proc['ppid'])+", "+proc['username']+", "+tmp_command+"\n")
current_proc_command = proc['command']
if current_proc_command == "":
current_proc_command = proc['name']

current_proc_pid = str(proc['pid'])
current_proc_ppid = str(proc['ppid'])
current_proc_username = proc['username']

print(pad_pid(current_proc_pid))
print(pad_pid(current_proc_ppid))
print(pad_username(current_proc_username))
print(current_proc_command.replace("\n","\\n")+"\n")

process_list(input_params['cmd_substring'])
print("\n")
Expand Down