customversion: make script less likely to error in systemd services

This commit is contained in:
ave 2019-01-23 02:13:22 +03:00
parent 9fd72d479e
commit 3f97a21677
No known key found for this signature in database
GPG key ID: 09356ABAA42C842B

View file

@ -1,6 +1,6 @@
#!/bin/env python3 #!/bin/env python3
import sys import sys
import os import getpass
import datetime import datetime
import socket import socket
@ -18,8 +18,15 @@ customtext = customtext.strip(",")
timestamp = str(datetime.datetime.utcnow()).split('.')[0] + " UTC" timestamp = str(datetime.datetime.utcnow()).split('.')[0] + " UTC"
customtext += ", built on {}@{} at {}".format(os.getlogin(), try:
socket.gethostname(), uname = getpass.getuser()
except:
uname = "unknown"
hostname = socket.gethostname().split(".")[0]
customtext += ", built on {}@{} at {}".format(uname,
hostname,
timestamp) timestamp)
# Replace the target string # Replace the target string