-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
58 lines (48 loc) · 1.75 KB
/
setup.py
File metadata and controls
58 lines (48 loc) · 1.75 KB
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
56
57
58
#!/bin/env python3
import os
import sys
import json
import simplejson
import subprocess
sdir = os.path.dirname( os.path.realpath(__file__) )
wdir = os.path.relpath( os.path.join(sdir, '..', '..') )
cakedir = wdir
appdir = wdir + '/src'
with open(cakedir + '/composer.json') as f:
composerjson = simplejson.load(f)
execfile("config.py")
print("Notice: taking this as docroot: " + os.path.realpath ( cakedir ))
for symlink in symlinks:
ddir = os.path.dirname( symlink[1] )
sfile = symlink[0]
dsym = symlink[1]
if not os.path.isdir( ddir ):
print("Notice: directory not existant.. creating " + ddir)
os.makedirs(ddir)
if not os.path.isfile ( sfile ):
print("Error: source file not existant.. aborting at "+ sfile)
sys.exit()
if os.path.islink ( dsym ):
if os.path.realpath ( dsym ) != os.path.realpath ( sfile ):
print("Notice: incorrect symlink.. correcting " + sfile)
os.unlink ( dsym )
else:
continue
os.symlink( os.path.relpath(sfile, os.path.realpath(os.path.dirname(dsym))), dsym )
with open(cakedir + '/composer.json', 'w') as data_file:
data_file.write(simplejson.dumps(composerjson, indent=4, sort_keys=True))
command = ['/usr/bin/php', os.path.realpath(cakedir) + '/composer.phar','-d=' + os.path.realpath(cakedir), 'update']
subprocess.call(command)
for confline in lines_in_files:
line = confline[0]
dfile = confline[1]
found = False
with open(dfile) as search:
for tmpline in search:
tmpline = tmpline.rstrip()
if line == tmpline:
found = True
if not found:
with open(dfile, "a") as wfile:
wfile.write(line + '\n')
print("Added " + line + " to " + dfile)