5 from planetstack.config import Config
13 from core.models import *
18 dep_data = open(Config().dependency_graph).read()
20 dep_data = open('/opt/planetstack/model-deps').read()
22 dependencies = json.loads(dep_data)
25 for k, lst in dependencies.items():
28 inv_dependencies[v].append(k)
30 inv_dependencies[v]=[k]
34 if (name.endswith('s')):
40 def walk_deps(fn, object):
41 model = object.__class__.__name__
43 deps = dependencies[model]
46 __walk_deps(fn, object, deps)
48 def walk_inv_deps(fn, object):
49 model = object.__class__.__name__
51 deps = inv_dependencies[model]
54 __walk_deps(fn, object, deps)
56 def __walk_deps(fn, object, deps):
57 model = object.__class__.__name__
60 #print "Checking dep %s"%dep
64 peer = getattr(object, link)
65 except AttributeError:
68 peer = getattr(object, link)
69 except AttributeError:
70 if not missing_links.has_key(model+'.'+link):
71 print "Model %s missing link for dependency %s"%(model, link)
72 missing_links[model+'.'+link]=True
76 peer_objects = peer.all()
80 for o in peer_objects:
82 # Uncomment the following line to enable recursion
83 # walk_inv_deps(fn, o)
86 print x,x.__class__.__name__
93 s = Site.objects.filter(login_base='onlab')
97 if __name__=='__main__':