forked from selcukercan/rpi-ros-kinetic-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlabels.py
executable file
·55 lines (43 loc) · 1.34 KB
/
labels.py
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
48
49
50
51
52
53
54
55
#!/usr/bin/env python
##
## Do not modify!
##
##
import datetime
import getpass
import json
import os
import platform
import subprocess
from collections import OrderedDict
def go():
labels = OrderedDict()
def add_label(lname, value):
labels[lname] = value
def run(x):
return subprocess.check_output(x)
_ = run(['git', 'status', '--porcelain', '--untracked-files=no'])
nmodified = len(_.strip().split('\n'))
_ = run(['git', 'status', '--porcelain'])
nadded = len(_.strip().split('\n'))
add_label('nmodified', nmodified)
add_label('nadded', nadded)
add_label('user', getpass.getuser())
add_label('platform_machine', platform.machine())
add_label('platform_node', platform.node())
# add_label('platform_release', platform.release())
add_label('platform_system', platform.system())
# add_label('platform_version', platform.version())
# add_label('platform_processor', platform.processor())
add_label('build_timestamp', datetime.datetime.now().isoformat())
d = os.path.basename(os.path.realpath(os.getcwd()))
prefix = 'duckietown/dt18/%s/' % d
args = []
for k, v in labels.items():
j = json.dumps(v)
k0 = prefix + k
args.append('--label')
args.append('%s=%s' % (k0, j))
print(" ".join(args))
if __name__ == '__main__':
go()