Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
21d9a01b
Commit
21d9a01b
authored
8 years ago
by
Pierre Lalet
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #578 from gpotter2/fix-tests-automaton
[appveyor] Fix tests automaton
parents
75aa97f1
fddf6573
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scapy/automaton.py
+15
-11
15 additions, 11 deletions
scapy/automaton.py
with
15 additions
and
11 deletions
scapy/automaton.py
+
15
−
11
View file @
21d9a01b
...
@@ -26,14 +26,14 @@ class ObjectPipe:
...
@@ -26,14 +26,14 @@ class ObjectPipe:
def
fileno
(
self
):
def
fileno
(
self
):
return
self
.
rd
return
self
.
rd
def
checkRecv
(
self
):
def
checkRecv
(
self
):
return
len
(
self
.
queue
)
!=
0
return
len
(
self
.
queue
)
>
0
def
send
(
self
,
obj
):
def
send
(
self
,
obj
):
self
.
queue
.
append
(
obj
)
self
.
queue
.
append
(
obj
)
os
.
write
(
self
.
wr
,
"
X
"
)
os
.
write
(
self
.
wr
,
"
X
"
)
def
write
(
self
,
obj
):
def
write
(
self
,
obj
):
self
.
send
(
obj
)
self
.
send
(
obj
)
def
recv
(
self
,
n
=
0
):
def
recv
(
self
,
n
=
0
):
os
.
read
(
self
.
rd
,
1
)
os
.
read
(
self
.
rd
,
1
)
return
self
.
queue
.
popleft
()
return
self
.
queue
.
popleft
()
def
read
(
self
,
n
=
0
):
def
read
(
self
,
n
=
0
):
return
self
.
recv
(
n
)
return
self
.
recv
(
n
)
...
@@ -53,7 +53,6 @@ class _instance_state:
...
@@ -53,7 +53,6 @@ class _instance_state:
self
.
im_class
=
instance
.
im_class
self
.
im_class
=
instance
.
im_class
def
__getattr__
(
self
,
attr
):
def
__getattr__
(
self
,
attr
):
return
getattr
(
self
.
im_func
,
attr
)
return
getattr
(
self
.
im_func
,
attr
)
def
__call__
(
self
,
*
args
,
**
kargs
):
def
__call__
(
self
,
*
args
,
**
kargs
):
return
self
.
im_func
(
self
.
im_self
,
*
args
,
**
kargs
)
return
self
.
im_func
(
self
.
im_self
,
*
args
,
**
kargs
)
def
breaks
(
self
):
def
breaks
(
self
):
...
@@ -328,15 +327,20 @@ class Automaton_metaclass(type):
...
@@ -328,15 +327,20 @@ class Automaton_metaclass(type):
def
select_objects
(
inputs
,
remain
):
def
select_objects
(
inputs
,
remain
):
if
WINDOWS
:
if
WINDOWS
:
r
=
[]
r
=
[]
def
look_for_select
():
for
fd
in
inputs
:
if
isinstance
(
fd
,
ObjectPipe
)
or
isinstance
(
fd
,
Automaton
.
_IO_fdwrapper
):
if
fd
.
checkRecv
():
r
.
append
(
fd
)
else
:
raise
OSError
(
"
Not supported type of socket:
"
+
str
(
type
(
fd
)))
break
def
search_select
():
def
search_select
():
while
len
(
r
)
==
0
:
while
len
(
r
)
==
0
:
for
fd
in
inputs
:
look_for_select
()
if
isinstance
(
fd
,
ObjectPipe
)
or
isinstance
(
fd
,
Automaton
.
_IO_fdwrapper
):
if
remain
==
0
:
if
fd
.
checkRecv
():
look_for_select
()
r
.
append
(
fd
)
return
r
else
:
raise
OSError
(
"
Not supported type of socket:
"
+
str
(
type
(
fd
)))
break
t_select
=
threading
.
Thread
(
target
=
search_select
)
t_select
=
threading
.
Thread
(
target
=
search_select
)
t_select
.
start
()
t_select
.
start
()
t_select
.
join
(
remain
)
t_select
.
join
(
remain
)
...
@@ -750,7 +754,7 @@ class Automaton:
...
@@ -750,7 +754,7 @@ class Automaton:
with
self
.
started
:
with
self
.
started
:
# Flush command pipes
# Flush command pipes
while
True
:
while
True
:
r
=
select_objects
([
self
.
cmdin
,
self
.
cmdout
],
0
)
r
=
select_objects
([
self
.
cmdin
,
self
.
cmdout
],
0
)
if
not
r
:
if
not
r
:
break
break
for
fd
in
r
:
for
fd
in
r
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment