Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 39561
1
#!/usr/bin/python
2
3
import os, sys, time
4
5
if not 'SMC' in os.environ:
6
os.environ['SMC'] = os.path.join(os.environ['HOME'], '.smc')
7
8
SMC = os.environ['SMC']
9
if not os.path.exists(SMC):
10
os.makedirs(SMC)
11
12
# ensure that PATH starts with ~/bin, so user can customize what gets run
13
os.environ['PATH']="%s:%s"%(os.path.join(os.environ['HOME'], 'bin'), os.environ['PATH'])
14
15
def cmd(s):
16
print s
17
if os.system(s):
18
sys.exit(1)
19
20
def started():
21
return os.path.exists("%s/local_hub/local_hub.port"%SMC)
22
23
def main():
24
# concatenate all additional arguments and pass them to the node.js server
25
port_args = ' '.join(sys.argv[2:])
26
27
# Start local hub server
28
cmd("smc-local-hub start " + port_args)
29
30
i=0
31
while not started():
32
time.sleep(0.1)
33
i += 1
34
print i,
35
sys.stdout.flush()
36
if i >= 100:
37
sys.exit(1)
38
39
# Update the ~/.snapshots path symlinks
40
from update_snapshots import update_snapshots
41
update_snapshots()
42
43
if __name__ == "__main__":
44
main()
45
46