File: exec.py

package info (click to toggle)
osslsigncode 2.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,148 kB
  • sloc: ansic: 11,997; python: 939; sh: 74; makefile: 12
file content (47 lines) | stat: -rw-r--r-- 1,274 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python3
"""Implementation of a single ctest script."""

import sys
from subprocess import Popen, PIPE


def parse(value):
    """Read parameter from file."""
    prefix = 'FILE '
    if value.startswith(prefix):
        with open(value[len(prefix):], mode="r", encoding="utf-8") as file:
            return file.read().strip()
    return value


def main() -> None:
    """Run osslsigncode with its options."""
    if len(sys.argv) > 1:
        try:
            params = map(parse, sys.argv[1:])
            proc = Popen(params, stdout=PIPE, stderr=PIPE, text=True)
            stdout, stderr = proc.communicate()
            print(stdout, file=sys.stderr)
            if stderr:
                print("Error:\n" + "-" * 58 + "\n" + stderr, file=sys.stderr)
            sys.exit(proc.returncode)
        except Exception as err: # pylint: disable=broad-except
            # all exceptions are critical
            print(err, file=sys.stderr)
    else:
        print("Usage:\n\t{} COMMAND [ARG]...'".format(sys.argv[0]), file=sys.stderr)
    sys.exit(1)


if __name__ == "__main__":
    main()


# pylint: disable=pointless-string-statement
"""Local Variables:
    c-basic-offset: 4
    tab-width: 4
    indent-tabs-mode: nil
End:
    vim: set ts=4 expandtab:
"""