Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply selected suggestions courtesy of darker (from black) #36

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions XSConsoleData.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,20 @@ def UpdateFromNTPConf(self):

self.data['ntp']['method'] = ""
chronyPerm = os.stat("/etc/dhcp/dhclient.d/chrony.sh").st_mode
if chronyPerm & stat.S_IXUSR and chronyPerm & stat.S_IXGRP and chronyPerm & stat.S_IXOTH:
if (
chronyPerm & stat.S_IXUSR
and chronyPerm & stat.S_IXGRP
and chronyPerm & stat.S_IXOTH
):
self.data['ntp']['method'] = "DHCP"
elif self.data['ntp']['servers']:
self.data['ntp']['method'] = "Manual"

servers = self.data['ntp']['servers']
if len(servers) == 4 and all("centos.pool.ntp.org" in server for server in self.data['ntp']['servers']):
if len(servers) == 4 and all(
"centos.pool.ntp.org" in server
for server in self.data['ntp']['servers']
):
self.data['ntp']['method'] = "Default"
else:
self.data['ntp']['method'] = "Disabled"
Expand Down Expand Up @@ -547,10 +554,10 @@ def SaveToNTPConf(self):

try:
with open("/etc/chrony.conf", "w") as confFile:
for other in self.ntp.othercontents([]):
confFile.write(other + "\n")
for server in self.ntp.servers([]):
confFile.write("server " + server + " iburst\n")
for other in self.ntp.othercontents([]):
confFile.write(other + "\n")
for server in self.ntp.servers([]):
confFile.write("server " + server + " iburst\n")
finally:
self.UpdateFromNTPConf()

Expand Down Expand Up @@ -585,15 +592,19 @@ def ResetDefaultNTPServers(self):
# Double-check authentication
Auth.Inst().AssertAuthenticated()

Data.Inst().NTPServersSet(["0.centos.pool.ntp.org",
"1.centos.pool.ntp.org",
"2.centos.pool.ntp.org",
"3.centos.pool.ntp.org"])
Data.Inst().NTPServersSet(
[
"0.centos.pool.ntp.org",
"1.centos.pool.ntp.org",
"2.centos.pool.ntp.org",
"3.centos.pool.ntp.org",
]
)

def GetDHClientInterfaces(self):
(status, output) = getstatusoutput("ls /var/lib/xcp/ | grep leases")
if status != 0:
return []
return []

dhclientFiles = output.splitlines()
pattern = "dhclient-(.*).leases"
Expand Down
Loading