Path: blob/master/src/smc_pyutil/smc_pyutil/start_smc.py
Views: 285
#!/usr/bin/python1from __future__ import print_function, absolute_import23import os, sys, time45if not 'SMC' in os.environ:6os.environ['SMC'] = os.path.join(os.environ['HOME'], '.smc')78SMC = os.environ['SMC']9if not os.path.exists(SMC):10os.makedirs(SMC)1112# ensure that PATH starts with ~/bin, so user can customize what gets run13os.environ['PATH'] = "%s:%s" % (os.path.join(os.environ['HOME'],14'bin'), os.environ['PATH'])151617def cmd(s):18print(s)19if os.system(s):20sys.exit(1)212223def started():24return os.path.exists("%s/local_hub/local_hub.port" % SMC)252627def main():28# concatenate all additional arguments and pass them to the node.js server29port_args = ' '.join(sys.argv[2:])3031# Start local hub server32cmd("smc-local-hub start " + port_args)3334i = 035while not started():36time.sleep(0.1)37i += 138print(i, end=" ")39sys.stdout.flush()40if i >= 100:41sys.exit(1)424344if __name__ == "__main__":45main()464748