65d5b2da7538968414c193c635e2007e0b7ee15c
[platform/upstream/gstreamer.git] / common.py
1 import argparse
2 import subprocess
3
4 class Colors:
5     HEADER = '\033[95m'
6     OKBLUE = '\033[94m'
7     OKGREEN = '\033[92m'
8     WARNING = '\033[93m'
9     FAIL = '\033[91m'
10     ENDC = '\033[0m'
11
12     force_disable = False
13
14     @classmethod
15     def disable(cls):
16         cls.HEADER = ''
17         cls.OKBLUE = ''
18         cls.OKGREEN = ''
19         cls.WARNING = ''
20         cls.FAIL = ''
21         cls.ENDC = ''
22
23     @classmethod
24     def enable(cls):
25         if cls.force_disable:
26             return
27
28         cls.HEADER = '\033[95m'
29         cls.OKBLUE = '\033[94m'
30         cls.OKGREEN = '\033[92m'
31         cls.WARNING = '\033[93m'
32         cls.FAIL = '\033[91m'
33         cls.ENDC = '\033[0m'
34
35
36
37 def git(args, repository_path):
38     if not isinstance(args, list):
39         args = [args]
40
41     return subprocess.check_output(["git"] + args, cwd=repository_path,
42                                    stderr=subprocess.STDOUT).decode()
43
44