Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pyDTN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
space-public
pyDTN
Commits
48eb3b0e
Commit
48eb3b0e
authored
Sep 12, 2019
by
Juraj Sloboda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove cbor dependency - use cbor2 in all places (
#58
)
parent
50871f9a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
11 deletions
+10
-11
pydtn/pydtn/encoding/bundle7.py
pydtn/pydtn/encoding/bundle7.py
+9
-9
pydtn/requirements.txt
pydtn/requirements.txt
+0
-1
pydtn/setup.py
pydtn/setup.py
+1
-1
No files found.
pydtn/pydtn/encoding/bundle7.py
View file @
48eb3b0e
...
...
@@ -7,11 +7,11 @@ Conforms to::
(which is compatible with uPCN 0.6.0)
Dependencies:
This module depends on the ``cbor`` package which can be installed via pip:
This module depends on the ``cbor
2
`` package which can be installed via pip:
.. code:: bash
pip install cbor
pip install cbor
2
Usage:
If you are in the root directory of the project you can simply run:
...
...
@@ -44,8 +44,7 @@ import struct
from
enum
import
IntEnum
,
IntFlag
from
datetime
import
datetime
,
tzinfo
,
timedelta
from
random
import
random
import
cbor
from
cbor.cbor
import
CBOR_ARRAY
import
cbor2
from
.crc
import
crc16_x25
,
crc32
...
...
@@ -308,7 +307,7 @@ class PrimaryBlock(object):
# encode each field
for
field
in
primary_block
:
binary
.
append
(
cbor
.
dumps
(
field
))
binary
.
append
(
cbor
2
.
dumps
(
field
))
if
self
.
crc_type
==
CRCType
.
CRC32
:
# Empty CRC-32 bit field: CBOR "byte string"
...
...
@@ -324,7 +323,7 @@ class PrimaryBlock(object):
crc
=
crc16_x25
(
binary
)
primary_block
.
append
(
struct
.
pack
(
"!H"
,
crc
))
return
cbor
.
dumps
(
primary_block
)
return
cbor
2
.
dumps
(
primary_block
)
class
CanonicalBlock
(
object
):
...
...
@@ -350,7 +349,7 @@ class CanonicalBlock(object):
# Block data length
# If the value can be expressed in one byte, we have to ensure
# that we do not return 0 as block length. Therefore max(1, ...)
block
.
append
(
max
(
1
,
len
(
cbor
.
dumps
(
serialized_data
))))
block
.
append
(
max
(
1
,
len
(
cbor
2
.
dumps
(
serialized_data
))))
# Block-specific data
block
.
append
(
serialized_data
)
...
...
@@ -364,7 +363,7 @@ class CanonicalBlock(object):
else
:
empty_crc
=
b"
\x42\x00\x00
"
binary
=
struct
.
pack
(
"B"
,
0x80
|
7
)
+
b""
.
join
([
cbor
.
dumps
(
item
)
for
item
in
block
])
+
empty_crc
binary
=
struct
.
pack
(
"B"
,
0x80
|
7
)
+
b""
.
join
([
cbor
2
.
dumps
(
item
)
for
item
in
block
])
+
empty_crc
if
self
.
crc_type
==
CRCType
.
CRC32
:
crc
=
crc32
(
binary
)
...
...
@@ -375,7 +374,7 @@ class CanonicalBlock(object):
# unsigned short in network byte order
block
.
append
(
struct
.
pack
(
"!H"
,
crc
))
return
cbor
.
dumps
(
block
)
return
cbor
2
.
dumps
(
block
)
class
PayloadBlock
(
CanonicalBlock
):
...
...
@@ -504,6 +503,7 @@ class Bundle(object):
def
serialize
(
self
):
# Header for indefinite array
CBOR_ARRAY
=
0x80
head
=
struct
.
pack
(
"B"
,
CBOR_ARRAY
|
31
)
# Stop-code for indefinite array
stop
=
b"
\xff
"
...
...
pydtn/requirements.txt
View file @
48eb3b0e
pyyaml~=3.13
cbor~=1.0.0
cbor2~=4.1.2
asyncio~=3.4.3
pydtn/setup.py
View file @
48eb3b0e
from
setuptools
import
setup
,
find_packages
install_requires
=
[
"pyyaml>=3.13"
,
"cbor
>=1.0.0"
,
"cbor
2>=4.1.2"
,
"asyncio>=3.4.3"
]
install_requires
=
[
"pyyaml>=3.13"
,
"cbor2>=4.1.2"
,
"asyncio>=3.4.3"
]
setup
(
name
=
"pydtn"
,
...
...
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