| 178 | | |
| | 178 | {{{ |
| | 179 | #!python |
| | 180 | import time |
| | 181 | import subprocess |
| | 182 | |
| | 183 | from PyQt4 import QtCore |
| | 184 | |
| | 185 | from papywizard.common import config |
| | 186 | from papywizard.common.loggingServices import Logger |
| | 187 | from papywizard.common.pluginManager import PluginManager |
| | 188 | from papywizard.hardware.abstractShutterPlugin import AbstractShutterPlugin |
| | 189 | from papywizard.controller.shutterPluginController import ShutterPluginController |
| | 190 | from papywizard.view.pluginFields import ComboBoxField, LineEditField, CheckBoxField |
| | 191 | |
| | 192 | |
| | 193 | class TetheredShutter(AbstractShutterPlugin): |
| | 194 | name = "Tethered" |
| | 195 | |
| | 196 | def _init(self): |
| | 197 | pass |
| | 198 | |
| | 199 | def _getTimeValue(self): |
| | 200 | return -1 |
| | 201 | |
| | 202 | def _getMirrorLockup(self): |
| | 203 | return self._config['MIRROR_LOCKUP'] |
| | 204 | |
| | 205 | def _getBracketingNbPicts(self): |
| | 206 | return self._config['BRACKETING_NB_PICTS'] |
| | 207 | |
| | 208 | def _getBracketingIntent(self): |
| | 209 | return self._config['BRACKETING_INTENT'] |
| | 210 | |
| | 211 | def _defineConfig(self): |
| | 212 | AbstractShutterPlugin._defineConfig(self) |
| | 213 | self._addConfigKey('_mirrorLockup', 'MIRROR_LOCKUP', default=False) |
| | 214 | self._addConfigKey('_mirrorLockupCommand', 'MIRROR_LOCKUP_COMMAND', default="") |
| | 215 | self._addConfigKey('_shootCommand', 'SHOOT_COMMAND', default="") |
| | 216 | self._addConfigKey('_bracketingNbPicts', 'BRACKETING_NB_PICTS', default=1) |
| | 217 | self._addConfigKey('_bracketingIntent', 'BRACKETING_INTENT', default='exposure') |
| | 218 | |
| | 219 | def activate(self): |
| | 220 | Logger().trace("TetheredShutter.activate()") |
| | 221 | |
| | 222 | def shutdown(self): |
| | 223 | Logger().trace("TetheredShutter.shutdown()") |
| | 224 | |
| | 225 | def lockupMirror(self): |
| | 226 | Logger().debug("TetheredShutter.lockupMirror(): execute command '%s'..." % self._config['MIRROR_LOCKUP_COMMAND']) |
| | 227 | time.sleep(1) |
| | 228 | Logger().debug("TetheredShutter.lockupMirror(): command over") |
| | 229 | return 0 |
| | 230 | |
| | 231 | def shoot(self, bracketNumber): |
| | 232 | Logger().debug("TetheredShutter.shoot(): execute command '%s'..." % self._config['SHOOT_COMMAND']) |
| | 233 | |
| | 234 | # Launch external command |
| | 235 | args = self._config['SHOOT_COMMAND'].split() |
| | 236 | p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| | 237 | |
| | 238 | # Wait end of execution |
| | 239 | stdout, stderr = p.communicate() |
| | 240 | if stderr: |
| | 241 | Logger().debug("TetheredShutter.shoot(): stderr:\n%s" % stderr) |
| | 242 | Logger().debug("TetheredShutter.shoot(): stdout:\n%s" % stdout) |
| | 243 | |
| | 244 | return p.returncode |
| | 245 | |
| | 246 | |
| | 247 | class TetheredShutterController(ShutterPluginController): |
| | 248 | def _defineGui(self): |
| | 249 | ShutterPluginController._defineGui(self) |
| | 250 | self._addWidget('Main', "Mirror lockup", CheckBoxField, (), 'MIRROR_LOCKUP') |
| | 251 | self._addWidget('Main', "Mirror lockup command", LineEditField, (), 'MIRROR_LOCKUP_COMMAND') |
| | 252 | self._addWidget('Main', "Shoot command", LineEditField, (), 'SHOOT_COMMAND') |
| | 253 | self._addWidget('Main', "Bracketing nb picts", SpinBoxField, (1, 99), 'BRACKETING_NB_PICTS') |
| | 254 | self._addWidget('Main', "Bracketing intent", ComboBoxField, (['exposure', 'focus', 'white balance', 'movement'],), 'BRACKETING_INTENT') |
| | 255 | |
| | 256 | |
| | 257 | def register(): |
| | 258 | """ Register plugins. |
| | 259 | """ |
| | 260 | PluginManager().register(TetheredShutter, TetheredShutterController) |
| | 261 | }}} |