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
c9dea185
Commit
c9dea185
authored
Dec 17, 2010
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added loading default configs for date/time
parent
22a93319
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
fmod_date_time.py
plugins/functions/fmod_date_time.py
+19
-4
No files found.
plugins/functions/fmod_date_time.py
View file @
c9dea185
...
...
@@ -5,12 +5,15 @@ import os
import
time
import
re
import
hashlib
import
shutil
from
settingsd
import
const
from
settingsd
import
config
from
settingsd
import
service
from
settingsd
import
shared
from
settingsd
import
tools
##### Private constants #####
SERVICE_NAME
=
"date_time"
...
...
@@ -51,10 +54,20 @@ class DateTime(service.FunctionObject) :
os
.
symlink
(
os
.
path
.
join
(
config
.
value
(
SERVICE_NAME
,
"zoneinfo_dir_path"
),
zone
),
config
.
value
(
SERVICE_NAME
,
"localtime_file_path"
))
if
not
os
.
access
(
config
.
value
(
SERVICE_NAME
,
"clock_config_file_path"
),
os
.
F_OK
)
:
open
(
config
.
value
(
SERVICE_NAME
,
"clock_config_file_path"
),
"w"
)
.
close
()
clock_config_file_path
=
config
.
value
(
SERVICE_NAME
,
"clock_config_file_path"
)
###
clock_config_file_path_sample
=
config_value
(
SERVICE_NAME
,
"clock_config_file_path_sample"
)
if
not
os
.
access
(
clock_config_file_path
,
os
.
F_OK
)
:
if
access
(
clock_config_file_path_sample
,
os
.
F_OK
)
:
shutil
.
copy2
(
clock_config_file_path_sample
,
clock_config_file_path
)
else
:
open
(
clock_config_file_path
,
"w"
)
.
close
()
clock_config_file
=
open
(
config
.
value
(
SERVICE_NAME
,
"clock_config_file_path"
),
"r+"
)
###
clock_config_file
=
open
(
clock_config_file_path
,
"r+"
)
clock_config_file_data
=
clock_config_file
.
read
()
clock_config_file_data
=
re
.
sub
(
r"(\A|\n)ZONE=[\"\']?[a-zA-Z0-9/]*[\"\']?"
,
"
\n
ZONE=
\"
%
s
\"
"
%
(
zone
),
clock_config_file_data
)
...
...
@@ -133,6 +146,8 @@ class Service(service.Service) :
(
SERVICE_NAME
,
"hwclock_prog_path"
,
"/usr/sbin/hwclock"
,
str
),
(
SERVICE_NAME
,
"localtime_file_path"
,
"/etc/localtime"
,
str
),
(
SERVICE_NAME
,
"zoneinfo_dir_path"
,
"/usr/share/zoneinfo"
,
str
),
(
SERVICE_NAME
,
"clock_config_file_path"
,
"/etc/sysconfig/clock"
,
str
)
(
SERVICE_NAME
,
"clock_config_file_path"
,
"/etc/sysconfig/clock"
,
str
),
(
SERVICE_NAME
,
"clock_config_file_path_sample"
,
os
.
path
.
join
(
const
.
FUNCTIONS_DATA_DIR
,
SERVICE_NAME
,
"clock"
),
str
)
]
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