File tree Expand file tree Collapse file tree 6 files changed +47
-24
lines changed
Expand file tree Collapse file tree 6 files changed +47
-24
lines changed Original file line number Diff line number Diff line change 22
33import pytest
44
5+ import salt .utils .platform
56from tests .support .case import ModuleCase
67
78
89def _check_systemctl ():
910 if not hasattr (_check_systemctl , "memo" ):
10- proc = subprocess .run (["localectl" ], capture_output = True , check = False )
11- _check_systemctl .memo = b"No such file or directory" in proc .stderr
11+ if not salt .utils .platform .is_linux ():
12+ _check_systemctl .memo = False
13+ else :
14+ proc = subprocess .run (["localectl" ], capture_output = True , check = False )
15+ _check_systemctl .memo = b"No such file or directory" in proc .stderr
1216 return _check_systemctl .memo
1317
1418
Original file line number Diff line number Diff line change 88
99import pytest
1010
11+ import salt .utils .platform
1112from tests .support .case import ModuleCase
1213
1314try :
2021
2122def _check_systemctl ():
2223 if not hasattr (_check_systemctl , "memo" ):
23- proc = subprocess .run (["timedatectl" ], capture_output = True , check = False )
24- _check_systemctl .memo = b"No such file or directory" in proc .stderr
24+ if not salt .utils .platform .is_linux ():
25+ _check_systemctl .memo = False
26+ else :
27+ proc = subprocess .run (["timedatectl" ], capture_output = True , check = False )
28+ _check_systemctl .memo = b"No such file or directory" in proc .stderr
2529 return _check_systemctl .memo
2630
2731
Original file line number Diff line number Diff line change 1717
1818def _check_systemctl ():
1919 if not hasattr (_check_systemctl , "memo" ):
20- proc = subprocess .run (["systemctl" ], capture_output = True , check = False )
21- _check_systemctl .memo = (
22- b"Failed to get D-Bus connection: No such file or directory" in proc .stderr
23- )
20+ if not salt .utils .platform .is_linux ():
21+ _check_systemctl .memo = False
22+ else :
23+ proc = subprocess .run (["systemctl" ], capture_output = True , check = False )
24+ _check_systemctl .memo = (
25+ b"Failed to get D-Bus connection: No such file or directory"
26+ in proc .stderr
27+ )
2428 return _check_systemctl .memo
2529
2630
Original file line number Diff line number Diff line change 2222
2323def check_hostnamectl ():
2424 if not hasattr (check_hostnamectl , "memo" ):
25- proc = subprocess .run (["hostnamectl" ], capture_output = True , check = False )
26- check_hostnamectl .memo = (
27- b"Failed to connect to bus: No such file or directory" in proc .stderr
28- or b"Failed to create bus connection: No such file or directory"
29- in proc .stderr
30- )
25+ if not salt .utils .platform .is_linux ():
26+ check_hostnamectl .memo = False
27+ else :
28+ proc = subprocess .run (["hostnamectl" ], capture_output = True , check = False )
29+ check_hostnamectl .memo = (
30+ b"Failed to connect to bus: No such file or directory" in proc .stderr
31+ or b"Failed to create bus connection: No such file or directory"
32+ in proc .stderr
33+ )
3134 return check_hostnamectl .memo
3235
3336
Original file line number Diff line number Diff line change 2424
2525def _check_systemctl ():
2626 if not hasattr (_check_systemctl , "memo" ):
27- proc = subprocess .run (["systemctl" ], capture_output = True , check = False )
28- _check_systemctl .memo = (
29- b"Failed to get D-Bus connection: No such file or directory" in proc .stderr
30- or b"Failed to connect to bus: No such file or directory" in proc .stderr
31- )
27+ if not salt .utils .platform .is_linux ():
28+ _check_systemctl .memo = False
29+ else :
30+ proc = subprocess .run (["systemctl" ], capture_output = True , check = False )
31+ _check_systemctl .memo = (
32+ b"Failed to get D-Bus connection: No such file or directory"
33+ in proc .stderr
34+ or b"Failed to connect to bus: No such file or directory" in proc .stderr
35+ )
3236 return _check_systemctl .memo
3337
3438
Original file line number Diff line number Diff line change 1919
2020def _check_systemctl ():
2121 if not hasattr (_check_systemctl , "memo" ):
22- proc = subprocess .run (["systemctl" ], capture_output = True , check = False )
23- _check_systemctl .memo = (
24- b"Failed to get D-Bus connection: No such file or directory" in proc .stderr
25- or b"Failed to connect to bus: No such file or directory" in proc .stderr
26- )
22+ if not salt .utils .platform .is_linux ():
23+ _check_systemctl .memo = False
24+ else :
25+ proc = subprocess .run (["systemctl" ], capture_output = True , check = False )
26+ _check_systemctl .memo = (
27+ b"Failed to get D-Bus connection: No such file or directory"
28+ in proc .stderr
29+ or b"Failed to connect to bus: No such file or directory" in proc .stderr
30+ )
2731 return _check_systemctl .memo
2832
2933
You can’t perform that action at this time.
0 commit comments