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
8d7f618d
Commit
8d7f618d
authored
Sep 10, 2010
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring
parent
ca308c0d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
23 deletions
+31
-23
application.py
settingsd/application.py
+8
-0
dbus_tools.py
settingsd/dbus_tools.py
+8
-8
logger.py
settingsd/logger.py
+15
-15
No files found.
settingsd/application.py
View file @
8d7f618d
...
...
@@ -37,6 +37,8 @@ class Application(object) :
self
.
_main_loop
.
quit
()
logger
.
verbose
(
"GObject loop closed"
)
###
def
loadModules
(
self
)
:
sys
.
path
.
append
(
const
.
FUNCTIONS_DIR
)
sys
.
path
.
append
(
const
.
ACTIONS_DIR
)
...
...
@@ -60,6 +62,8 @@ class Application(object) :
sys
.
path
.
remove
(
const
.
FUNCTIONS_DIR
)
sys
.
path
.
remove
(
const
.
ACTIONS_DIR
)
###
def
loadApplicationConfigs
(
self
)
:
config
.
loadConfigs
(
only_sections_list
=
(
config
.
APPLICATION_SECTION
,))
...
...
@@ -77,6 +81,8 @@ class Application(object) :
config
.
loadConfigs
(
exclude_sections_list
=
(
config
.
APPLICATION_SECTION
,))
###
def
initBus
(
self
)
:
bus_type
=
config
.
value
(
config
.
APPLICATION_SECTION
,
"bus_type"
)
service_name
=
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_name"
)
...
...
@@ -91,6 +97,8 @@ class Application(object) :
logger
.
verbose
(
"Connected to D-Bus
\"
%
s
\"
as
\"
%
s
\"
"
%
(
bus_type
,
service_name
))
###
def
initServices
(
self
)
:
for
service_name
in
self
.
_services_dict
.
keys
()
:
if
config
.
value
(
service_name
,
"enabled"
)
:
...
...
settingsd/dbus_tools.py
View file @
8d7f618d
# -*- coding: utf-8 -*-
##### Public methods #####
def
joinPath
(
first
,
*
others_list
)
:
return
joinItems
(
"/"
,
first
,
*
others_list
)
def
joinMethod
(
first
,
*
others_list
)
:
return
joinItems
(
"."
,
first
,
*
others_list
)
##### Private methods #####
def
joinItems
(
separator
,
first
,
*
others_list
)
:
for
others_list_item
in
others_list
:
...
...
@@ -18,3 +10,11 @@ def joinItems(separator, first, *others_list) :
first
+=
separator
+
others_list_item
return
first
##### Public methods #####
def
joinPath
(
first
,
*
others_list
)
:
return
joinItems
(
"/"
,
first
,
*
others_list
)
def
joinMethod
(
first
,
*
others_list
)
:
return
joinItems
(
"."
,
first
,
*
others_list
)
settingsd/logger.py
View file @
8d7f618d
...
...
@@ -32,6 +32,21 @@ class UnknownMessageType(Exception) :
pass
##### Private methods #####
def
log
(
message_type
,
message
)
:
if
not
message_type
in
ALL_MESSAGES_LIST
:
raise
UnknownMessageType
(
"Message type
\"
%
d
\"
not in list
%
s"
%
(
message_type
,
ALL_MESSAGES_LIST
))
if
message_type
[
2
]
<=
config
.
value
(
config
.
APPLICATION_SECTION
,
"log_level"
)
:
message_type_texts_list
=
(
"Error"
,
"Warning"
,
"Notice"
,
"Info"
,
"Details"
,
"Debug"
)
message
=
"[
%
s ]:
%
s"
%
(
message_type_texts_list
[
message_type
[
0
]],
message
)
print
>>
sys
.
stderr
,
const
.
MY_NAME
,
message
if
config
.
value
(
config
.
RUNTIME_SECTION
,
"use_syslog"
)
:
syslog
.
syslog
(
message_type
[
1
],
message
)
##### Public methods #####
def
error
(
message
)
:
log
(
ERROR_MESSAGE
,
message
)
...
...
@@ -55,18 +70,3 @@ def attachException(message_type = ERROR_MESSAGE) :
for
line
in
traceback
.
format_exc
()
.
splitlines
()
:
log
(
message_type
,
line
)
##### Private methods #####
def
log
(
message_type
,
message
)
:
if
not
message_type
in
ALL_MESSAGES_LIST
:
raise
UnknownMessageType
(
"Message type
\"
%
d
\"
not in list
%
s"
%
(
message_type
,
ALL_MESSAGES_LIST
))
if
message_type
[
2
]
<=
config
.
value
(
config
.
APPLICATION_SECTION
,
"log_level"
)
:
message_type_texts_list
=
(
"Error"
,
"Warning"
,
"Notice"
,
"Info"
,
"Details"
,
"Debug"
)
message
=
"[
%
s ]:
%
s"
%
(
message_type_texts_list
[
message_type
[
0
]],
message
)
print
>>
sys
.
stderr
,
const
.
MY_NAME
,
message
if
config
.
value
(
config
.
RUNTIME_SECTION
,
"use_syslog"
)
:
syslog
.
syslog
(
message_type
[
1
],
message
)
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