Scott Baker | 8899be9 | 2015-08-04 17:02:29 -0700 | [diff] [blame] | 1 | import os |
| 2 | import sys |
| 3 | |
Scott Baker | 8899be9 | 2015-08-04 17:02:29 -0700 | [diff] [blame] | 4 | # add the parent directory to sys.path |
| 5 | import os,sys,inspect |
| 6 | currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) |
| 7 | parentdir = os.path.dirname(currentdir) |
| 8 | sys.path.append(parentdir) |
| 9 | |
Scott Baker | 1c5fc47 | 2015-09-23 21:13:50 -0700 | [diff] [blame] | 10 | # a bit of a hack for developing -- run m4 to generate xos.yaml from xos.m4 |
| 11 | os.system("m4 %s/custom_types/xos.m4 > %s/custom_types/xos.yaml" % (currentdir, currentdir)) |
| 12 | |
Scott Baker | 8899be9 | 2015-08-04 17:02:29 -0700 | [diff] [blame] | 13 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings") |
| 14 | import django |
| 15 | django.setup() |
| 16 | |
| 17 | from core.models import User |
| 18 | from tosca.engine import XOSTosca |
| 19 | |
| 20 | def main(): |
| 21 | if len(sys.argv)<3: |
| 22 | print "Syntax: destroy.py <username> <yaml-template-name>" |
| 23 | sys.exit(-1) |
| 24 | |
| 25 | username = sys.argv[1] |
| 26 | template_name = sys.argv[2] |
| 27 | |
| 28 | u = User.objects.get(email=username) |
| 29 | |
Scott Baker | e08b456 | 2015-08-11 17:23:52 -0700 | [diff] [blame] | 30 | xt = XOSTosca(file(template_name).read(), parent_dir=currentdir, log_to_console=True) |
Scott Baker | 8899be9 | 2015-08-04 17:02:29 -0700 | [diff] [blame] | 31 | xt.destroy(u) |
| 32 | |
| 33 | if __name__=="__main__": |
| 34 | main() |