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
21ca55c0
Commit
21ca55c0
authored
Jan 27, 2011
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fmod_date_time uses PlainEditor
parent
d78fe289
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
35 deletions
+13
-35
fmod_date_time.py
plugins/functions/fmod_date_time.py
+13
-35
No files found.
plugins/functions/fmod_date_time.py
View file @
21ca55c0
...
...
@@ -14,6 +14,7 @@ from settingsd import shared
import
settingsd.tools
as
tools
import
settingsd.tools.process
import
settingsd.tools.editors
##### Private constants #####
...
...
@@ -56,44 +57,21 @@ class DateTime(service.FunctionObject) :
os
.
symlink
(
os
.
path
.
join
(
config
.
value
(
SERVICE_NAME
,
"zoneinfo_dir_path"
),
zone
),
config
.
value
(
SERVICE_NAME
,
"localtime_file_path"
))
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
os
.
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
(
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
)
clock_config_file
.
seek
(
0
)
clock_config_file
.
truncate
()
clock_config_file
.
write
(
clock_config_file_data
)
try
:
clock_config_file
.
close
()
except
:
pass
time_zone_editor
=
tools
.
editors
.
PlainEditor
(
spaces_list
=
[])
time_zone_editor
.
open
(
config
.
value
(
SERVICE_NAME
,
"clock_config_file_path"
),
config
.
value
(
SERVICE_NAME
,
"sample_clock_config_file_path"
))
time_zone_editor
.
setValue
(
"ZONE"
,
zone
)
time_zone_editor
.
save
()
time_zone_editor
.
close
()
@service.functionMethod
(
ZONE_METHODS_NAMESPACE
,
out_signature
=
"s"
)
def
timeZone
(
self
)
:
if
os
.
access
(
config
.
value
(
SERVICE_NAME
,
"clock_config_file_path"
),
os
.
F_OK
)
:
clock_config_file
=
open
(
config
.
value
(
SERVICE_NAME
,
"clock_config_file_path"
))
clock_config_file_data
=
clock_config_file
.
read
()
try
:
clock_config_file
.
close
()
except
:
pass
zone_match
=
re
.
search
(
r"(\A|\n)ZONE=[\"\']?([a-zA-Z0-9/]*)[\"\']?"
,
clock_config_file_data
)
if
zone_match
!=
None
:
return
os
.
path
.
normpath
(
zone_match
.
group
(
2
))
time_zone_editor
=
tools
.
editors
.
PlainEditor
(
spaces_list
=
[])
time_zone_editor
.
open
(
config
.
value
(
SERVICE_NAME
,
"clock_config_file_path"
))
zones_list
=
time_zone_editor
.
value
(
"ZONE"
)
if
len
(
zones_list
)
>
0
:
return
os
.
path
.
normpath
(
zones_list
[
-
1
])
try
:
zoneinfo_dir_path
=
os
.
path
.
normpath
(
os
.
readlink
(
config
.
value
(
SERVICE_NAME
,
"localtime_file_path"
)))
...
...
@@ -150,6 +128,6 @@ class Service(service.Service) :
(
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_sample
"
,
os
.
path
.
join
(
const
.
FUNCTIONS_DATA_DIR
,
SERVICE_NAME
,
"clock"
),
str
)
(
SERVICE_NAME
,
"
sample_clock_config_file_path
"
,
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