| Generates schema diagrams for Django apps. Just run the script with no |
| arguments. If you don't have them installed, you'll need "dot" from the |
| Graphviz package and Django. |
| ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) |
| for project, app in PROJECTS: |
| settings = 'autotest_lib.%s.settings' % project |
| os.environ['DJANGO_SETTINGS_MODULE'] = settings |
| # import after setting DJANGO_SETTINGS_MODULE |
| from autotest_lib.contrib import modelviz |
| # hack to force reload of settings and app list |
| from django.db.models import loading |
| print 'Analyzing', project |
| dot_contents = modelviz.generate_dot([app]) |
| dot_path = project + '.dot' |
| dotfile = open(dot_path, 'w') |
| dotfile.write(dot_contents) |
| png_path = project + '.png' |
| os.system('dot -Tpng -o %s %s' % (png_path, dot_path)) |
| print 'Generated', png_path |
| del os.environ['DJANGO_SETTINGS_MODULE'] |
| if __name__ == '__main__': |