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
7b173447
Commit
7b173447
authored
Sep 07, 2010
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring
parent
cf1eb01e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
20 deletions
+51
-20
hello.py
functions/hello.py
+1
-1
application.py
settingsd/application.py
+8
-2
config.py
settingsd/config.py
+2
-2
const.py
settingsd/const.py
+1
-0
dbus_tools.py
settingsd/dbus_tools.py
+2
-2
logger.py
settingsd/logger.py
+3
-3
service.py
settingsd/service.py
+25
-6
shared.py
settingsd/shared.py
+7
-2
validators.py
settingsd/validators.py
+2
-2
No files found.
functions/hello.py
View file @
7b173447
...
...
@@ -31,7 +31,7 @@ class Service(settingsd.service.Service) :
return
"hello"
@classmethod
def
options
(
self
)
:
def
options
List
(
self
)
:
return
[
(
self
.
serviceName
(),
"hello_string"
,
"Hello, World!"
,
str
)
]
...
...
settingsd/application.py
View file @
7b173447
...
...
@@ -14,7 +14,7 @@ import validators
import
logger
#####
#####
Public classes #####
class
Application
(
object
)
:
def
__init__
(
self
)
:
object
.
__init__
(
self
)
...
...
@@ -26,6 +26,9 @@ class Application(object) :
self
.
_main_loop
=
gobject
.
MainLoop
()
### Public ###
def
exec_
(
self
)
:
self
.
init
()
logger
.
message
(
const
.
LOG_LEVEL_INFO
,
"Initialized"
)
...
...
@@ -35,6 +38,9 @@ class Application(object) :
self
.
close
()
logger
.
message
(
const
.
LOG_LEVEL_INFO
,
"Closed"
)
### Private ###
def
init
(
self
)
:
self
.
loadModules
()
self
.
loadConfigs
()
...
...
@@ -65,7 +71,7 @@ class Application(object) :
def
loadConfigs
(
self
)
:
for
service_name
in
self
.
_services_dict
.
keys
()
:
service_options_list
=
list
(
self
.
_services_dict
[
service_name
][
"service_class"
]
.
options
())
service_options_list
=
list
(
self
.
_services_dict
[
service_name
][
"service_class"
]
.
options
List
())
service_options_list
.
append
((
service_name
,
"enabled"
,
"no"
,
validators
.
validBool
))
for
service_options_list_item
in
service_options_list
:
...
...
settingsd/config.py
View file @
7b173447
...
...
@@ -9,7 +9,7 @@ import config
import
validators
#####
#####
Private objects #####
ConfigDictObject
=
{
const
.
MY_NAME
:
{
"service_name"
:
(
const
.
DEFAULT_SERVICE_NAME
,
str
),
...
...
@@ -20,7 +20,7 @@ ConfigDictObject = {
}
##### Public #####
##### Public
methods
#####
def
setValue
(
section
,
option
,
value
,
validator
=
None
)
:
global
ConfigDictObject
...
...
settingsd/const.py
View file @
7b173447
# -*- coding: utf-8 -*-
##### Public constants #####
MY_NAME
=
"settingsd"
RUNTIME_NAME
=
"runtime"
...
...
settingsd/dbus_tools.py
View file @
7b173447
# -*- coding: utf-8 -*-
##### Public #####
##### Public
methods
#####
def
joinPath
(
first
,
*
others_list
)
:
return
joinItems
(
"/"
,
first
,
*
others_list
)
...
...
@@ -9,7 +9,7 @@ def joinMethod(first, *others_list) :
return
joinItems
(
"."
,
first
,
*
others_list
)
##### Private #####
##### Private
methods
#####
def
joinItems
(
separator
,
first
,
*
others_list
)
:
for
others_list_item
in
others_list
:
if
len
(
first
)
==
0
:
...
...
settingsd/logger.py
View file @
7b173447
...
...
@@ -7,7 +7,7 @@ import const
import
config
#####
#####
Public constants #####
ERROR_MESSAGE
=
0
INFO_MESSAGE
=
1
VERBOSE_MESSAGE
=
2
...
...
@@ -21,12 +21,12 @@ ALL_MESSAGES_LIST = (
)
#####
#####
Exceptions #####
class
UnknownMessageType
(
Exception
)
:
pass
#####
#####
Public methods #####
def
message
(
message_type
,
message
)
:
if
message_type
in
(
ERROR_MESSAGE
,
INFO_MESSAGE
)
:
log_level
=
const
.
LOG_LEVEL_INFO
...
...
settingsd/service.py
View file @
7b173447
# -*- coding: utf-8 -*-
import
dbus
import
dbus.service
import
dbus.glib
...
...
@@ -12,12 +13,12 @@ import dbus_tools
import
logger
#####
class
Service
(
object
)
:
#####
Private classes #####
class
Service
Interface
(
object
)
:
__metaclass__
=
abc
.
ABCMeta
Functions
=
shared
.
Functions
Actions
=
shared
.
Actions
### Public ###
@abc.abstractmethod
def
initService
(
self
)
:
...
...
@@ -26,16 +27,28 @@ class Service(object) :
def
closeService
(
self
)
:
pass
class
ServiceRequisitesInterface
(
object
)
:
__metaclass__
=
abc
.
ABCMeta
### Public ###
@classmethod
@abc.abstractmethod
def
serviceName
(
self
)
:
pass
@classmethod
def
options
(
self
)
:
def
options
List
(
self
)
:
return
[]
##### Public classes #####
class
Service
(
ServiceInterface
,
ServiceRequisitesInterface
)
:
Functions
=
shared
.
Functions
Actions
=
shared
.
Actions
#####
class
CustomObject
(
dbus
.
service
.
Object
)
:
def
__init__
(
self
,
object_path
)
:
...
...
@@ -43,6 +56,9 @@ class CustomObject(dbus.service.Object) :
self
.
_object_path
=
object_path
### Public ###
def
objectPath
(
self
)
:
self
.
_object_path
...
...
@@ -52,6 +68,7 @@ class CustomObject(dbus.service.Object) :
def
removeFromConnection
(
self
,
conneciton
=
None
,
path
=
None
)
:
self
.
remove_from_connection
(
conneciton
,
path
)
class
FunctionObject
(
CustomObject
)
:
def
__init__
(
self
,
object_path
)
:
CustomObject
.
__init__
(
self
,
dbus_tools
.
joinPath
(
config
.
value
(
const
.
MY_NAME
,
"service_path"
),
"functions"
,
object_path
))
...
...
@@ -61,7 +78,7 @@ class ActionObject(CustomObject) :
CustomObject
.
__init__
(
self
,
dbus_tools
.
joinPath
(
config
.
value
(
const
.
MY_NAME
,
"service_path"
),
"actions"
,
object_path
))
######
#####
Private decorators ####
#
def
tracer
(
function
)
:
def
wrapper
(
self
,
*
args_list
,
**
kwargs_dict
)
:
return_value
=
function
(
self
,
*
args_list
,
**
kwargs_dict
)
...
...
@@ -75,6 +92,8 @@ def tracer(function) :
return
wrapper
##### Public decorators #####
def
customMethod
(
interface_name
)
:
def
decorator
(
function
)
:
return
tracer
(
dbus
.
service
.
method
(
interface_name
)(
function
))
...
...
settingsd/shared.py
View file @
7b173447
# -*- coding: utf-8 -*-
#####
#####
Exceptions #####
class
SharedConflict
(
Exception
)
:
pass
...
...
@@ -9,11 +9,14 @@ class SharedNotExist(Exception) :
pass
#####
#####
Private meta #####
class
SharedMeta
(
type
)
:
def
__init__
(
cls
,
name
,
bases_list
,
attrs_dict
)
:
cls
.
_shared_objects_dict
=
{}
### Public ###
def
addSharedObject
(
cls
,
shared_object_name
,
shared_object
)
:
if
cls
.
_shared_objects_dict
.
has_key
(
shared_object_name
)
:
raise
SharedConflict
(
"Shared
\"
%
s
\"
is already exists in collection
\"
%
s
\"
"
%
(
shared_object_name
,
cls
.
__name__
))
...
...
@@ -37,6 +40,8 @@ class SharedMeta(type) :
def
sharedObjectsList
(
cls
)
:
return
cls
.
_shared_objects_dict
##### Public classes #####
class
Functions
(
object
)
:
__metaclass__
=
SharedMeta
...
...
settingsd/validators.py
View file @
7b173447
# -*- coding: utf-8 -*-
#####
#####
Exceptions #####
class
ValidatorError
(
Exception
)
:
pass
##### Public #####
##### Public
methods
#####
def
validBool
(
arg
)
:
arg
=
str
(
arg
)
.
lower
()
true_args_list
=
(
"1"
,
"true"
,
"yes"
)
...
...
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