Package elisa :: Package core :: Module common
[hide private]
[frames] | no frames]

Source Code for Module elisa.core.common

 1  # -*- coding: utf-8 -*- 
 2  # Elisa - Home multimedia server 
 3  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
 4  # All rights reserved. 
 5  # 
 6  # This file is available under one of two license agreements. 
 7  # 
 8  # This file is licensed under the GPL version 3. 
 9  # See "LICENSE.GPL" in the root of this distribution including a special 
10  # exception to use Elisa with Fluendo's plugins. 
11  # 
12  # The GPL part of Elisa is also available under a commercial licensing 
13  # agreement from Fluendo. 
14  # See "LICENSE.Elisa" in the root directory of this distribution package 
15  # for details on that license. 
16   
17  """ 
18  This module provides access to the singleton application and a L{boot} 
19  function which initializes the global application execution 
20  environment. 
21   
22  @var  application: the Elisa application 
23  @type application: L{elisa.core.application.Application} 
24  @var booted:       has execution environment been initialized by calling L{boot}? 
25  @type booted:      bool 
26  """ 
27   
28  __maintainer__ = 'Philippe Normand <philippe@fluendo.com>' 
29   
30  import sys 
31   
32  application = None 
33   
34 -def set_application(app):
35 """ 36 Set the L{application} singleton's value. Overrides previous value. 37 38 @param app: the new singleton's value 39 @type app: L{Application} 40 """ 41 global application 42 application = app
43 44 booted = False 45 from_test = False 46
47 -def boot():
48 """ 49 Initializes the global application execution. Can't be called more 50 than once. 51 52 - install Twisted's glib2reactor 53 - initialize the logging framework 54 - clean namespace regarding pygst import 55 56 """ 57 global booted 58 global from_test 59 log_to_file = False 60 61 if not booted: 62 #FIXME : BAD HACK to disable the reactor installation in test mode 63 if not from_test: 64 try: 65 #FIXME glib2reactor does not works with unittest 66 from twisted.internet import glib2reactor 67 glib2reactor.install() 68 except AssertionError: 69 pass 70 71 from elisa.core import log 72 73 if 'gst' in sys.modules: 74 del sys.modules['gst'] 75 76 import pygst 77 pygst.require('0.10') 78 79 if '-l' in sys.argv: 80 log_to_file = True 81 82 log.init(log_to_file) 83 log.logTwisted() 84 85 booted = True
86