Example #1
0
def start_file_logging(identifier="lunchrc", directory="/var/tmp/lunch", log_level='info'):
    """
    Starts logging the Master infos to a file.
    @rettype: str
    """
    global log
    file_name = "master-%s.log" % (identifier)
    if not os.path.exists(directory):
        os.makedirs(directory)
    full_path = os.path.join(directory, file_name)
    f = open(full_path, 'w')
    f.close()
    os.chmod(full_path, 0600)
    #_log_file = logfile.BaseLogFile(file_name, directory)
    #_log_file = logfile.DailyLogFile(file_name, directory) #FIXME: do not use that DailyLogFile ! 
    #log.startLogging(_log_file)
    full_path = os.path.join(directory, file_name)
    log = logger.start(level=log_level, name=LOG_NAME, to_stdout=True, to_file=True, log_file_name=full_path)
    return full_path #_log_file.path
Example #2
0
 def __init__(self, app=None, scene_id="default", spinviewer_fps=30):
     global log
     self.app = app
     self.user_id = self.app.config.user_id
     self.scene_id = scene_id
     self.has_ever_started_viewer = False
     self.spinviewer_fps = spinviewer_fps
     unique_master_id = "spinic"
     log_dir = master.DEFAULT_LOG_DIR
     log_level = 'warning'
     if self.app.config.verbose:
         log_level = 'info'
     if self.app.config.debug:
         log_level = 'debug'
     master.start_logging(log_level=log_level)
     log = logger.start(name="launching")
     pid_file = master.write_master_pid_file(identifier=unique_master_id, directory=log_dir)
     # might raise a RuntimeError:
     self.lunch_master = master.Master(log_dir=log_dir, pid_file=pid_file, verbose=True)
     self.lunch_gui = gui.start_gui(self.lunch_master)
     self._start()
Example #3
0
import sys
import os
import textwrap
import webbrowser
from lunch import __version__
from lunch import dialogs
from lunch.states import *
from lunch import logger


#TODO: i18nize
def _(value):
    return value


log = logger.start(name="lunch-gui")

