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
5cb67506
Commit
5cb67506
authored
Jan 19, 2011
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using new version validators and tools
parent
3eb713fb
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
64 additions
and
45 deletions
+64
-45
fmod_common_info.py
plugins/functions/fmod_common_info.py
+5
-3
fmod_date_time.py
plugins/functions/fmod_date_time.py
+5
-3
fmod_disks_smart.py
plugins/functions/fmod_disks_smart.py
+9
-7
fmod_dnsmasq_config.py
plugins/functions/fmod_dnsmasq_config.py
+3
-1
fmod_machine.py
plugins/functions/fmod_machine.py
+15
-11
fmod_ntp_config.py
plugins/functions/fmod_ntp_config.py
+3
-2
fmod_rtorrentd_config.py
plugins/functions/fmod_rtorrentd_config.py
+0
-1
fmod_settingsd.py
plugins/functions/fmod_settingsd.py
+6
-4
fmod_statistics.py
plugins/functions/fmod_statistics.py
+6
-4
fmod_system_services.py
plugins/functions/fmod_system_services.py
+12
-9
No files found.
plugins/functions/fmod_common_info.py
View file @
5cb67506
...
...
@@ -5,7 +5,9 @@ from settingsd import config
from
settingsd
import
service
from
settingsd
import
shared
from
settingsd
import
logger
from
settingsd
import
tools
import
settingsd.tools
as
tools
import
settingsd.tools.process
##### Private constants #####
...
...
@@ -94,11 +96,11 @@ class CommonInfo(service.FunctionObject) :
def
lsbOption
(
self
,
option
)
:
proc_args
=
"
%
s
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"lsb_release_prog_path"
),
option
)
return
":"
.
join
(
tools
.
execProcess
(
proc_args
)[
0
]
.
split
(
":"
)[
1
:])
.
strip
()
return
":"
.
join
(
tools
.
process
.
execProcess
(
proc_args
)[
0
]
.
split
(
":"
)[
1
:])
.
strip
()
def
unameOption
(
self
,
option
)
:
proc_args
=
"
%
s
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"uname_prog_path"
),
option
)
return
tools
.
execProcess
(
proc_args
)[
0
]
.
strip
()
return
tools
.
process
.
execProcess
(
proc_args
)[
0
]
.
strip
()
##### Public classes #####
...
...
plugins/functions/fmod_date_time.py
View file @
5cb67506
...
...
@@ -11,7 +11,9 @@ from settingsd import const
from
settingsd
import
config
from
settingsd
import
service
from
settingsd
import
shared
from
settingsd
import
tools
import
settingsd.tools
as
tools
import
settingsd.tools.process
##### Private constants #####
...
...
@@ -36,7 +38,7 @@ class DateTime(service.FunctionObject) :
def
setUtcTime
(
self
,
month
,
monthday
,
hour
,
minute
,
year
,
second
)
:
proc_args
=
"
%
s -u
%02
d
%02
d
%02
d
%02
d
%04
d.
%02
d"
%
(
config
.
value
(
SERVICE_NAME
,
"date_prog_path"
),
month
,
monthday
,
hour
,
minute
,
year
,
second
)
return
tools
.
execProcess
(
proc_args
,
False
)[
2
]
return
tools
.
process
.
execProcess
(
proc_args
,
False
)[
2
]
@service.functionMethod
(
SYSTEM_CLOCK_METHODS_NAMESPACE
,
out_signature
=
"iiiiii"
)
def
utcTime
(
self
)
:
...
...
@@ -121,7 +123,7 @@ class DateTime(service.FunctionObject) :
@service.functionMethod
(
HARDWARE_CLOCK_METHODS_NAMESPACE
,
out_signature
=
"i"
)
def
syncWithSystem
(
self
)
:
return
tools
.
execProcess
(
"
%
s --systohc"
%
(
config
.
value
(
SERVICE_NAME
,
"hwclock_prog_path"
)),
False
)[
0
]
return
tools
.
process
.
execProcess
(
"
%
s --systohc"
%
(
config
.
value
(
SERVICE_NAME
,
"hwclock_prog_path"
)),
False
)[
0
]
##### Public classes #####
...
...
plugins/functions/fmod_disks_smart.py
View file @
5cb67506
...
...
@@ -9,10 +9,12 @@ import glib
from
settingsd
import
config
from
settingsd
import
service
from
settingsd
import
shared
from
settingsd
import
dbus_tools
from
settingsd
import
tools
from
settingsd
import
logger
import
settingsd.tools
as
tools
import
settingsd.tools.dbus
import
settingsd.tools.process
##### Private constants #####
SERVICE_NAME
=
"disks_smart"
...
...
@@ -40,7 +42,7 @@ class Disk(service.FunctionObject) :
attrs_list
=
[]
attrs_found_flag
=
False
for
attrs_list_item
in
tools
.
execProcess
(
proc_args
)[
0
]
.
split
(
"
\n
"
)
:
for
attrs_list_item
in
tools
.
process
.
execProcess
(
proc_args
)[
0
]
.
split
(
"
\n
"
)
:
attrs_list_item
=
attrs_list_item
.
strip
()
if
attrs_found_flag
:
...
...
@@ -67,7 +69,7 @@ class Disk(service.FunctionObject) :
disk_health_flag
=
False
health_found_flag
=
False
for
health_list_item
in
tools
.
execProcess
(
proc_args
)[
0
]
.
split
(
"
\n
"
)
:
for
health_list_item
in
tools
.
process
.
execProcess
(
proc_args
)[
0
]
.
split
(
"
\n
"
)
:
health_list_item
=
health_list_item
.
strip
()
if
health_found_flag
:
...
...
@@ -112,7 +114,7 @@ class Service(service.Service) :
device_file_path
=
device
.
get_device_file
()
if
disks_filter_regexp
.
match
(
device_name
)
and
self
.
smartAvailable
(
device_file_path
)
:
disks_smart_shared
.
addSharedObject
(
device_name
,
Disk
(
device_file_path
,
dbus_tool
s
.
joinPath
(
DISKS_SMART_SHARED_NAME
,
device_name
),
self
))
tools
.
dbu
s
.
joinPath
(
DISKS_SMART_SHARED_NAME
,
device_name
),
self
))
devices_count
+=
1
logger
.
verbose
(
"{mod}: Added
%
d devices"
%
(
devices_count
))
...
...
@@ -141,7 +143,7 @@ class Service(service.Service) :
def
smartAvailable
(
self
,
device_file_path
)
:
proc_args
=
"
%
s
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"smartctl_prog_path"
),
device_file_path
)
return
not
bool
(
tools
.
execProcess
(
proc_args
,
False
)[
2
])
return
not
bool
(
tools
.
process
.
execProcess
(
proc_args
,
False
)[
2
])
###
...
...
@@ -155,7 +157,7 @@ class Service(service.Service) :
if
action
==
"add"
and
not
device
in
registered_devices_list
and
self
.
smartAvailable
(
device_file_path
)
:
disks_smart_shared
.
addSharedObject
(
device_name
,
Disk
(
device_file_path
,
dbus_tool
s
.
joinPath
(
DISKS_SMART_SHARED_NAME
,
device_name
),
self
))
tools
.
dbu
s
.
joinPath
(
DISKS_SMART_SHARED_NAME
,
device_name
),
self
))
self
.
__disks_smart
.
devicesChanged
()
logger
.
debug
(
"{mod}: Added SMART disk
\"
%
s
\"
"
%
(
device_file_path
))
...
...
plugins/functions/fmod_dnsmasq_config.py
View file @
5cb67506
...
...
@@ -11,7 +11,9 @@ from settingsd import config
from
settingsd
import
service
from
settingsd
import
shared
from
settingsd
import
logger
from
settingsd
import
validators
import
settingsd.validators
as
validators
import
settingsd.validators.network
##### Private constants #####
...
...
plugins/functions/fmod_machine.py
View file @
5cb67506
...
...
@@ -5,8 +5,12 @@ from settingsd import config
from
settingsd
import
service
from
settingsd
import
shared
from
settingsd
import
logger
from
settingsd
import
tools
from
settingsd
import
validators
import
settingsd.tools
as
tools
import
settingsd.tools.process
import
settingsd.validators
as
validators
import
settingsd.validators.common
##### Private constants #####
...
...
@@ -25,34 +29,34 @@ class Machine(service.FunctionObject) :
@service.functionMethod
(
POWER_METHODS_NAMESPACE
,
out_signature
=
"i"
)
def
shutdown
(
self
)
:
return
tools
.
execProcess
(
"
%
s -h now"
%
(
config
.
value
(
SERVICE_NAME
,
"shutdown_prog_path"
)),
False
)[
2
]
return
tools
.
process
.
execProcess
(
"
%
s -h now"
%
(
config
.
value
(
SERVICE_NAME
,
"shutdown_prog_path"
)),
False
)[
2
]
@service.functionMethod
(
POWER_METHODS_NAMESPACE
,
out_signature
=
"i"
)
def
reboot
(
self
)
:
return
tools
.
execProcess
(
"
%
s -r now"
%
(
config
.
value
(
SERVICE_NAME
,
"shutdown_prog_path"
)),
False
)[
2
]
return
tools
.
process
.
execProcess
(
"
%
s -r now"
%
(
config
.
value
(
SERVICE_NAME
,
"shutdown_prog_path"
)),
False
)[
2
]
@service.functionMethod
(
POWER_METHODS_NAMESPACE
,
out_signature
=
"i"
)
def
suspend
(
self
)
:
return
tools
.
execProcess
(
config
.
value
(
SERVICE_NAME
,
"pm_suspend_prog_path"
),
False
)[
2
]
return
tools
.
process
.
execProcess
(
config
.
value
(
SERVICE_NAME
,
"pm_suspend_prog_path"
),
False
)[
2
]
@service.functionMethod
(
POWER_METHODS_NAMESPACE
,
out_signature
=
"i"
)
def
hibernate
(
self
)
:
return
tools
.
execProcess
(
config
.
value
(
SERVICE_NAME
,
"pm_hibernate_prog_path"
),
False
)[
2
]
return
tools
.
process
.
execProcess
(
config
.
value
(
SERVICE_NAME
,
"pm_hibernate_prog_path"
),
False
)[
2
]
###
@service.functionMethod
(
RUNLEVELS_METHODS_NAMESPACE
,
in_signature
=
"i"
,
out_signature
=
"i"
)
def
switchTo
(
self
,
level
)
:
proc_args
=
"
%
s
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"telinit_prog_path"
),
validators
.
common
.
validRange
(
str
(
level
),
RUNLEVELS
))
return
tools
.
execProcess
(
proc_args
,
False
)[
2
]
return
tools
.
process
.
execProcess
(
proc_args
,
False
)[
2
]
@service.functionMethod
(
RUNLEVELS_METHODS_NAMESPACE
,
out_signature
=
"i"
)
def
currentLevel
(
self
)
:
proc_args
=
config
.
value
(
SERVICE_NAME
,
"runlevel_prog_path"
)
level_pairs_list
=
tools
.
execProcess
(
proc_args
)[
0
]
.
strip
()
.
split
(
" "
)
level_pairs_list
=
tools
.
process
.
execProcess
(
proc_args
)[
0
]
.
strip
()
.
split
(
" "
)
if
len
(
level_pairs_list
)
!=
2
or
not
level_pairs_list
[
1
]
in
RUNLEVELS
:
raise
tools
.
SubprocessFailure
(
"Error while execute
\"
%
s
\"\n
Stdout:
%
s
\n
Stderr:
%
s
\n
Return code:
%
d"
%
(
raise
tools
.
process
.
SubprocessFailure
(
"Error while execute
\"
%
s
\"\n
Stdout:
%
s
\n
Stderr:
%
s
\n
Return code:
%
d"
%
(
proc_args
,
proc_stdout
.
strip
(),
proc_stderr
.
strip
(),
proc_returncode
))
return
int
(
level_pairs_list
[
1
])
...
...
@@ -61,9 +65,9 @@ class Machine(service.FunctionObject) :
def
previousLevel
(
self
)
:
proc_args
=
config
.
value
(
SERVICE_NAME
,
"runlevel_prog_path"
)
level_pairs_list
=
tools
.
execProcess
(
proc_args
)[
0
]
.
strip
()
.
split
(
" "
)
level_pairs_list
=
tools
.
process
.
execProcess
(
proc_args
)[
0
]
.
strip
()
.
split
(
" "
)
if
len
(
level_pairs_list
)
!=
2
or
not
level_pairs_list
[
1
]
in
RUNLEVELS
+
"N"
:
raise
tools
.
SubprocessFailure
(
"Error while execute
\"
%
s
\"\n
Stdout:
%
s
\n
Stderr:
%
s
\n
Return code:
%
d"
%
(
raise
tools
.
process
.
SubprocessFailure
(
"Error while execute
\"
%
s
\"\n
Stdout:
%
s
\n
Stderr:
%
s
\n
Return code:
%
d"
%
(
proc_args
,
proc_stdout
.
strip
(),
proc_stderr
.
strip
(),
proc_returncode
))
return
(
int
(
level_pairs_list
[
0
])
if
level_pairs_list
[
0
]
in
RUNLEVELS
else
-
1
)
...
...
plugins/functions/fmod_ntp_config.py
View file @
5cb67506
...
...
@@ -10,8 +10,9 @@ from settingsd import config
from
settingsd
import
service
from
settingsd
import
shared
from
settingsd
import
logger
from
settingsd
import
tools
import
settingsd.tools
as
tools
import
settingsd.tools.process
##### Private constants #####
SERVICE_NAME
=
"ntp_config"
...
...
@@ -37,7 +38,7 @@ class NtpConfig(service.FunctionObject) :
@service.functionMethod
(
NTP_METHODS_NAMESPACE
)
def
request
(
self
)
:
proc_args
=
"
%
s
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"ntpdate_prog_path"
),
" "
.
join
(
self
.
servers
()))
tools
.
execProcess
(
proc_args
)
tools
.
process
.
execProcess
(
proc_args
)
### Private ###
...
...
plugins/functions/fmod_rtorrentd_config.py
View file @
5cb67506
...
...
@@ -9,7 +9,6 @@ from settingsd import const
from
settingsd
import
config
from
settingsd
import
service
from
settingsd
import
shared
from
settingsd
import
tools
##### Private constants #####
...
...
plugins/functions/fmod_settingsd.py
View file @
5cb67506
...
...
@@ -5,13 +5,15 @@ from settingsd import const
from
settingsd
import
config
from
settingsd
import
service
from
settingsd
import
shared
from
settingsd
import
dbus_tools
import
settingsd.tools
as
tools
import
settingsd.tools.dbus
##### Private constants #####
SETTINGSD_METHODS_NAMESPACE
=
dbus_tool
s
.
joinMethod
(
const
.
DEFAULT_SERVICE_NAME
,
"commonInfo.settingsd"
)
LOGGER_METHODS_NAMESPACE
=
dbus_tool
s
.
joinMethod
(
const
.
DEFAULT_SERVICE_NAME
,
"logger"
)
APPLICATION_METHODS_NAMESPACE
=
dbus_tool
s
.
joinMethod
(
const
.
DEFAULT_SERVICE_NAME
,
"application"
)
SETTINGSD_METHODS_NAMESPACE
=
tools
.
dbu
s
.
joinMethod
(
const
.
DEFAULT_SERVICE_NAME
,
"commonInfo.settingsd"
)
LOGGER_METHODS_NAMESPACE
=
tools
.
dbu
s
.
joinMethod
(
const
.
DEFAULT_SERVICE_NAME
,
"logger"
)
APPLICATION_METHODS_NAMESPACE
=
tools
.
dbu
s
.
joinMethod
(
const
.
DEFAULT_SERVICE_NAME
,
"application"
)
##### Private classes #####
...
...
plugins/functions/fmod_statistics.py
View file @
5cb67506
...
...
@@ -5,7 +5,9 @@ import re
from
settingsd
import
service
from
settingsd
import
shared
from
settingsd
import
dbus_tools
import
settingsd.tools
as
tools
import
settingsd.tools.dbus
##### Private constants #####
...
...
@@ -212,7 +214,7 @@ class Service(service.Service) :
###
shared
.
Functions
.
shared
(
STATISTICS_SHARED_NAME
)
.
addSharedObject
(
MEMORY_OBJECT_NAME
,
Memory
(
dbus_tool
s
.
joinPath
(
STATISTICS_SHARED_NAME
,
MEMORY_OBJECT_NAME
),
self
))
Memory
(
tools
.
dbu
s
.
joinPath
(
STATISTICS_SHARED_NAME
,
MEMORY_OBJECT_NAME
),
self
))
###
...
...
@@ -225,10 +227,10 @@ class Service(service.Service) :
except
:
pass
shared
.
Functions
.
shared
(
STATISTICS_SHARED_NAME
)
.
addSharedObject
(
CPU_OBJECT_NAME
,
Cpu
(
CPU_OBJECT_NAME
,
dbus_tool
s
.
joinPath
(
STATISTICS_SHARED_NAME
,
CPU_OBJECT_NAME
),
self
))
Cpu
(
CPU_OBJECT_NAME
,
tools
.
dbu
s
.
joinPath
(
STATISTICS_SHARED_NAME
,
CPU_OBJECT_NAME
),
self
))
for
cpu_names_list_item
in
cpu_names_list
:
shared
.
Functions
.
shared
(
STATISTICS_SHARED_NAME
)
.
shared
(
CPU_SHARED_NAME
)
.
addSharedObject
(
cpu_names_list_item
,
Cpu
(
cpu_names_list_item
,
dbus_tool
s
.
joinPath
(
STATISTICS_SHARED_NAME
,
CPU_SHARED_NAME
,
cpu_names_list_item
),
self
))
Cpu
(
cpu_names_list_item
,
tools
.
dbu
s
.
joinPath
(
STATISTICS_SHARED_NAME
,
CPU_SHARED_NAME
,
cpu_names_list_item
),
self
))
###
...
...
plugins/functions/fmod_system_services.py
View file @
5cb67506
...
...
@@ -9,11 +9,14 @@ import pyinotify
from
settingsd
import
config
from
settingsd
import
service
from
settingsd
import
shared
from
settingsd
import
dbus_tools
from
settingsd
import
logger
from
settingsd
import
tools
from
settingsd
import
validators
import
settingsd.tools
as
tools
import
settingsd.tools.dbus
import
settingsd.tools.process
##### Private constants #####
SERVICE_NAME
=
"system_services"
...
...
@@ -49,7 +52,7 @@ class SystemService(service.FunctionObject) :
@service.functionMethod
(
SYSTEM_SERVICE_METHODS_NAMESPACE
,
out_signature
=
"s"
)
def
levelsMap
(
self
)
:
proc_args
=
"
%
s --list
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"chkconfig_prog_path"
),
self
.
__system_service_name
)
(
proc_stdout
,
proc_stderr
,
proc_returncode
)
=
tools
.
execProcess
(
proc_args
)
(
proc_stdout
,
proc_stderr
,
proc_returncode
)
=
tools
.
process
.
execProcess
(
proc_args
)
service_record_list
=
re
.
split
(
r"\s+"
,
proc_stdout
.
split
(
"
\n
"
)[
0
])
levels_list
=
[
"0"
]
*
(
len
(
service_record_list
)
-
1
)
...
...
@@ -74,18 +77,18 @@ class SystemService(service.FunctionObject) :
@service.functionMethod
(
SYSTEM_SERVICE_METHODS_NAMESPACE
,
out_signature
=
"i"
)
def
start
(
self
)
:
logger
.
verbose
(
"{mod}: Request to start service
\"
%
s
\"
"
%
(
self
.
__system_service_name
))
return
tools
.
execProcess
(
"
%
s start"
%
(
os
.
path
.
join
(
config
.
value
(
SERVICE_NAME
,
"initd_dir_path"
),
return
tools
.
process
.
execProcess
(
"
%
s start"
%
(
os
.
path
.
join
(
config
.
value
(
SERVICE_NAME
,
"initd_dir_path"
),
self
.
__system_service_name
)
),
False
)[
2
]
@service.functionMethod
(
SYSTEM_SERVICE_METHODS_NAMESPACE
,
out_signature
=
"i"
)
def
stop
(
self
)
:
logger
.
verbose
(
"{mod}: Request to stop service
\"
%
s
\"
"
%
(
self
.
__system_service_name
))
return
tools
.
execProcess
(
"
%
s stop"
%
(
os
.
path
.
join
(
config
.
value
(
SERVICE_NAME
,
"initd_dir_path"
),
return
tools
.
process
.
execProcess
(
"
%
s stop"
%
(
os
.
path
.
join
(
config
.
value
(
SERVICE_NAME
,
"initd_dir_path"
),
self
.
__system_service_name
)
),
False
)[
2
]
@service.functionMethod
(
SYSTEM_SERVICE_METHODS_NAMESPACE
,
out_signature
=
"i"
)
def
status
(
self
)
:
return
tools
.
execProcess
(
"
%
s status"
%
(
os
.
path
.
join
(
config
.
value
(
SERVICE_NAME
,
"initd_dir_path"
),
return
tools
.
process
.
execProcess
(
"
%
s status"
%
(
os
.
path
.
join
(
config
.
value
(
SERVICE_NAME
,
"initd_dir_path"
),
self
.
__system_service_name
)
),
False
)[
2
]
...
...
@@ -99,7 +102,7 @@ class SystemService(service.FunctionObject) :
proc_args
=
"
%
s
%
s
%
s
%
s"
%
(
config
.
value
(
SERVICE_NAME
,
"chkconfig_prog_path"
),
(
"--level
%
s"
%
(
levels
)
if
levels
!=
None
else
""
),
self
.
__system_service_name
,
(
"on"
if
enabled_flag
else
"off"
)
)
return
tools
.
execProcess
(
proc_args
,
False
)[
2
]
return
tools
.
process
.
execProcess
(
proc_args
,
False
)[
2
]
###
...
...
@@ -153,7 +156,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
if
st_mode
&
stat
.
S_IEXEC
and
st_mode
&
stat
.
S_IFREG
:
dbus_system_service_name
=
re
.
sub
(
r"-|\."
,
"_"
,
system_service_name
)
system_services_shared
.
addSharedObject
(
dbus_system_service_name
,
SystemService
(
system_service_name
,
dbus_tool
s
.
joinPath
(
SERVICE_NAME
,
dbus_system_service_name
),
self
))
tools
.
dbu
s
.
joinPath
(
SERVICE_NAME
,
dbus_system_service_name
),
self
))
system_service_count
+=
1
logger
.
verbose
(
"{mod}: Added
%
d system services"
%
(
system_service_count
))
...
...
@@ -194,7 +197,7 @@ class Service(service.Service, pyinotify.ThreadedNotifier) :
if
event
.
maskname
==
"IN_CREATE"
:
system_services_shared
.
addSharedObject
(
dbus_system_service_name
,
SystemService
(
event
.
name
,
dbus_tool
s
.
joinPath
(
SERVICE_NAME
,
dbus_system_service_name
),
self
))
tools
.
dbu
s
.
joinPath
(
SERVICE_NAME
,
dbus_system_service_name
),
self
))
logger
.
verbose
(
"{mod}: Added system service
\"
%
s
\"
"
%
(
dbus_system_service_name
))
elif
event
.
maskname
==
"IN_DELETE"
:
...
...
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