Revision 8f39ec0d
b/snf-app/synnefo/ui/management/commands/link_static.py | ||
---|---|---|
62 | 62 |
for module, ns in STATIC_FILES.iteritems(): |
63 | 63 |
module = import_module(module) |
64 | 64 |
static_root = os.path.join(os.path.dirname(module.__file__), 'static') |
65 |
for f in os.listdir(static_root): |
|
66 |
symlinks.append((os.path.join(static_root, f), os.path.join(target, ns, f))) |
|
67 |
if not os.path.exists(os.path.join(target, ns)): |
|
68 |
dirs_to_create.add(os.path.join(target, ns)) |
|
69 | 65 |
|
70 |
return symlinks, dirs_to_create |
|
66 |
# no nested dir exists for the app |
|
67 |
if ns == '': |
|
68 |
for f in os.listdir(static_root): |
|
69 |
symlinks.append((os.path.join(static_root, f), os.path.join(target, ns, f))) |
|
70 |
|
|
71 |
# symlink whole app directory |
|
72 |
else: |
|
73 |
symlinks.append((os.path.join(static_root), os.path.join(target, ns))) |
|
74 |
|
|
75 |
return symlinks |
|
71 | 76 |
|
72 | 77 |
def handle(self, *args, **options): |
73 | 78 |
|
74 | 79 |
print "The following synlinks will get created" |
75 | 80 |
|
76 |
symlinks, dirs_to_create = self.collect_files(options['static_root'])
|
|
81 |
symlinks = self.collect_files(options['static_root']) |
|
77 | 82 |
for linkfrom, linkto in symlinks: |
78 | 83 |
print "Symlink '%s' to '%s' will get created." % (linkfrom, linkto) |
79 | 84 |
|
... | ... | |
83 | 88 |
Type 'yes' to continue, or 'no' to cancel: """) |
84 | 89 |
|
85 | 90 |
if confirm == "yes": |
86 |
for d in dirs_to_create: |
|
87 |
os.mkdir(d) |
|
88 |
|
|
89 | 91 |
for linkfrom, linkto in symlinks: |
90 | 92 |
print "Creating link from %s to %s" % (linkfrom, linkto) |
93 |
if os.path.exists(linkto): |
|
94 |
print "Skippig %s" % linkto |
|
95 |
continue |
|
96 |
|
|
91 | 97 |
os.symlink(linkfrom, linkto) |
92 | 98 |
|
Also available in: Unified diff