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.

74 lines
1.4KB

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