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
77388c96
Commit
77388c96
authored
Oct 06, 2010
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved decorators from service.py to service_decorators.py
parent
79370ec0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
74 deletions
+94
-74
service.py
settingsd/service.py
+8
-74
service_decorators.py
settingsd/service_decorators.py
+86
-0
No files found.
settingsd/service.py
View file @
77388c96
...
...
@@ -12,6 +12,14 @@ import shared
import
dbus_tools
import
logger
from
service_decorators
import
customMethod
from
service_decorators
import
functionMethod
from
service_decorators
import
actionMethod
from
service_decorators
import
customSignal
from
service_decorators
import
functionSignal
from
service_decorators
import
actionSignal
##### Private classes #####
class
ServiceInterface
(
object
)
:
...
...
@@ -86,77 +94,3 @@ class ActionObject(CustomObject) :
CustomObject
.
__init__
(
self
,
dbus_tools
.
joinPath
(
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_path"
),
"actions"
,
object_path
),
shared_path
,
service
)
##### Private decorators #####
def
tracer
(
function
,
statics_list
=
[
0
])
:
def
wrapper
(
self
,
*
args_list
,
**
kwargs_dict
)
:
if
config
.
value
(
config
.
APPLICATION_SECTION
,
"log_level"
)
==
const
.
LOG_LEVEL_DEBUG
:
logger
.
debug
(
"
%
s
%
s
%
s::
%
s"
%
(
" "
*
statics_list
[
0
],
str
((
function
.
__dict__
.
has_key
(
"_dbus_is_method"
)
and
"Called method"
)
or
(
function
.
__dict__
.
has_key
(
"_dbus_is_signal"
)
and
"Emited signal"
)),
self
.
_object_path
,
dbus_tools
.
joinMethod
(
function
.
_dbus_interface
,
function
.
__name__
)
))
statics_list
[
0
]
+=
1
try
:
return_value
=
function
(
self
,
*
args_list
,
**
kwargs_dict
)
except
:
logger
.
attachException
()
raise
finally
:
statics_list
[
0
]
-=
1
logger
.
debug
(
"
%
s... executed as
%
s::
%
s(
%
s,
%
s) -->
%
s"
%
(
" "
*
statics_list
[
0
],
self
.
__class__
.
__name__
,
function
.
__name__
,
str
(
args_list
),
str
(
kwargs_dict
),
str
(
return_value
)
))
return
return_value
else
:
try
:
return
function
(
self
,
*
args_list
,
**
kwargs_dict
)
except
:
logger
.
attachException
()
raise
wrapper
.
__name__
=
function
.
__name__
wrapper
.
__dict__
=
function
.
__dict__
wrapper
.
__doc__
=
function
.
__doc__
return
wrapper
##### Public decorators #####
def
customMethod
(
interface_name
)
:
def
decorator
(
function
)
:
return
tracer
(
dbus
.
service
.
method
(
interface_name
)(
function
))
return
decorator
def
functionMethod
(
interface_name
)
:
def
decorator
(
function
)
:
return
customMethod
(
dbus_tools
.
joinMethod
(
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_name"
),
"functions"
,
interface_name
))(
function
)
return
decorator
def
actionsMethod
(
interface_name
)
:
def
decorator
(
function
)
:
return
customMethod
(
dbus_tools
.
joinMethod
(
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_name"
),
"actions"
,
interface_name
))(
function
)
return
decorator
###
def
customSignal
(
interface_name
)
:
def
decorator
(
function
)
:
return
tracer
(
dbus
.
service
.
signal
(
interface_name
)(
function
))
return
decorator
def
functionSignal
(
interface_name
)
:
def
decorator
(
function
)
:
return
customSignal
(
dbus_tools
.
joinMethod
(
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_name"
),
"functions"
,
interface_name
))(
function
)
return
decorator
def
actionsSignal
(
interface_name
)
:
def
decorator
(
function
)
:
return
customSignal
(
dbus_tools
.
joinMethod
(
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_name"
),
"actions"
,
interface_name
))(
function
)
return
decorator
settingsd/service_decorators.py
0 → 100644
View file @
77388c96
# -*- coding: utf-8 -*-
import
dbus
import
dbus.service
import
dbus.glib
import
const
import
config
import
dbus_tools
import
logger
##### Private decorators #####
def
tracer
(
function
,
statics_list
=
[
0
])
:
def
wrapper
(
self
,
*
args_list
,
**
kwargs_dict
)
:
if
config
.
value
(
config
.
APPLICATION_SECTION
,
"log_level"
)
==
const
.
LOG_LEVEL_DEBUG
:
logger
.
debug
(
"
%
s
%
s
%
s::
%
s"
%
(
" "
*
statics_list
[
0
],
str
((
function
.
__dict__
.
has_key
(
"_dbus_is_method"
)
and
"Called method"
)
or
(
function
.
__dict__
.
has_key
(
"_dbus_is_signal"
)
and
"Emited signal"
)),
self
.
_object_path
,
dbus_tools
.
joinMethod
(
function
.
_dbus_interface
,
function
.
__name__
)
))
statics_list
[
0
]
+=
1
try
:
return_value
=
function
(
self
,
*
args_list
,
**
kwargs_dict
)
except
:
logger
.
attachException
()
raise
finally
:
statics_list
[
0
]
-=
1
logger
.
debug
(
"
%
s... executed as
%
s::
%
s(
%
s,
%
s) -->
%
s"
%
(
" "
*
statics_list
[
0
],
self
.
__class__
.
__name__
,
function
.
__name__
,
str
(
args_list
),
str
(
kwargs_dict
),
str
(
return_value
)
))
return
return_value
else
:
try
:
return
function
(
self
,
*
args_list
,
**
kwargs_dict
)
except
:
logger
.
attachException
()
raise
wrapper
.
__name__
=
function
.
__name__
wrapper
.
__dict__
=
function
.
__dict__
wrapper
.
__doc__
=
function
.
__doc__
return
wrapper
##### Public decorators #####
def
customMethod
(
interface_name
)
:
def
decorator
(
function
)
:
return
tracer
(
dbus
.
service
.
method
(
interface_name
)(
function
))
return
decorator
def
functionMethod
(
interface_name
)
:
def
decorator
(
function
)
:
return
customMethod
(
dbus_tools
.
joinMethod
(
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_name"
),
"functions"
,
interface_name
))(
function
)
return
decorator
def
actionMethod
(
interface_name
)
:
def
decorator
(
function
)
:
return
customMethod
(
dbus_tools
.
joinMethod
(
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_name"
),
"actions"
,
interface_name
))(
function
)
return
decorator
###
def
customSignal
(
interface_name
)
:
def
decorator
(
function
)
:
return
tracer
(
dbus
.
service
.
signal
(
interface_name
)(
function
))
return
decorator
def
functionSignal
(
interface_name
)
:
def
decorator
(
function
)
:
return
customSignal
(
dbus_tools
.
joinMethod
(
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_name"
),
"functions"
,
interface_name
))(
function
)
return
decorator
def
actionSignal
(
interface_name
)
:
def
decorator
(
function
)
:
return
customSignal
(
dbus_tools
.
joinMethod
(
config
.
value
(
config
.
APPLICATION_SECTION
,
"service_name"
),
"actions"
,
interface_name
))(
function
)
return
decorator
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