Skip to content
Snippets Groups Projects
Commit d0adbeec authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[ssr] python 2 and 3 compatibility, bob logger

parent 35ecdead
No related branches found
No related tags found
No related merge requests found
Pipeline #
#!/usr/bin/env python
# encoding: utf-8
# Copyright (c) 2017 Idiap Research Institute, http://www.idiap.ch/
# Written by Guillaume Heusch <guillaume.heusch@idiap.ch>,
#
# This file is part of bob.rpgg.base.
#
# bob.rppg.base is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# bob.rppg.base is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with bob.rppg.base. If not, see <http://www.gnu.org/licenses/>.
"""Pulse extractor for database videos (%(version)s)
"""Pulse extractor using 2SR algorithm (%(version)s)
Usage:
%(prog)s (cohface | hci) [--protocol=<string>] [--subset=<string> ...]
......@@ -68,15 +50,14 @@ Example:
See '%(prog)s --help' for more information.
"""
from __future__ import print_function
import os
import sys
import pkg_resources
import logging
__logging_format__='[%(levelname)s] %(message)s'
logging.basicConfig(format=__logging_format__)
logger = logging.getLogger("extract_log")
from bob.core.log import setup
logger = setup("bob.rppg.base")
from docopt import docopt
......@@ -110,19 +91,12 @@ def main(user_input=None):
arguments = sys.argv[1:]
prog = os.path.basename(sys.argv[0])
completions = dict(
prog=prog,
version=version,
)
args = docopt(
__doc__ % completions,
argv=arguments,
version='Signal extractor for videos (%s)' % version,
)
completions = dict(prog=prog, version=version,)
args = docopt(__doc__ % completions, argv=arguments, version='Signal extractor for videos (%s)' % version,)
# if the user wants more verbosity, lowers the logging level
if args['--verbose'] == 1: logging.getLogger("extract_log").setLevel(logging.INFO)
elif args['--verbose'] >= 2: logging.getLogger("extract_log").setLevel(logging.DEBUG)
from bob.core.log import set_verbosity_level
set_verbosity_level(logger, args['--verbose'])
# chooses the database driver to use
if args['cohface']:
......@@ -161,16 +135,20 @@ def main(user_input=None):
objects = db.objects(args['--protocol'], args['--subset'])
# if we are on a grid environment, just find what I have to process.
if os.environ.has_key('SGE_TASK_ID'):
sge = False
try:
sge = os.environ.has_key('SGE_TASK_ID') # python2
except AttributeError:
sge = 'SGE_TASK_ID' in os.environ # python3
if sge:
pos = int(os.environ['SGE_TASK_ID']) - 1
if pos >= len(objects):
raise RuntimeError, "Grid request for job %d on a setup with %d jobs" % \
(pos, len(objects))
raise RuntimeError("Grid request for job {} on a setup with {} jobs".format(pos, len(objects)))
objects = [objects[pos]]
if args['--gridcount']:
print len(objects)
sys.exit()
print(len(objects))
# the temporal stride
temporal_stride = int(args['--stride'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment