Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
agent
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
7
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f6d38d37
authored
Aug 12, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix logging
parent
3cf8491e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
10 deletions
+17
-10
agent-winservice.py
+6
-2
agent.py
+5
-1
utils.py
+6
-7
No files found.
agent-winservice.py
View file @
f6d38d37
import
logging
from
logging.handlers
import
NTEventLogHandler
import
os
import
servicemanager
import
socket
import
sys
import
win32event
import
win32service
import
win32serviceutil
...
...
@@ -9,12 +11,14 @@ import win32serviceutil
from
agent
import
main
as
agent_main
,
reactor
logger
=
logging
.
getLogger
()
fh
=
logging
.
File
Handler
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"agent-service.log"
))
fh
=
NTEventLog
Handler
(
"CIRCLE Agent"
,
dllname
=
os
.
path
.
dirname
(
__file__
))
formatter
=
logging
.
Formatter
(
"
%(asctime)
s -
%(name)
s [
%(levelname)
s]
%(message)
s"
)
fh
.
setFormatter
(
formatter
)
logger
.
addHandler
(
fh
)
level
=
os
.
environ
.
get
(
'LOGLEVEL'
,
'INFO'
)
logger
.
setLevel
(
level
)
logger
.
info
(
"
%
s loaded"
,
__file__
)
...
...
agent.py
View file @
f6d38d37
...
...
@@ -13,7 +13,7 @@ import platform
import
sys
import
tarfile
from
os.path
import
expanduser
,
join
,
exists
from
os
import
mkdir
from
os
import
mkdir
,
environ
from
glob
import
glob
from
StringIO
import
StringIO
from
base64
import
decodestring
...
...
@@ -25,7 +25,11 @@ from utils import SerialLineReceiverBase
from
ssh
import
PubKey
logging
.
basicConfig
()
logger
=
logging
.
getLogger
()
level
=
environ
.
get
(
'LOGLEVEL'
,
'INFO'
)
logger
.
setLevel
(
level
)
SSH_DIR
=
expanduser
(
'~cloud/.ssh'
)
AUTHORIZED_KEYS
=
join
(
SSH_DIR
,
'authorized_keys'
)
...
...
utils.py
View file @
f6d38d37
...
...
@@ -2,8 +2,7 @@ from twisted.protocols.basic import LineReceiver
import
json
import
logging
root_logger
=
logging
.
getLogger
()
root_logger
.
setLevel
(
logging
.
DEBUG
)
logger
=
logging
.
getLogger
()
class
SerialLineReceiverBase
(
LineReceiver
,
object
):
...
...
@@ -31,17 +30,17 @@ class SerialLineReceiverBase(LineReceiver, object):
args
=
{}
command
=
data
.
get
(
'command'
,
None
)
response
=
data
.
get
(
'response'
,
None
)
logg
ing
.
debug
(
'[serial] valid json:
%
s'
%
(
data
,
))
logg
er
.
debug
(
'[serial] valid json:
%
s'
%
(
data
,
))
except
(
ValueError
,
KeyError
)
as
e
:
logg
ing
.
error
(
'[serial] invalid json:
%
s (
%
s)'
%
(
data
,
e
))
logg
er
.
error
(
'[serial] invalid json:
%
s (
%
s)'
%
(
data
,
e
))
return
if
command
is
not
None
and
isinstance
(
command
,
unicode
):
logg
ing
.
debug
(
'received command:
%
s (
%
s)'
%
(
command
,
args
))
logg
er
.
debug
(
'received command:
%
s (
%
s)'
%
(
command
,
args
))
try
:
self
.
handle_command
(
command
,
args
)
except
Exception
as
e
:
logg
ing
.
exception
(
u'Unhandled exception: '
)
logg
er
.
exception
(
u'Unhandled exception: '
)
elif
response
is
not
None
and
isinstance
(
response
,
unicode
):
logg
ing
.
debug
(
'received reply:
%
s (
%
s)'
%
(
response
,
args
))
logg
er
.
debug
(
'received reply:
%
s (
%
s)'
%
(
response
,
args
))
self
.
handle_response
(
response
,
args
)
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