Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
croft1
floodlight
Commits
2e496b82
Commit
2e496b82
authored
13 years ago
by
Mandeep Dhami
Browse files
Options
Downloads
Patches
Plain Diff
Updated jython server to use java logging (and made log object available to python code)
parent
bebc2642
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/net/floodlightcontroller/jython/Server.java
+9
-1
9 additions, 1 deletion
src/main/java/net/floodlightcontroller/jython/Server.java
src/main/python/debugserver.py
+21
-3
21 additions, 3 deletions
src/main/python/debugserver.py
with
30 additions
and
4 deletions
src/main/java/net/floodlightcontroller/jython/Server.java
+
9
−
1
View file @
2e496b82
package
net.floodlightcontroller.jython
;
import
java.net.URL
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.python.util.PythonInterpreter
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* This class starts a thread that runs a jython interpreter that
...
...
@@ -13,6 +16,8 @@ import org.python.util.PythonInterpreter;
*
*/
public
class
Server
extends
Thread
{
protected
static
Logger
log
=
LoggerFactory
.
getLogger
(
Server
.
class
);
int
port
;
Map
<
String
,
Object
>
locals
;
...
...
@@ -23,7 +28,10 @@ public class Server extends Thread {
public
Server
(
int
port_
,
Map
<
String
,
Object
>
locals_
)
{
this
.
port
=
port_
;
this
.
locals
=
locals_
;
if
(
this
.
locals
==
null
)
{
this
.
locals
=
new
HashMap
<
String
,
Object
>();
}
this
.
locals
.
put
(
"log"
,
Server
.
log
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/main/python/debugserver.py
+
21
−
3
View file @
2e496b82
...
...
@@ -6,6 +6,17 @@ from code import InteractiveConsole
_locals
=
None
class
DebugLogger
(
object
):
def
do_print
(
self
,
*
args
):
for
i
in
args
:
print
i
,
print
info
=
do_print
warn
=
do_print
debug
=
do_print
_log
=
DebugLogger
()
class
DebugConsole
(
InteractiveConsole
):
def
__init__
(
self
,
request
):
self
.
request
=
request
...
...
@@ -26,7 +37,7 @@ class DebugConsole(InteractiveConsole):
class
DebugServerHandler
(
BaseRequestHandler
):
def
__init__
(
self
,
request
,
client_address
,
server
):
print
'
Open connection to DebugServer from: %s
'
%
str
(
client_address
)
_log
.
debug
(
'
Open connection to DebugServer from: %s
'
%
str
(
client_address
)
)
BaseRequestHandler
.
__init__
(
self
,
request
,
client_address
,
server
)
def
handle
(
self
):
...
...
@@ -36,15 +47,22 @@ class DebugServerHandler(BaseRequestHandler):
self
.
request
.
close
()
class
DebugServer
(
TCPServer
):
daemon_threads
=
True
allow_reuse_address
=
True
def
handle_error
(
self
,
request
,
client_address
):
print
'
Closing connection to DebugServer from: %s
'
%
str
(
client_address
)
_log
.
debug
(
'
Closing connection to DebugServer from: %s
'
%
str
(
client_address
)
)
request
.
close
()
def
run_server
(
port
=
6655
,
host
=
'
0.0.0.0
'
,
locals
=
locals
()):
global
_locals
_locals
=
locals
print
"
Starting DebugServer on port %d
"
%
port
if
"
log
"
in
locals
.
keys
():
global
_log
_log
=
locals
[
"
log
"
]
_log
.
info
(
"
Starting DebugServer on port %d
"
%
port
)
server
=
DebugServer
((
''
,
port
),
DebugServerHandler
)
try
:
server
.
serve_forever
()
...
...
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