Running Python code from Java program, shoudl i be doing this?

Posted by Space Rocker on Stack Overflow See other posts from Stack Overflow or by Space Rocker
Published on 2012-09-28T09:36:24Z Indexed on 2012/09/28 9:37 UTC
Read the original article Hit count: 232

Filed under:
|
|

i have a scenario where i draw a network and set all it's paraments on swing based gui, after that i have to translate this network into a python based script which another framework reads and realize this network in the form of virtual machines.

As an example have look here:

from mininet.topo import Topo, Node
class MyTopo( Topo ):
    def *__init__*( self, enable_all = True ):
        super( MyTopo, self ).__init__()
        Host = 1
        Switch = 2
        self.add_node( Switch, Node( is_switch=True ) )
        self.add_node( Host, Node( is_switch=False ) )
        self.add_edge( Host, Switch )
        self.enable_all()
topos = { 'mytopo': ( lambda: MyTopo() ) }

It simply connects a host to a switch and realize this topology on mininet framework.
Now for now in order to realize the drawn network on java GUI here is what i am doing:

I simply take the information from GUI and creates a new python file like the one above using java code and then run this file in mininet, which works fine somehow.

I want to know, is this the correct and robust way how i am doing this or should i be looking further into java-python bridge like scenarios to be more effective or so as to say more professional.

© Stack Overflow or respective owner

Related posts about java

Related posts about python