Skip to content
Snippets Groups Projects
Commit 04a11ccd authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Add get_caller_info function in rc_util

parent eb388e59
No related branches found
No related tags found
2 merge requests!147Merge previous default branch feat-cod-rmq into main,!127Add updated_by field to user_state table
...@@ -5,6 +5,7 @@ import signal ...@@ -5,6 +5,7 @@ import signal
import logging import logging
import argparse import argparse
import pika import pika
import pwd
import uuid import uuid
from rc_rmq import RCRMQ from rc_rmq import RCRMQ
import json import json
...@@ -63,6 +64,7 @@ def add_account(username, queuename, email, full="", reason=""): ...@@ -63,6 +64,7 @@ def add_account(username, queuename, email, full="", reason=""):
) )
rc_rmq.disconnect() rc_rmq.disconnect()
def certify_account(username, queuename, state="ok", service="all"): def certify_account(username, queuename, state="ok", service="all"):
rc_rmq.publish_msg( rc_rmq.publish_msg(
{ {
...@@ -77,6 +79,7 @@ def certify_account(username, queuename, state="ok", service="all"): ...@@ -77,6 +79,7 @@ def certify_account(username, queuename, state="ok", service="all"):
) )
rc_rmq.disconnect() rc_rmq.disconnect()
def worker(ch, method, properties, body): def worker(ch, method, properties, body):
msg = json.loads(body) msg = json.loads(body)
username = msg["username"] username = msg["username"]
...@@ -260,3 +263,7 @@ def update_state(username, state, debug=False): ...@@ -260,3 +263,7 @@ def update_state(username, state, debug=False):
) )
return result return result
def get_caller_info():
return f"{pwd.getpwuid(os.getuid()).pw_name}@{os.uname().nodename}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment