Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
settingsd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
settingsd
Commits
3944bff0
Commit
3944bff0
authored
Nov 24, 2010
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed regexp for ntp servers, code for checks /etc/ntp.conf
parent
f3ea0489
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
fmod_ntp_config.py
plugins/functions/fmod_ntp_config.py
+20
-14
No files found.
plugins/functions/fmod_ntp_config.py
View file @
3944bff0
# -*- coding: utf-8 -*-
import
os
import
re
from
settingsd
import
config
...
...
@@ -23,10 +24,13 @@ class NtpConfig(service.FunctionObject) :
@service.functionMethod
(
NTP_METHODS_NAMESPACE
,
in_signature
=
"as"
)
def
setServers
(
self
,
servers_list
)
:
if
not
os
.
access
(
config
.
value
(
SERVICE_NAME
,
"ntp_config_file_path"
),
os
.
F_OK
)
:
open
(
config
.
value
(
SERVICE_NAME
,
"ntp_config_file_path"
),
"w"
)
.
close
()
ntp_config_file
=
open
(
config
.
value
(
SERVICE_NAME
,
"ntp_config_file_path"
),
"r+"
)
ntp_config_file_data
=
ntp_config_file
.
read
()
ntp_config_file_data
=
re
.
sub
(
r"
\n
server[\s\t]+[^\n]+"
,
""
,
ntp_config_file_data
)
ntp_config_file_data
=
re
.
sub
(
r"
(\n|\A)
server[\s\t]+[^\n]+"
,
""
,
ntp_config_file_data
)
for
servers_list_item
in
servers_list
:
ntp_config_file_data
+=
"server
%
s
\n
"
%
(
servers_list_item
)
...
...
@@ -40,19 +44,21 @@ class NtpConfig(service.FunctionObject) :
@service.functionMethod
(
NTP_METHODS_NAMESPACE
,
out_signature
=
"as"
)
def
servers
(
self
)
:
ntp_config_file
=
open
(
config
.
value
(
SERVICE_NAME
,
"ntp_config_file_path"
),
"r"
)
ntp_config_file_list
=
ntp_config_file
.
read
()
.
split
(
"
\n
"
)
try
:
ntp_config_file
.
close
()
except
:
pass
servers_list
=
[]
for
ntp_config_file_list_item
in
ntp_config_file_list
:
if
len
(
ntp_config_file_list_item
)
==
0
:
continue
if
re
.
match
(
r"^server[\s\t]+"
,
ntp_config_file_list_item
)
!=
None
:
servers_list
.
append
(
re
.
split
(
r"[\s\t]+"
,
ntp_config_file_list_item
)[
1
])
return
servers_list
if
os
.
access
(
config
.
value
(
SERVICE_NAME
,
"ntp_config_file_path"
),
os
.
F_OK
)
:
ntp_config_file
=
open
(
config
.
value
(
SERVICE_NAME
,
"ntp_config_file_path"
),
"r"
)
ntp_config_file_list
=
ntp_config_file
.
read
()
.
split
(
"
\n
"
)
try
:
ntp_config_file
.
close
()
except
:
pass
servers_list
=
[]
for
ntp_config_file_list_item
in
ntp_config_file_list
:
if
len
(
ntp_config_file_list_item
)
==
0
:
continue
if
re
.
match
(
r"^server[\s\t]+"
,
ntp_config_file_list_item
)
!=
None
:
servers_list
.
append
(
re
.
split
(
r"[\s\t]+"
,
ntp_config_file_list_item
)[
1
])
return
servers_list
return
[]
###
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment