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
79370ec0
Commit
79370ec0
authored
Oct 06, 2010
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hieratic structure of shareds
parent
41021b91
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
33 deletions
+82
-33
main.conf
configs/main.conf
+1
-1
service.py
settingsd/service.py
+15
-8
shared.py
settingsd/shared.py
+66
-24
No files found.
configs/main.conf
View file @
79370ec0
...
...
@@ -3,6 +3,6 @@ bus_type = session
log_level
=
2
enabled
=
yes
[
hello
]
[
example
]
enabled
=
yes
settingsd/service.py
View file @
79370ec0
...
...
@@ -45,22 +45,29 @@ class ServiceRequisitesInterface(object) :
##### Public classes #####
class
Service
(
ServiceInterface
,
ServiceRequisitesInterface
)
:
Functions
=
shared
.
Functions
Actions
=
shared
.
Actions
pass
#####
class
CustomObject
(
dbus
.
service
.
Object
)
:
def
__init__
(
self
,
object_path
)
:
def
__init__
(
self
,
object_path
,
shared_path
,
service
)
:
dbus
.
service
.
Object
.
__init__
(
self
,
config
.
value
(
config
.
RUNTIME_SECTION
,
"bus_name"
),
object_path
)
self
.
_object_path
=
object_path
self
.
_shared_path
=
shared_path
self
.
_service
=
service
### Public ###
def
objectPath
(
self
)
:
self
.
_object_path
return
self
.
_object_path
def
sharedPath
(
self
)
:
return
self
.
_shared_path
def
service
(
self
)
:
return
self
.
_service
def
addToConnection
(
self
,
connection
=
None
,
path
=
None
)
:
self
.
add_to_connection
(
connection
,
path
)
...
...
@@ -70,14 +77,14 @@ class CustomObject(dbus.service.Object) :
class
FunctionObject
(
CustomObject
)
:
def
__init__
(
self
,
object_path
)
:
def
__init__
(
self
,
object_path
,
shared_path
,
service
)
:
CustomObject
.
__init__
(
self
,
dbus_tools
.
joinPath
(
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_path"
),
"functions"
,
object_path
))
"service_path"
),
"functions"
,
object_path
)
,
shared_path
,
service
)
class
ActionObject
(
CustomObject
)
:
def
__init__
(
self
,
object_path
)
:
def
__init__
(
self
,
object_path
,
shared_path
,
service
)
:
CustomObject
.
__init__
(
self
,
dbus_tools
.
joinPath
(
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_path"
),
"actions"
,
object_path
))
"service_path"
),
"actions"
,
object_path
)
,
shared_path
,
service
)
##### Private decorators #####
...
...
settingsd/shared.py
View file @
79370ec0
...
...
@@ -2,49 +2,91 @@
##### Exceptions #####
class
SharedConflict
(
Exception
)
:
class
Shared
s
Conflict
(
Exception
)
:
pass
class
SharedNotExist
(
Exception
)
:
class
SharedNotExist
s
(
Exception
)
:
pass
class
SharedObjectsConflict
(
Exception
)
:
pass
class
SharedObjectNotExists
(
Exception
)
:
pass
##### Private meta #####
class
SharedMeta
(
type
)
:
def
__init__
(
cls
,
name
,
bases_list
,
attrs_dict
)
:
cls
.
_shared_objects_dict
=
{}
##### Private classes #####
class
SharedAbstract
:
def
__init__
(
entity
)
:
entity
.
_shareds_dict
=
{}
entity
.
_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__
))
def
addShared
(
entity
,
shared_name
)
:
if
entity
.
_shareds_dict
.
has_key
(
shared_name
)
:
raise
SharedsConflict
(
"Shared
\"
%
s
\"
is already exists in collection
\"
%
s
\"
"
%
(
shared_name
,
entity
.
__name__
))
entity
.
_shareds_dict
[
shared_name
]
=
Shared
()
setattr
(
entity
,
shared_name
,
entity
.
_shareds_dict
[
shared_name
])
def
removeShared
(
entity
,
shared_name
)
:
if
not
entity
.
_shareds_dict
.
has_key
(
shared_name
)
:
raise
SharedNotExists
(
"Shared
\"
%
s
\"
does not exist in collection
\"
%
s
\"
"
%
(
shared_name
,
entity
.
__name__
))
entity
.
_shareds_dict
.
pop
(
shared_name
)
delattr
(
entity
,
shared_name
)
cls
.
_shared_objects_dict
[
shared_object_name
]
=
shared_object
setattr
(
cls
,
shared_object_name
,
shared_object
)
def
hasShared
(
entity
,
shared_name
)
:
return
entity
.
_shareds_dict
.
has_key
(
shared_name
)
def
removeSharedObject
(
cls
,
shared_object_name
)
:
if
not
cls
.
_shared_objects_dict
.
has_key
(
shared_object_name
)
:
raise
SharedNotExist
(
"Shared
\"
%
s
\"
does not exist in collection
\"
%
s
\"
"
%
(
shared_object_name
,
cls
.
__name__
))
def
shared
(
entity
,
shared_name
)
:
return
entity
.
_shareds_dict
[
shared_name
]
cls
.
_shared_objects_dict
.
pop
(
shared_object_name
)
delattr
(
cls
,
shared_object_name
)
def
shareds
(
entity
)
:
return
entity
.
_shareds_dict
def
hasSharedObject
(
cls
,
shared_object
)
:
return
(
shared_object
in
cls
.
_shared_objects_dict
.
keys
()
or
shared_object
in
cls
.
_shared_objects_dict
.
values
()
)
###
def
sharedObject
(
cls
,
shared_object_name
)
:
return
cls
.
_shared_objects_dict
[
shared_object_name
]
def
addSharedObject
(
entity
,
shared_object_name
,
shared_object
)
:
if
entity
.
_shared_objects_dict
.
has_key
(
shared_object_name
)
:
raise
SharedObjectsConflict
(
"Shared object
\"
%
s
\"
is already exists in collection
\"
%
s
\"
"
%
(
shared_object_name
,
entity
.
__name__
))
entity
.
_shared_objects_dict
[
shared_object_name
]
=
shared_object
setattr
(
entity
,
shared_object_name
,
entity
.
_shared_objects_dict
[
shared_object_name
])
def
removeSharedObject
(
entity
,
shared_object_name
)
:
if
not
entity
.
_shared_objects_dict
.
has_key
(
shared_object_name
)
:
raise
SharedObjectNotExists
(
"Shared object
\"
%
s
\"
does not exist in collection
\"
%
s
\"
"
%
(
shared_object_name
,
entity
.
__name__
))
entity
.
_shared_objects_dict
.
pop
(
shared_object_name
)
delattr
(
entity
,
shared_object_name
)
def
hasSharedObject
(
entity
,
shared_object
)
:
return
(
entity
.
_shared_objects_dict
.
has_key
(
shared_object
)
or
shared_object
in
entity
.
_shared_objects_dict
.
values
()
)
def
sharedObject
(
entity
,
shared_object_name
)
:
return
entity
,
entity
.
_shared_objects_dict
[
shared_object_name
]
def
sharedObjects
(
entity
)
:
return
entity
.
_shared_objects_dict
class
SharedRootMeta
(
type
,
SharedAbstract
)
:
def
__init__
(
cls
,
name
,
bases_list
,
attrs_dict
)
:
type
.
__init__
(
cls
,
name
,
bases_list
,
attrs_dict
)
SharedAbstract
.
__init__
(
cls
)
def
sharedObjectsList
(
cls
)
:
return
cls
.
_shared_objects_dict
class
Shared
(
object
,
SharedAbstract
)
:
def
__init__
(
self
)
:
object
.
__init__
(
self
)
SharedAbstract
.
__init__
(
self
)
##### Public classes #####
class
Functions
(
object
)
:
__metaclass__
=
SharedMeta
__metaclass__
=
Shared
Root
Meta
class
Actions
(
object
)
:
__metaclass__
=
SharedMeta
__metaclass__
=
Shared
Root
Meta
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