示例#1
0
文件: rest.py 项目: rmoorman/monitor
def _get_input(req, opt=None):
    args = parser.parse_args()
    args.name = sanitize_name(args.name)
    args.sensor = sanitize_name(args.sensor)
    args.sensors = [sanitize_name(sensor) for sensor in args.sensors] if args.sensors else None
    args.unit = sanitize_name(args.unit)

    if args.axis and args.axis not in the_axis.keys():
        abort(400, error="given axis is not permitted")

    cargs = dict((a, args[a]) for a in args if args[a] is not None)

    if not all([cargs.get(r) for r in req]):
        abort(400, error="please specify all required arguments", expected=req)
    if opt and not any([cargs.get(o) for o in opt]):
        abort(400, error="please specify at least one (optional) argument", expected=opt)

    return cargs
示例#2
0
文件: rest.py 项目: rmoorman/monitor
 def _chk_sens(s):
     return all([s.unit, s.unit.axis in the_axis.keys(), s.get_data().first()])