/usr/bin/pyoptical is in python-pyoptical 0.4-1.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #!/usr/bin/python
#coding=utf-8
# : vim set filtype=python :
# Copyright (c) 2009-2012 Valentin Haenel <valentin.haenel@gmx.de>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
""" Command line wrapper for the pyoptical module. """
import pyoptical as pyop
from optparse import OptionParser
import sys
import time
from itertools import repeat
if __name__ == "__main__":
usage = "%prog [-i interval] [-n number ] [-r] com-port"
version = "%prog " + pyop.__version__
error_prefix = "pyoptical -- error:"
parser = OptionParser(usage=usage, version=version)
parser.add_option("-i", "--interval",
action="store",
type="float",
dest="interval",
default=0.0,
help="the measurement interval in ms, default is as fast as possible")
parser.add_option("-n", "--number",
action="store",
type="int",
dest="number",
default=None,
help="number of measurements to make, default is endless")
parser.add_option("-r", "--robust",
action="store_true",
dest="robust",
default=False,
help="when encountering an error, try to continue ignoring as many exceptions as possible")
opts, args = parser.parse_args()
if len(args) != 1:
parser.error("wrong number of arguments")
sys.exit(-1)
op = pyop.OptiCAL(args[0])
# this is a hack, either it executes opts.number times, or endlessly
for i in repeat(None) if opts.number is None else repeat(None, opts.number):
try:
print op.read_luminance()
time.sleep(opts.interval / 1000)
except pyop.OptiCALException, e:
sys.stderr.write(error_prefix + str(e) + "\n")
if opts.robust:
continue
else:
sys.exit(-1)
|