File: sample_process.py

package info (click to toggle)
doit 0.25.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,404 kB
  • ctags: 1,504
  • sloc: python: 11,084; makefile: 111; ansic: 14
file content (25 lines) | stat: -rw-r--r-- 720 bytes parent folder | download | duplicates (2)
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
#! /usr/bin/env python

# tests on CmdTask will use this script as an external process.
# 3 or more arguments. process return error exit (166)
# arguments "please fail". process return fail exit (11)
# first argument is sent to stdout
# second argument is sent to stderr

import sys

if __name__ == "__main__":
    # error
    if len(sys.argv) > 3:
        sys.exit(166)
    # fail
    if len(sys.argv) == 3 and sys.argv[1]=='please' and sys.argv[2]=='fail':
        sys.stdout.write("out ouch")
        sys.stderr.write("err output on failure")
        sys.exit(11)
    # ok
    if len(sys.argv) > 1:
        sys.stdout.write(sys.argv[1])
    if len(sys.argv) > 2:
        sys.stderr.write(sys.argv[2])
    sys.exit(0)