Optimize Build user when displaying fe or be version (#5437)

This commit is contained in:
wangruin 2022-04-24 13:14:05 +08:00 committed by GitHub
parent 3954f1f2b3
commit 01b0e45b01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -37,9 +37,14 @@ def get_current_time():
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
def get_user():
return os.getenv("USER")
user = os.getenv("USER")
if not user:
user = "StarRocks"
return user
def get_hostname():
if os.path.exists('/.dockerenv'):
return "docker"
res = subprocess.Popen(["hostname", "-f"], stdout=subprocess.PIPE)
out, err = res.communicate()
return out.decode('utf-8').strip()