jack1 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.4KB

  1. import libjack
  2. import state
  3. import subprocess
  4. SESSION_PATH="/home/torbenh/jackSessions/"
  5. implicit_clients = ["system"]
  6. infra_clients = ["system"]
  7. sd = state.SessionDom( SESSION_PATH+"session.xml" )
  8. cl=libjack.JackClient("bla5")
  9. g=cl.get_graph()
  10. print sd.get_client_names()
  11. g.ensure_clientnames( sd.get_client_names() )
  12. # get graph again... renaming isnt prefect yet.
  13. g=cl.get_graph()
  14. # build up list of port connections
  15. conns = []
  16. for p in sd.get_port_names():
  17. for c in sd.get_connections_for_port( p ):
  18. conns.append( (p,c) )
  19. print conns
  20. # now fire up the processes
  21. children = []
  22. for cname in sd.get_client_names():
  23. cmd = sd.get_commandline_for_client( cname )
  24. children.append( subprocess.Popen( cmd, shell=True ) )
  25. avail_ports = g.get_port_list()
  26. # wait for ports to appear, and connect em.
  27. while len(conns) > 0:
  28. p = cl.port_queue.get()
  29. print p[0],p[1]
  30. pname = libjack.port_name(p[0])
  31. for c1 in conns:
  32. if c1[0]==pname:
  33. if c1[1] in avail_ports:
  34. cl.connect( pname, c1[1] )
  35. conns.remove( c1 )
  36. if (c1[1],c1[0]) in conns:
  37. conns.remove( (c1[1],c1[0]) )
  38. break
  39. if c1[1]==pname:
  40. if c1[0] in avail_ports:
  41. cl.connect( pname, c1[0] )
  42. conns.remove( c1 )
  43. if (c1[1],c1[0]) in conns:
  44. conns.remove( (c1[1],c1[0]) )
  45. break
  46. avail_ports.append( pname )
  47. print "session restored... exiting"
  48. cl.close()