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
0c412496
authored
May 29, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle disconnect
parent
6be953f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletions
+12
-1
agent.py
+3
-0
linux/posixvirtio.py
+9
-1
No files found.
agent.py
View file @
0c412496
...
@@ -57,6 +57,9 @@ class SerialLineReceiver(SerialLineReceiverBase):
...
@@ -57,6 +57,9 @@ class SerialLineReceiver(SerialLineReceiverBase):
return
d
return
d
reactor
.
addSystemEventTrigger
(
"before"
,
"shutdown"
,
shutdown
)
reactor
.
addSystemEventTrigger
(
"before"
,
"shutdown"
,
shutdown
)
def
connectionLost
(
self
,
reason
):
reactor
.
stop
()
def
connectionLost2
(
self
,
reason
):
def
connectionLost2
(
self
,
reason
):
self
.
send_command
(
command
=
'agent_stopped'
,
self
.
send_command
(
command
=
'agent_stopped'
,
args
=
{})
args
=
{})
...
...
linux/posixvirtio.py
View file @
0c412496
...
@@ -7,7 +7,9 @@ Virtio-Serial Port Protocol
...
@@ -7,7 +7,9 @@ Virtio-Serial Port Protocol
"""
"""
# system imports
# system imports
import
logging
import
os
import
os
from
time
import
sleep
# dependent on pyserial ( http://pyserial.sf.net/ )
# dependent on pyserial ( http://pyserial.sf.net/ )
# only tested w/ 1.18 (5 Dec 2002)
# only tested w/ 1.18 (5 Dec 2002)
...
@@ -15,6 +17,8 @@ import os
...
@@ -15,6 +17,8 @@ import os
# twisted imports
# twisted imports
from
twisted.internet
import
abstract
,
fdesc
from
twisted.internet
import
abstract
,
fdesc
logger
=
logging
.
getLogger
()
class
SerialPort
(
abstract
.
FileDescriptor
):
class
SerialPort
(
abstract
.
FileDescriptor
):
"""
"""
...
@@ -57,4 +61,8 @@ class SerialPort(abstract.FileDescriptor):
...
@@ -57,4 +61,8 @@ class SerialPort(abstract.FileDescriptor):
"""
"""
abstract
.
FileDescriptor
.
connectionLost
(
self
,
reason
)
abstract
.
FileDescriptor
.
connectionLost
(
self
,
reason
)
os
.
close
(
self
.
_serial
)
os
.
close
(
self
.
_serial
)
self
.
protocol
.
connectionLost
(
reason
)
sleep
(
2
)
self
.
_serial
=
os
.
open
(
self
.
port
,
os
.
O_RDWR
|
os
.
O_NOCTTY
|
os
.
O_NONBLOCK
)
self
.
startReading
()
logger
.
info
(
"Reconnecting"
)
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