-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrelease.py
29 lines (23 loc) · 858 Bytes
/
release.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import subprocess
import os
import sys
def fatal(msg):
print(msg, file=sys.stderr)
exit(1)
if __name__ == "__main__":
os.chdir(os.path.dirname(os.path.realpath(__file__)))
if not os.path.exists("cod"):
fatal("cod binary is not found")
try:
clients_text = subprocess.check_output(["cod", "api", "list-clients"])
except subprocess.CalledProcessError:
subprocess.call(["killall", "cod"])
os.rename("cod", os.path.expanduser("~/.local/bin/cod"))
else:
subprocess.call(["killall", "cod"])
os.rename("cod", os.path.expanduser("~/.local/bin/cod"))
for line in clients_text.decode('utf-8').strip().split('\n'):
pid, shell = line.strip().split()
subprocess.check_call(["cod", "api", "attach", pid, shell])