fix: timedatectl not available in docker container
This commit is contained in:
parent
1f8377ba3c
commit
d4feb57631
|
@ -15,8 +15,16 @@ class TDTestCase:
|
|||
def run(self): # sourcery skip: extract-duplicate-method
|
||||
tdSql.prepare()
|
||||
# get system timezone
|
||||
time_zone = os.popen('timedatectl | grep zone').read(
|
||||
).strip().split(':')[1].lstrip()
|
||||
time_zone_arr = os.popen('timedatectl | grep zone').read(
|
||||
).strip().split(':')
|
||||
if len(time_zone_arr) > 1:
|
||||
time_zone = time_zone_arr[1].lstrip()
|
||||
else:
|
||||
# possibly in a docker container
|
||||
time_zone_1 = os.popen('ls -l /etc/localtime|awk -F/ \'{print $(NF-1) "/" $NF}\'').read().strip()
|
||||
time_zone_2 = os.popen('date "+(%Z, %z)"').read().strip()
|
||||
time_zone = time_zone_1 + " " + time_zone_2
|
||||
print("expected time zone: " + time_zone)
|
||||
|
||||
tdLog.printNoPrefix("==========step1:create tables==========")
|
||||
tdSql.execute(
|
||||
|
|
Loading…
Reference in New Issue