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
0bca814d
Commit
0bca814d
authored
Aug 01, 2019
by
Juraj Sloboda
Committed by
Matej Feder
Sep 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement logging
parent
c2442ed1
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
82 additions
and
6 deletions
+82
-6
.gitignore
.gitignore
+3
-0
demo_app/main.py
demo_app/main.py
+1
-1
pydtn/pydtn/pydtn.py
pydtn/pydtn/pydtn.py
+11
-3
pydtn/pydtn/pydtn.yaml
pydtn/pydtn/pydtn.yaml
+26
-0
pydtn/requirements.txt
pydtn/requirements.txt
+1
-0
pydtn/setup.py
pydtn/setup.py
+1
-0
pydtn_rest/pydtn_rest/pydtn_rest.py
pydtn_rest/pydtn_rest/pydtn_rest.py
+11
-2
pydtn_rest/pydtn_rest/pydtn_rest.yaml
pydtn_rest/pydtn_rest/pydtn_rest.yaml
+26
-0
pydtn_rest/requirements.txt
pydtn_rest/requirements.txt
+1
-0
pydtn_rest/setup.py
pydtn_rest/setup.py
+1
-0
No files found.
.gitignore
View file @
0bca814d
...
...
@@ -4,3 +4,6 @@
__pycache__
*.swp
*.egg-info
# Log files
*.log
demo_app/main.py
View file @
0bca814d
...
...
@@ -8,7 +8,7 @@ from pydtn import start as bp_start
from
pydtn_rest
import
start
as
rest_start
logging
.
basicConfig
(
format
=
'
[%(asctime)s] %(levelname)s:
%(message)s'
,
level
=
logging
.
DEBUG
)
logging
.
basicConfig
(
format
=
'
%(asctime)s - [%(name)s] - [%(levelname)-5s] -
%(message)s'
,
level
=
logging
.
DEBUG
)
our_eid
=
None
...
...
pydtn/pydtn/pydtn.py
View file @
0bca814d
import
asyncio
import
logging
import
logging.config
import
pkg_resources
import
yaml
from
.bundle_protocol
import
bp_agent
from
.bundle_protocol.bp_node
import
set_bp_node_id
from
.bundle_protocol.convergence_layers.tcp_cl
import
TCPCLAdapter
logging
.
basicConfig
(
format
=
'[%(asctime)s] %(levelname)s: %(message)s'
,
level
=
logging
.
DEBUG
)
def
load_config
():
filename
=
pkg_resources
.
resource_filename
(
'pydtn'
,
'pydtn.yaml'
)
with
open
(
filename
,
'rt'
)
as
file
:
config
=
yaml
.
safe_load
(
file
.
read
())
return
config
def
start
(
node_id
,
tcp_port
):
def
start
(
node_id
,
tcp_port
,
config
=
load_config
()):
logging
.
config
.
dictConfig
(
config
[
'log'
])
set_bp_node_id
(
node_id
)
# Initialize TCP convergence layer adapter
...
...
pydtn/pydtn/pydtn.yaml
0 → 100644
View file @
0bca814d
# === LOGGING ===
log
:
version
:
1
formatters
:
standard
:
format
:
"
%(asctime)s
-
[%(name)s]
-
[%(levelname)-5s]
-
%(message)s"
handlers
:
console
:
class
:
logging.StreamHandler
level
:
DEBUG
formatter
:
standard
stream
:
ext://sys.stdout
file
:
class
:
logging.handlers.WatchedFileHandler
level
:
DEBUG
formatter
:
standard
filename
:
pydtn.log
root
:
level
:
DEBUG
handlers
:
[
console
,
file
]
loggers
:
pydtn
:
level
:
DEBUG
handlers
:
[
console
,
file
]
propogate
:
no
pydtn/requirements.txt
View file @
0bca814d
pyyaml~=3.13
cbor~=1.0.0
cbor2~=4.1.2
asyncio~=3.4.3
pydtn/setup.py
View file @
0bca814d
...
...
@@ -2,6 +2,7 @@ from setuptools import setup, find_packages
install_requires
=
[
'pyyaml>=3.13'
,
'cbor>=1.0.0'
,
'cbor2>=4.1.2'
,
'asyncio>=3.4.3'
,
...
...
pydtn_rest/pydtn_rest/pydtn_rest.py
View file @
0bca814d
import
logging
import
logging.config
from
aiohttp
import
web
import
pkg_resources
import
yaml
from
pydtn.bundle_protocol
import
bp_agent
from
pydtn.bundle_protocol.bp_node
import
get_bp_node_id
logging
.
basicConfig
(
format
=
'[%(asctime)s] %(levelname)s: %(message)s'
,
level
=
logging
.
DEBUG
)
def
load_config
():
filename
=
pkg_resources
.
resource_filename
(
'pydtn_rest'
,
'pydtn_rest.yaml'
)
with
open
(
filename
,
'rt'
)
as
file
:
config
=
yaml
.
safe_load
(
file
.
read
())
return
config
our_eid
=
None
...
...
@@ -47,7 +54,9 @@ async def handle_bundle(request):
return
web
.
json_response
({
'success'
:
True
})
def
start
(
port
,
host
=
'0.0.0.0'
):
def
start
(
port
,
host
=
'0.0.0.0'
,
config
=
load_config
()):
logging
.
config
.
dictConfig
(
config
[
'log'
])
global
bp_client
,
our_eid
our_eid
=
f'
{
get_bp_node_id
()
}
/web'
bp_client
=
bp_agent
.
register
(
our_eid
,
None
)
...
...
pydtn_rest/pydtn_rest/pydtn_rest.yaml
0 → 100644
View file @
0bca814d
# === LOGGING ===
log
:
version
:
1
formatters
:
standard
:
format
:
"
%(asctime)s
-
[%(name)s]
-
[%(levelname)-5s]
-
%(message)s"
handlers
:
console
:
class
:
logging.StreamHandler
level
:
DEBUG
formatter
:
standard
stream
:
ext://sys.stdout
file
:
class
:
logging.handlers.WatchedFileHandler
level
:
DEBUG
formatter
:
standard
filename
:
pydtn_rest.log
root
:
level
:
DEBUG
handlers
:
[
console
,
file
]
loggers
:
pydtn_rest
:
level
:
DEBUG
handlers
:
[
console
,
file
]
propogate
:
no
pydtn_rest/requirements.txt
View file @
0bca814d
pyyaml~=3.13
pydtn~=1.0.0
aiohttp~=3.5.4
pydtn_rest/setup.py
View file @
0bca814d
...
...
@@ -2,6 +2,7 @@ from setuptools import setup, find_packages
install_requires
=
[
'pyyaml>=3.13'
,
'pydtn>=1.0.0'
,
'aiohttp>=3.5.4'
,
]
...
...
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