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
e61626a3
Commit
e61626a3
authored
Sep 07, 2010
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug with method decorator, added logging for exceptions
parent
05f2c1b7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
11 deletions
+21
-11
application.py
settingsd/application.py
+8
-3
logger.py
settingsd/logger.py
+12
-7
service.py
settingsd/service.py
+1
-1
No files found.
settingsd/application.py
View file @
e61626a3
...
...
@@ -31,12 +31,12 @@ class Application(object) :
def
exec_
(
self
)
:
self
.
init
()
logger
.
message
(
const
.
LOG_LEVEL_INFO
,
"Initialized"
)
logger
.
message
(
logger
.
INFO_MESSAGE
,
"Initialized"
)
try
:
self
.
run
()
except
KeyboardInterrupt
:
self
.
close
()
logger
.
message
(
const
.
LOG_LEVEL_INFO
,
"Closed"
)
logger
.
message
(
logger
.
INFO_MESSAGE
,
"Closed"
)
### Private ###
...
...
@@ -60,7 +60,12 @@ class Application(object) :
for
modules_path_list_item
in
(
const
.
FUNCTIONS_DIR
,
const
.
ACTIONS_DIR
)
:
for
module_name
in
[
item
[:
-
3
]
for
item
in
os
.
listdir
(
modules_path_list_item
)
if
item
.
endswith
(
".py"
)
]
:
self
.
_modules_list
.
append
(
__import__
(
module_name
,
globals
(),
locals
(),
[
""
]))
try
:
self
.
_modules_list
.
append
(
__import__
(
module_name
,
globals
(),
locals
(),
[
""
]))
except
Exception
:
logger
.
message
(
logger
.
ERROR_MESSAGE
,
"Import error on module
\"
%
s
\"
"
%
(
module_name
))
logger
.
attachException
()
continue
self
.
_services_dict
[
self
.
_modules_list
[
-
1
]
.
Service
.
serviceName
()]
=
{
"service_class"
:
self
.
_modules_list
[
-
1
]
.
Service
,
"service"
:
None
...
...
settingsd/logger.py
View file @
e61626a3
...
...
@@ -2,6 +2,7 @@
import
sys
import
traceback
import
const
import
config
...
...
@@ -29,20 +30,24 @@ class UnknownMessageType(Exception) :
##### Public methods #####
def
message
(
message_type
,
message
)
:
if
message_type
in
(
ERROR_MESSAGE
,
INFO_MESSAGE
)
:
log
_level
=
const
.
LOG_LEVEL_INFO
message
_level
=
const
.
LOG_LEVEL_INFO
elif
message_type
==
VERBOSE_MESSAGE
:
log
_level
=
const
.
LOG_LEVEL_VERBOSE
message
_level
=
const
.
LOG_LEVEL_VERBOSE
elif
message_type
==
DEBUG_MESSAGE
:
log
_level
=
const
.
LOG_LEVEL_DEBUG
message
_level
=
const
.
LOG_LEVEL_DEBUG
else
:
raise
UnknownMessageType
(
"Message type
\"
%
d
\"
not in list
%
s"
%
(
message_type
,
ALL_MESSAGES_LIST
))
if
log_level
<=
config
.
value
(
const
.
MY_NAME
,
"log_level"
)
:
text_log_levels_list
=
(
if
message_level
<=
config
.
value
(
const
.
MY_NAME
,
"log_level"
)
:
message_level_prefixes_list
=
(
"
%
s [ Error ]:"
%
(
const
.
MY_NAME
),
"
%
s [ Info ]:"
%
(
const
.
MY_NAME
),
"
%
s [ Details ]:"
%
(
const
.
MY_NAME
),
"
%
s [ Details ]:"
%
(
const
.
MY_NAME
),
"
%
s [ Debug ]:"
%
(
const
.
MY_NAME
)
)
print
>>
sys
.
stderr
,
message_level_prefixes_list
[
message_type
],
message
print
>>
sys
.
stderr
,
text_log_levels_list
[
log_level
],
message
def
attachException
()
:
for
line
in
traceback
.
format_exc
()
.
splitlines
()
:
message
(
ERROR_MESSAGE
,
line
)
settingsd/service.py
View file @
e61626a3
...
...
@@ -89,7 +89,7 @@ def tracer(function) :
wrapper
.
__name__
=
function
.
__name__
wrapper
.
__dict__
=
function
.
__dict__
wrapper
.
__doc__
=
function
s
.
__doc__
wrapper
.
__doc__
=
function
.
__doc__
return
wrapper
...
...
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