Module generateXSDataCommon
[hide private]
[frames] | no frames]

Source Code for Module generateXSDataCommon

 1  #!/usr/bin/env python 
 2  # coding: utf8  
 3  # 
 4  #    Project: EDNA-Kernel 
 5  #             http://www.edna-site.org 
 6  # 
 7  #    File: "$Id:$" 
 8  # 
 9  #    Copyright (C) ESRF 
10  # 
11  #    Principal author:       Jerome Kieffer 
12  # 
13  #    Contributing authors:    
14  # 
15  #    This program is free software: you can redistribute it and/or modify 
16  #    it under the terms of the GNU General Public License as published by 
17  #    the Free Software Foundation, either version 3 of the License, or 
18  #    (at your option) any later version. 
19  # 
20  #    This program is distributed in the hope that it will be useful, 
21  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
22  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
23  #    GNU General Public License for more details. 
24  # 
25  #    You should have received a copy of the GNU General Public License 
26  #    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
27  # 
28  import os, sys, subprocess, tempfile 
29   
30  xsDataName = "XSDataCommon.edml" 
31   
32  if "EDNA_HOME" not in os.environ: 
33      full_path = os.path.abspath(sys.argv[0]) 
34      while True: 
35          old_path = full_path 
36          full_path = os.path.dirname(old_path) 
37          if old_path == full_path: 
38              print("Something weird is happening: I did not find the EDNA_ROOT !!!") 
39              sys.exit(1) 
40          if  os.path.isdir(os.path.join(full_path, "kernel", "datamodel")): 
41              EDNA_HOME = full_path 
42              os.environ["EDNA_HOME"] = full_path 
43              break 
44  else: 
45      EDNA_HOME = os.environ["EDNA_HOME"] 
46   
47  xsdHomeDir = os.path.dirname(os.path.abspath(sys.argv[0])) 
48   
49  cmdLine = ["java", "-jar"] 
50  cmdLine.append(os.path.join(EDNA_HOME, "kernel", "datamodel", "EDGenerateDS.jar")) 
51  cmdLine.append("-includepaths") 
52  cmdLine.append(os.path.join(EDNA_HOME, "kernel", "datamodel")) 
53  cmdLine.append("-sourceDir") 
54  cmdLine.append(xsdHomeDir) 
55  cmdLine.append("-sourceFile") 
56  cmdLine.append(xsDataName) 
57  cmdLine.append("-targetdir") 
58  cmdLine.append(os.path.join(os.path.dirname(xsdHomeDir), "src")) 
59  sub = subprocess.Popen(cmdLine, cwd=tempfile.gettempdir()) 
60  print("Java code for data-binding finished with exit code %s" % sub.wait()) 
61