root / py / maugis / scenic / runner.py @ e21a6d08
History | View | Annotate | Download (1.8 kB)
| 1 |
#!/usr/bin/env python
|
|---|---|
| 2 |
# -*- coding: utf-8 -*-
|
| 3 |
#
|
| 4 |
# Scenic
|
| 5 |
# Copyright (C) 2008 Société des arts technologiques (SAT)
|
| 6 |
# http://www.sat.qc.ca
|
| 7 |
# All rights reserved.
|
| 8 |
#
|
| 9 |
# This file is free software: you can redistribute it and/or modify
|
| 10 |
# it under the terms of the GNU General Public License as published by
|
| 11 |
# the Free Software Foundation, either version 2 of the License, or
|
| 12 |
# (at your option) any later version.
|
| 13 |
#
|
| 14 |
# Scenic is distributed in the hope that it will be useful,
|
| 15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 |
# GNU General Public License for more details.
|
| 18 |
#
|
| 19 |
# You should have received a copy of the GNU General Public License
|
| 20 |
# along with Scenic. If not, see <http://www.gnu.org/licenses/>.
|
| 21 |
|
| 22 |
"""
|
| 23 |
Main of the application. |
| 24 |
"""
|
| 25 |
import sys |
| 26 |
from optparse import OptionParser |
| 27 |
from twisted.internet import gtk2reactor |
| 28 |
gtk2reactor.install() # has to be done before importing reactor
|
| 29 |
from twisted.internet import reactor |
| 30 |
from twisted.internet import error |
| 31 |
from twisted.python import log |
| 32 |
|
| 33 |
from scenic import application |
| 34 |
from scenic import version |
| 35 |
|
| 36 |
def start_logging_to_stdout(): |
| 37 |
log.startLogging(sys.stdout) |
| 38 |
|
| 39 |
def run(): |
| 40 |
# command line parsing
|
| 41 |
parser = OptionParser(usage="%prog", version=str(version.__version__)) |
| 42 |
parser.add_option("-k", "--kiosk", action="store_true", help="Run in kiosk mode") |
| 43 |
parser.add_option("-f", "--fullscreen", action="store_true", help="Run in fullscreen mode") |
| 44 |
(options, args) = parser.parse_args() |
| 45 |
start_logging_to_stdout() |
| 46 |
try:
|
| 47 |
app = application.Application(kiosk_mode=options.kiosk, fullscreen=options.fullscreen) |
| 48 |
except error.CannotListenError, e:
|
| 49 |
print("There must be an other Scenic running.")
|
| 50 |
print(str(e))
|
| 51 |
else:
|
| 52 |
try:
|
| 53 |
reactor.run() |
| 54 |
except KeyboardInterrupt: |
| 55 |
pass
|
