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
a5876988
Commit
a5876988
authored
9 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
Use __future__ to allow with statement under Python 2.5
parent
62173582
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scapy/utils.py
+5
-15
5 additions, 15 deletions
scapy/utils.py
with
5 additions
and
15 deletions
scapy/utils.py
+
5
−
15
View file @
a5876988
...
...
@@ -7,6 +7,7 @@
General utility functions.
"""
from
__future__
import
with_statement
import
os
,
sys
,
socket
,
types
import
random
,
time
import
gzip
,
zlib
,
cPickle
...
...
@@ -521,26 +522,15 @@ def wrpcap(filename, pkt, *args, **kargs):
gz: set to 1 to save a gzipped capture
linktype: force linktype value
endianness:
"
<
"
or
"
>
"
, force endianness
"""
## Does not work with Python <= 2.5. Use this implementation as
## soon as we drop support for Python 2.5.
# with PcapWriter(filename, *args, **kargs) as fdesc:
# fdesc.write(pkt)
fdesc
=
PcapWriter
(
filename
,
*
args
,
**
kargs
)
fdesc
.
write
(
pkt
)
fdesc
.
close
()
with
PcapWriter
(
filename
,
*
args
,
**
kargs
)
as
fdesc
:
fdesc
.
write
(
pkt
)
@conf.commands.register
def
rdpcap
(
filename
,
count
=-
1
):
"""
Read a pcap file and return a packet list
count: read only <count> packets
"""
## Does not work with Python <= 2.5. Use this implementation as
## soon as we drop support for Python 2.5.
# with PcapReader(filename) as fdesc:
# return fdesc.read_all(count=count)
fdesc
=
PcapReader
(
filename
)
result
=
fdesc
.
read_all
(
count
=
count
)
fdesc
.
close
()
return
result
with
PcapReader
(
filename
)
as
fdesc
:
return
fdesc
.
read_all
(
count
=
count
)
...
...
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