forked from pulp-platform/pulpissimo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ipstools_cfg.py
47 lines (38 loc) · 1.2 KB
/
ipstools_cfg.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
#!/usr/bin/env python3
# Francesco Conti <[email protected]>
#
# Copyright (C) 2016-2018 ETH Zurich, University of Bologna.
# All rights reserved.
# switch to "[email protected]" if you have an SSH public key deployed on GitHub
# and you want to push things there
DEFAULT_SERVER = "https://github.com"
#################################
## DO NOT EDIT BELOW THIS LINE ##
#################################
import sys,os,subprocess
devnull = open(os.devnull, 'wb')
class tcolors:
OK = '\033[92m'
WARNING = '\033[93m'
ERROR = '\033[91m'
ENDC = '\033[0m'
def execute(cmd, silent=False):
if silent:
stdout = devnull
else:
stdout = None
return subprocess.call(cmd.split(), stdout=stdout)
def execute_out(cmd, silent=False):
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
out, err = p.communicate()
return out
# download latest IPApproX tools in ./ipstools and import them
if os.path.exists("ipstools") and os.path.isdir("ipstools"):
cwd = os.getcwd()
os.chdir("ipstools")
execute("git pull", silent=True)
os.chdir(cwd)
import ipstools
else:
execute("git clone https://github.com/pulp-platform/IPApproX ipstools")
import ipstools