chdir to the root to run modelgen or dmdot
diff --git a/xos/tools/apigen/modelgen b/xos/tools/apigen/modelgen
index 63cf5b7..72cce08 100644
--- a/xos/tools/apigen/modelgen
+++ b/xos/tools/apigen/modelgen
@@ -184,7 +184,17 @@
print 'Usage: modelgen [options] <template_fn>'
exit(1)
- output = args[0]
+ template_name = os.path.abspath(args[0])
+
+ # try to make sure we're running from the right place
+ if (not os.path.exists("core")):
+ if (os.path.exists("../core")):
+ os.chdir("..")
+ elif (os.path.exists("../../core")):
+ os.chdir("../..")
+ else:
+ print >> sys.stderr, "Are you sure you're running modelgen from the root of an XOS installation"
+ sys.exit(-1)
generator = Generator()
@@ -194,7 +204,7 @@
generator.add_object(m)
generator.compute_links()
- template_contents = open(output).read()
+ template_contents = open(template_name).read()
template = Template(template_contents)
context = Context({'generator':generator})
print template.render(context)
diff --git a/xos/tools/dmdot b/xos/tools/dmdot
index 9507749..a57c0b1 100755
--- a/xos/tools/dmdot
+++ b/xos/tools/dmdot
@@ -11,6 +11,14 @@
from django.db.models.fields.related import ForeignKey
+# try to make sure we're running from the right place
+if (not os.path.exists("core")):
+ if (os.path.exists("../core")):
+ os.chdir("..")
+ else:
+ print >> sys.stderr, "Are you sure you're running dmdot from the root of an XOS installation"
+ sys.exit(-1)
+
# defaults
apps = ["core", "services.hpc", "services.cord", "services.requestrouter", "services.onos"]
output = "-json"