| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | |
|---|
| 3 | """ Panohead remote control. |
|---|
| 4 | |
|---|
| 5 | License |
|---|
| 6 | ======= |
|---|
| 7 | |
|---|
| 8 | - B{Papywizard} (U{http://www.papywizard.org}) is Copyright: |
|---|
| 9 | - (C) 2007-2009 Frédéric Mantegazza |
|---|
| 10 | |
|---|
| 11 | This software is governed by the B{CeCILL} license under French law and |
|---|
| 12 | abiding by the rules of distribution of free software. You can use, |
|---|
| 13 | modify and/or redistribute the software under the terms of the CeCILL |
|---|
| 14 | license as circulated by CEA, CNRS and INRIA at the following URL |
|---|
| 15 | U{http://www.cecill.info}. |
|---|
| 16 | |
|---|
| 17 | As a counterpart to the access to the source code and rights to copy, |
|---|
| 18 | modify and redistribute granted by the license, users are provided only |
|---|
| 19 | with a limited warranty and the software's author, the holder of the |
|---|
| 20 | economic rights, and the successive licensors have only limited |
|---|
| 21 | liability. |
|---|
| 22 | |
|---|
| 23 | In this respect, the user's attention is drawn to the risks associated |
|---|
| 24 | with loading, using, modifying and/or developing or reproducing the |
|---|
| 25 | software by the user in light of its specific status of free software, |
|---|
| 26 | that may mean that it is complicated to manipulate, and that also |
|---|
| 27 | therefore means that it is reserved for developers and experienced |
|---|
| 28 | professionals having in-depth computer knowledge. Users are therefore |
|---|
| 29 | encouraged to load and test the software's suitability as regards their |
|---|
| 30 | requirements in conditions enabling the security of their systems and/or |
|---|
| 31 | data to be ensured and, more generally, to use and operate it in the |
|---|
| 32 | same conditions as regards security. |
|---|
| 33 | |
|---|
| 34 | The fact that you are presently reading this means that you have had |
|---|
| 35 | knowledge of the CeCILL license and that you accept its terms. |
|---|
| 36 | |
|---|
| 37 | Module purpose |
|---|
| 38 | ============== |
|---|
| 39 | |
|---|
| 40 | Configurations. |
|---|
| 41 | |
|---|
| 42 | @author: Frédéric Mantegazza |
|---|
| 43 | @copyright: (C) 2007-2009 Frédéric Mantegazza |
|---|
| 44 | @license: CeCILL |
|---|
| 45 | """ |
|---|
| 46 | |
|---|
| 47 | __revision__ = "$Id$" |
|---|
| 48 | |
|---|
| 49 | import sys |
|---|
| 50 | import os.path |
|---|
| 51 | |
|---|
| 52 | # Version |
|---|
| 53 | VERSION_MAJOR = 2 |
|---|
| 54 | VERSION_MINOR = 1 # Odd means dev. release |
|---|
| 55 | VERSION_UPDATE = 15 |
|---|
| 56 | VERSION = "%d.%d.%d" % (VERSION_MAJOR, VERSION_MINOR, VERSION_UPDATE) |
|---|
| 57 | VERSION_XML = "b" |
|---|
| 58 | |
|---|
| 59 | # Paths |
|---|
| 60 | HOME_DIR = os.path.expanduser("~") |
|---|
| 61 | if sys.platform == 'win32': |
|---|
| 62 | USER_CONFIG_DIR = os.path.join(os.path.expandvars("$APPDATA"), "papywizard2") |
|---|
| 63 | DATA_STORAGE_DIR = HOME_DIR # Find a way to retreive the "My Documents" dir in all languages |
|---|
| 64 | TMP_DIR = os.path.expandvars("$TEMP") |
|---|
| 65 | else: |
|---|
| 66 | USER_CONFIG_DIR = os.path.join(HOME_DIR, ".config", "papywizard2") # OpenDesktop standard |
|---|
| 67 | try: |
|---|
| 68 | import hildon |
|---|
| 69 | DATA_STORAGE_DIR = os.path.join(HOME_DIR, "MyDocs") |
|---|
| 70 | except ImportError: |
|---|
| 71 | DATA_STORAGE_DIR = HOME_DIR |
|---|
| 72 | TMP_DIR = "/tmp" |
|---|
| 73 | USER_PLUGINS_DIR = os.path.join(USER_CONFIG_DIR, "plugins") |
|---|
| 74 | try: |
|---|
| 75 | #os.makedirs(USER_CONFIG_DIR) |
|---|
| 76 | os.makedirs(USER_PLUGINS_DIR) |
|---|
| 77 | except OSError, (errno, errmsg): |
|---|
| 78 | if errno in (17, 183): # dir already exists |
|---|
| 79 | pass |
|---|
| 80 | else: |
|---|
| 81 | raise |
|---|
| 82 | CONFIG_FILE = "papywizard.conf" |
|---|
| 83 | USER_CONFIG_FILE = os.path.join(USER_CONFIG_DIR, CONFIG_FILE) |
|---|
| 84 | PRESET_FILE = "presets.xml" |
|---|
| 85 | USER_PRESET_FILE = os.path.join(USER_CONFIG_DIR, PRESET_FILE) |
|---|
| 86 | if VERSION_MINOR % 2: |
|---|
| 87 | USER_GUIDE_URL = "http://www.papywizard.org/wiki/UserGuideSvn" |
|---|
| 88 | else: |
|---|
| 89 | USER_GUIDE_URL = "http://www.papywizard.org/wiki/UserGuide2.x" |
|---|
| 90 | STYLESHEET_FILE = "papywizard.css" |
|---|
| 91 | USER_STYLESHEET_FILE = os.path.join(USER_CONFIG_DIR, STYLESHEET_FILE) |
|---|
| 92 | SPLASHCREEN_FILE = "splashscreen.png" |
|---|
| 93 | |
|---|
| 94 | # Model |
|---|
| 95 | SENSOR_RATIOS = {'3:2': 3./2., '4:3': 4./3., '5:4': 5./4., '16:9': 16./9.} |
|---|
| 96 | |
|---|
| 97 | # View |
|---|
| 98 | COLOR_SCHEME = 'default' |
|---|
| 99 | ALPHA = 224 |
|---|
| 100 | SHOOTING_COLOR_SCHEME = {'default': {'background': (224, 224, 224, 255), |
|---|
| 101 | 'head': (0, 0, 255, 255), |
|---|
| 102 | 'border': (64, 64, 64, ALPHA), |
|---|
| 103 | 'preview': (128, 128, 128, ALPHA), |
|---|
| 104 | 'preview-next': (255, 255, 0, ALPHA), |
|---|
| 105 | 'preview-toshoot': (160, 160, 160, ALPHA), |
|---|
| 106 | 'ok': (0, 255, 0, ALPHA), |
|---|
| 107 | 'ok-next': (255, 255, 0, ALPHA), |
|---|
| 108 | 'ok-toshoot': (160, 255, 160, ALPHA), |
|---|
| 109 | 'invalid': (160, 0, 255, ALPHA), |
|---|
| 110 | 'invalid-next': (255, 255, 0, ALPHA), |
|---|
| 111 | 'invalid-toshoot': (255, 160, 255, ALPHA), |
|---|
| 112 | 'error': (255, 0, 0, ALPHA), |
|---|
| 113 | 'error-next': (255, 255, 0, ALPHA), |
|---|
| 114 | 'error-toshoot': (255, 160, 160, ALPHA), |
|---|
| 115 | }, |
|---|
| 116 | 'dark': {'background': (32, 32, 32, 255), |
|---|
| 117 | 'head': (0, 0, 128, 255), |
|---|
| 118 | 'border': (160, 160, 160, ALPHA), |
|---|
| 119 | 'preview': (64, 64, 64, ALPHA), |
|---|
| 120 | 'preview-next': (128, 128, 0, ALPHA), |
|---|
| 121 | 'preview-toshoot': (96, 96, 96, ALPHA), |
|---|
| 122 | 'ok': (0, 128, 0, ALPHA), |
|---|
| 123 | 'ok-next': (128, 128, 0, ALPHA), |
|---|
| 124 | 'ok-toshoot': (96, 160, 96, ALPHA), |
|---|
| 125 | 'invalid': (96, 0, 160, ALPHA), |
|---|
| 126 | 'invalid-next': (128, 64, 255, ALPHA), |
|---|
| 127 | 'invalid-toshoot': (128, 96, 0, ALPHA), |
|---|
| 128 | 'error': (160, 0, 0, ALPHA), |
|---|
| 129 | 'error-next': (128, 128, 0, ALPHA), |
|---|
| 130 | 'error-toshoot': (128, 96, 96, ALPHA), |
|---|
| 131 | } |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | # GUI index for controller |
|---|
| 135 | HEAD_ORIENTATION_INDEX = {'up': 0, 'left': 1, 'right': 2, 'down': 3, |
|---|
| 136 | 0: 'up', 1: 'left', 2: 'right', 3: 'down'} |
|---|
| 137 | CAMERA_ORIENTATION_INDEX = {'portrait': 0, 'landscape': 1, 'custom': 2, |
|---|
| 138 | 0: 'portrait', 1: 'landscape', 2: 'custom'} |
|---|
| 139 | MOSAIC_START_FROM_INDEX = {'top-left': 0, 'top-right': 1, 'bottom-left': 2, 'bottom-right': 3, |
|---|
| 140 | 0: 'top-left', 1 : 'top-right', 2: 'bottom-left', 3: 'bottom-right'} |
|---|
| 141 | MOSAIC_INITIAL_DIR_INDEX = {'yaw': 0, 'pitch': 1, |
|---|
| 142 | 0: 'yaw', 1: 'pitch'} |
|---|
| 143 | SENSOR_RATIO_INDEX = {'3:2': 0, '4:3': 1, '5:4': 2, '16:9': 3, |
|---|
| 144 | 0: '3:2', 1: '4:3', 2: '5:4', 3: '16:9'} |
|---|
| 145 | LENS_TYPE_INDEX = {'rectilinear': 0, 'fisheye': 1, |
|---|
| 146 | 0: 'rectilinear', 1: 'fisheye'} |
|---|
| 147 | DRIVER_INDEX = {'bluetooth': 0, 'serial': 1, 'ethernet': 2, |
|---|
| 148 | 0: 'bluetooth', 1: 'serial', 2: 'ethernet'} |
|---|
| 149 | LOGGER_INDEX = {'trace': 0, 'debug': 1, 'info': 2, 'warning' :3, 'error': 4, 'exception': 5, 'critical': 6, |
|---|
| 150 | 0: 'trace', 1: 'debug', 2: 'info', 3: 'warning', 4: 'error', 5: 'exception', 6: 'critical'} |
|---|
| 151 | |
|---|
| 152 | # Logger |
|---|
| 153 | LOGGER_FORMAT = "%(asctime)s::%(threadName)s::%(levelname)s::%(message)s" |
|---|
| 154 | LOGGER_MAX_COUNT_LINE = 1000 |
|---|
| 155 | LOGGER_FILENAME = "papywizard.log" |
|---|
| 156 | LOGGER_MAX_BYTES = 100 * 1024 |
|---|
| 157 | LOGGER_BACKUP_COUNT = 3 |
|---|
| 158 | |
|---|
| 159 | # Hardware |
|---|
| 160 | BLUETOOTH_DRIVER_CONNECT_DELAY = 8. |
|---|
| 161 | SERIAL_BAUDRATE = 9600 |
|---|
| 162 | |
|---|
| 163 | # Spy |
|---|
| 164 | SPY_REFRESH_DELAY = 200 # ms |
|---|
| 165 | |
|---|
| 166 | # Low-level simulator |
|---|
| 167 | SIMUL_DEFAULT_CONNEXION = 'ethernet' |
|---|
| 168 | SIMUL_DEFAULT_SERIAL_PORT = "/dev/ttyS0" |
|---|
| 169 | #SIMUL_DEFAULT_SERIAL_PORT = "COM1" |
|---|
| 170 | SIMUL_DEFAULT_ETHERNET_HOST = "127.0.0.1" |
|---|
| 171 | SIMUL_DEFAULT_ETHERNET_PORT = 7165 |
|---|
| 172 | SIMUL_DEFAULT_LOGGER_LEVEL = 'debug' |
|---|