__license__ = _("""Lunch
Copyright (C) 2009 Society for Arts and Technology (SAT)
http://www.sat.qc.ca
All rights reserved.

This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

Lunch is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
Example #4
0
import gtk
import pango
import sys
import os
import textwrap
import webbrowser
from lunch import __version__
from lunch import dialogs
from lunch.states import *
from lunch import logger

#TODO: i18nize
def _(value):
    return value

log = logger.start(name="lunch-gui")

__license__ = _("""Lunch
Copyright (C) 2009 Society for Arts and Technology (SAT)
http://www.sat.qc.ca
All rights reserved.

This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

Lunch is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
Example #5
0
def start_stdout_logging(log_level='info'):
    #log.startLogging(sys.stdout)
    global log
    log = logger.start(level=log_level, name=LOG_NAME, to_stdout=True, to_file=False)
Example #6
0
"""
from twisted.trial import unittest
from twisted.internet import defer
from twisted.python import failure
from twisted.internet import reactor
from lunch import master
from lunch import commands
from lunch.states import *

LOG_LEVEL = "warning"
#LOG_LEVEL = "info"
#LOG_LEVEL = "debug"

master.start_stdout_logging(LOG_LEVEL)
from lunch import logger
log = logger.start(name="test")

#TODO: add the path to lunch-slave to $PATH

class Test_Master(unittest.TestCase):
    timeout = 4.0 # so that we don't wait in case of a problem
    def test_read_config(self):
        pass
    test_read_config.skip = "TODO."

    def test_add_remove_command(self):
        COMMAND_IDENTIFER = "test"
        COMMAND_LINE = "man man"
        _deferred = defer.Deferred()
        _master = master.Master()
        self.the_command = None
Example #7
0
#!/usr/bin/env python
"""
Tools to parse the config file. (for the cameras)
"""
import os
import json
assert(json.loads) # need Python >= 2.6
import glob
from lunch import logger
from spinic import audioconnector

log = logger.start(name="cameras")

SHM_PREFIX = "spinic-"

class CamerasConfig(object):
    """
    System-wide configuration for the cameras, as read in the cameras config file.
    """
    def __init__(self):
        # default values:
        self.receiveraddress = "127.0.0.1"
        self.videosource = "videotestsrc" # "dc1394src"
        self.videocodec = "h263"
        self.videobitrate = 75000
        self.framerate = 15
        self.grayscale = True
        self.height = 480
        self.width = 640
        self.display = ":0.0"
        self.user_audio_src = 1 # as seen by pd [adc] Must be unique for each spinics in a scene.
Example #8
0
#!/usr/bin/env python
"""
Manages JACK routing configuration with jack.plumbing
"""

import os
from lunch import logger
from twisted.internet import defer
from twisted.internet import reactor
from twisted.python import procutils
from twisted.internet import utils

if __name__ == "__main__":
    log = logger.start(name="plumberjack", to_stdout=True, level="debug")
else:
    log = logger.start(name="plumberjack")

def jack_disconnect(source, sink):
    """
    Calls jack_disconnect with the given arguments.
    Returns a Deferred
    """
    deferred = defer.Deferred()
    def _cb(result):
        if type(result) != int:
            lor.error("The result of calling jack_disconnect should be an int.")
        log.info("jack_disconnect result: " + str(result))
        if result == 0:
            deferred.callback(True)
        else:
            deferred.callback(False)
Example #9
0
#!/usr/bin/env python
"""
Tools to parse the SPIN framework config file.
"""
import os
from lunch import logger

if __name__ == "__main__":
    log = logger.start(name="spindefaults", to_stdout=True, level="debug")
else:
    class DummyLogger(object):
        def debug(self, s):
            pass
            # print("Debug:" + str(s))
        def info(self, s):
            pass
            # print("info:" + str(s))
        def error(self, s):
            print("Error:" + str(s))
    log = DummyLogger() # FIXME: that's bad! The logging does not work in this module, since we need to start it before starting the main logging in lunch. This should be fixed.

def read_spin_defaults():
    """
    Returns a dict of defaults parameters for spinframework.
    (ports number and multicast group)
    """
    file_name = "spinFramework/spinDefaults.h"
    prefixes = ["/usr/local", "/usr"]
    is_found = False
    for prefix in prefixes:
        full_path = os.path.join(prefix, "include", file_name)
Example #10
0
"""
Audio connections manager for Spinic.

Uses plumberjack.py
"""
from spinic import plumberjack
from lunch import logger
from twisted.internet import defer

log = logger.start(name="audioconnector")

class AudioConnector(object):
    """
    Manages audio connections with JACK for spinic. (SPIN and Milhouse)
    """
    def __init__(self, app):
        self.app = app
        self.plumber = plumberjack.PlumberJack()
        
        self._plug_input_to_every_sender()
        self._plug_pd_outputs()
        self._connect_signals()

    def _connect_signals(self):
        self.app.osc_interface.connected_to_scene_signal.connect(self.on_connected_to_scene)
        self.app.osc_interface.start_streaming_with_user_signal.connect(self.on_start_streaming_with_user)
        self.app.osc_interface.stopped_streaming_with_user_signal.connect(self.on_stopped_streaming_with_user)

    def _plug_input_to_every_sender(self):
        name = "to_all_milhouse" 
Example #11
0
#!/usr/bin/env python
"""
The Spinic GUI
"""
import os
import sys
import tempfile
if __name__ == "__main__": # just a reminder
    from twisted.internet import gtk2reactor
    gtk2reactor.install()
from twisted.internet import reactor
import gtk
from lunch import logger

log = logger.start(name='spinic_gui')

PACKAGE_DATA = "./data"
APP_NAME = "spinic"
GLADE_FILE_NAME = "spinic.glade"

def set_model_from_list(cb, items):
    """
    Set up a ComboBox or ComboBoxEntry based on a list of strings.
    
    @type cb: L{gtk.ComboBox}
    @type items: C{list}
    """
    model = gtk.ListStore(str)
    for i in items:
        model.append([i])
    cb.set_model(model)
Example #12
0
from twisted.trial import unittest
from twisted.internet import defer
from twisted.python import failure
from twisted.internet import reactor
from lunch import master
from lunch import commands
from lunch.states import *

LOG_LEVEL = "warning"
#LOG_LEVEL = "info"
#LOG_LEVEL = "debug"

master.start_stdout_logging(LOG_LEVEL)
from lunch import logger

log = logger.start(name="test")

#TODO: add the path to lunch-slave to $PATH


class Test_Master(unittest.TestCase):
    timeout = 4.0  # so that we don't wait in case of a problem

    def test_read_config(self):
        pass

    test_read_config.skip = "TODO."

    def test_add_remove_command(self):
        COMMAND_IDENTIFER = "test"
        COMMAND_LINE = "man man"