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
8af6bb07
Commit
8af6bb07
authored
13 years ago
by
Mandeep Dhami
Browse files
Options
Downloads
Patches
Plain Diff
Changed jarpath to work in eclipse and dev env as well
parent
8f9fea7a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/net/floodlightcontroller/jython/Server.java
+25
-1
25 additions, 1 deletion
src/main/java/net/floodlightcontroller/jython/Server.java
with
25 additions
and
1 deletion
src/main/java/net/floodlightcontroller/jython/Server.java
+
25
−
1
View file @
8af6bb07
package
net.floodlightcontroller.jython
;
import
java.net.URL
;
import
java.util.Map
;
import
org.python.util.PythonInterpreter
;
/**
* This class starts a thread that runs a jython interpreter that
* can be used for debug (or even development).
*
* @author mandeepdhami
*
*/
public
class
Server
extends
Thread
{
int
port
;
Map
<
String
,
Object
>
locals
;
/**
* @param port_ Port to use for jython server
* @param locals_ Locals to add to the interpreters top level name space
*/
public
Server
(
int
port_
,
Map
<
String
,
Object
>
locals_
)
{
this
.
port
=
port_
;
this
.
locals
=
locals_
;
}
/**
* The main thread for this class invoked by Thread.run()
*
* @see java.lang.Thread#run()
*/
public
void
run
()
{
PythonInterpreter
p
=
new
PythonInterpreter
();
for
(
String
name
:
this
.
locals
.
keySet
())
{
p
.
set
(
name
,
this
.
locals
.
get
(
name
));
}
String
jarPath
=
Server
.
class
.
getProtectionDomain
().
getCodeSource
().
getLocation
().
getPath
();
URL
jarUrl
=
Server
.
class
.
getProtectionDomain
().
getCodeSource
().
getLocation
();
String
jarPath
=
jarUrl
.
getPath
();
if
(
jarUrl
.
getProtocol
().
equals
(
"file"
))
{
// If URL is of type file, assume that we are in dev env and set path to python dir.
// else use the jar file as is
jarPath
=
jarPath
+
"../../src/main/python/"
;
}
p
.
exec
(
"import sys"
);
p
.
exec
(
"sys.path.append('"
+
jarPath
+
"')"
);
p
.
exec
(
"from debugserver import run_server"
);
...
...
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