Ejemplo n.º 1
0
def main():
    # Connect to LASH if Python bindings are available, and the user did not
    # pass --no-lash
    if lash and not '--no-lash' in sys.argv:
        # sys.argv is modified by this call
        lash_client = lash.init(sys.argv, "jack_mixer", lash.LASH_Config_File)
    else:
        lash_client = None

    parser = OptionParser(usage='usage: %prog [options] [jack_client_name]')
    parser.add_option('-c',
                      '--config',
                      dest='config',
                      help='use a non default configuration file')
    # --no-lash here is not acted upon, it is specified for completeness when
    # --help is passed.
    parser.add_option('--no-lash',
                      dest='nolash',
                      action='store_true',
                      help='do not connect to LASH')
    options, args = parser.parse_args()

    # Yeah , this sounds stupid, we connected earlier, but we dont want to show this if we got --help option
    # This issue should be fixed in pylash, there is a reason for having two functions for initialization after all
    if lash_client:
        server_name = lash.lash_get_server_name(lash_client)
        if server_name:
            print "Successfully connected to LASH server at " + server_name
        else:
            # getting the server name failed, probably not worth trying to do
            # further things with as a lash client.
            lash_client = None

    if len(args) == 1:
        name = args[0]
    else:
        name = None

    if not name:
        name = "jack_mixer"

    try:
        mixer = JackMixer(name, lash_client)
    except Exception, e:
        err = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
                                gtk.BUTTONS_OK,
                                "Mixer creation failed (%s)" % str(e))
        err.run()
        err.destroy()
        sys.exit(1)
Ejemplo n.º 2
0
def main():
    # Connect to LASH if Python bindings are available, and the user did not
    # pass --no-lash
    if lash and not '--no-lash' in sys.argv:
        # sys.argv is modified by this call
        lash_client = lash.init(sys.argv, "jack_mixer", lash.LASH_Config_File)
    else:
        lash_client = None

    parser = OptionParser(usage='usage: %prog [options] [jack_client_name]')
    parser.add_option('-c',
                      '--config',
                      dest='config',
                      help='use a non default configuration file')
    # --no-lash here is not acted upon, it is specified for completeness when
    # --help is passed.
    parser.add_option('--no-lash',
                      dest='nolash',
                      action='store_true',
                      help='do not connect to LASH')
    options, args = parser.parse_args()

    # Yeah , this sounds stupid, we connected earlier, but we dont want to show this if we got --help option
    # This issue should be fixed in pylash, there is a reason for having two functions for initialization after all
    if lash_client:
        server_name = lash.lash_get_server_name(lash_client)
        if server_name:
            print("Successfully connected to LASH server at " + server_name)
        else:
            # getting the server name failed, probably not worth trying to do
            # further things with as a lash client.
            lash_client = None

    if len(args) == 1:
        name = args[0]
    else:
        name = None

    if not name:
        name = "jack_mixer"

    try:
        mixer = JackMixer(name, lash_client)
    except Exception as e:
        err = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL,
                                Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
                                "Mixer creation failed (%s)" % str(e))
        err.run()
        err.destroy()
        sys.exit(1)

    if options.config:
        f = open(options.config)
        mixer.current_filename = options.config
        try:
            mixer.load_from_xml(f)
        except:
            err = Gtk.MessageDialog(mixer.window, Gtk.DialogFlags.MODAL,
                                    Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
                                    "Failed loading settings.")
            err.run()
            err.destroy()
        mixer.window.set_default_size(
            60 * (1 + len(mixer.channels) + len(mixer.output_channels)), 300)
        f.close()

    mixer.main()

    mixer.cleanup()
Ejemplo n.º 3
0
        elif event_type == lash.LASH_Restore_File:
            print("LASH ordered to restore data from directory %s" %
                  lash.lash_event_get_string(event))
            lash.lash_event_destroy(event)
        else:
            print("Got unhandled LASH event, type " + str(event_type))
            lash.lash_event_destroy(event)
            return True

        event = lash.lash_get_event(lash_client)

    return True


# sys.argv is modified by this call
lash_client = lash.init(sys.argv, "pylash test",
                        lash.LASH_Config_Data_Set | lash.LASH_Terminal)
if not lash_client:
    print("Cannot connect to LASH server")
    sys.exit(1)

print("Successfully connected to LASH server at " +
      lash.lash_get_server_name(lash_client))

# Send our client name to server
lash_event = lash.lash_event_new_with_type(lash.LASH_Client_Name)
lash.lash_event_set_string(lash_event, "pylash test")
lash.lash_send_event(lash_client, lash_event)

# loop until we receive quit order from LASH server
while lash_check_events(lash_client):
    time.sleep(1)
Ejemplo n.º 4
0
Archivo: test.py Proyecto: LADI/ladish
            print "LASH ordered to restore data"
            lash.lash_event_destroy(event)
        elif event_type == lash.LASH_Restore_File:
            print "LASH ordered to restore data from directory %s" % lash.lash_event_get_string(event)
            lash.lash_event_destroy(event)
        else:
            print "Got unhandled LASH event, type " + str(event_type)
            lash.lash_event_destroy(event)
            return True

        event = lash.lash_get_event(lash_client)

    return True

# sys.argv is modified by this call
lash_client = lash.init(sys.argv, "pylash test", lash.LASH_Config_Data_Set | lash.LASH_Terminal)
if not lash_client:
    print "Cannot connect to LASH server"
    sys.exit(1)

print "Successfully connected to LASH server at " +  lash.lash_get_server_name(lash_client)

# Send our client name to server
lash_event = lash.lash_event_new_with_type(lash.LASH_Client_Name)
lash.lash_event_set_string(lash_event, "pylash test")
lash.lash_send_event(lash_client, lash_event)

# loop until we receive quit order from LASH server
while lash_check_events(lash_client):
    time.sleep(1)