diff --git a/dct_launch.py b/dct_launch.py index 0521c31334faeef8c0fd2f50367f5a4b20b295a9..745123f98bafe8c9b60f80d136e10830eb358489 100755 --- a/dct_launch.py +++ b/dct_launch.py @@ -28,7 +28,8 @@ class DCTLauncher(object): cmd = args[1] if cmd is "-h" or cmd is "--help": self.command = "help" - elif cmd in ("matlab", "update", "compile_mex", "compile_matlab", "update_conf"): + elif cmd in ("matlab", "update", "compile_mex", "compile_matlab", \ + "update_conf", "make"): self.command = cmd else: raise ValueError("Command '%s' not recognized" % cmd) @@ -51,6 +52,8 @@ class DCTLauncher(object): self._launchCompileMatlab() elif self.command == "update_conf": self._launchUpdateConf() + elif self.command == "make": + self._launchMake() else: raise ValueError("Not recognized command: %s" % self.command) @@ -130,6 +133,16 @@ class DCTLauncher(object): confexamplefile = os.path.join(self.dct_dir, "zUtil_Conf", "conf.example.xml") upd.safelyInstallNewFile(confexamplefile, "conf.xml") + def _launchMake(self): + if len(self.args) is 0: + raise ValueError("Not enough arguments") + + if self.args[0] == "install_zip": + builder = dct.dct_distrib.DCTMakeInstallBundle() + builder.run(self.dct_dir) + else: + raise ValueError("Unsupported make option: '%s'" % " ".join(self.args)) + def printHelp(self): print("\"%s\" launches dct or one of the maintenance routines in the DCT directory: \"%s\"" % (__file__, self.dct_dir) ) @@ -149,7 +162,9 @@ if __name__ == '__main__': try: launcher.run() - except SystemError as exc: - dct.dct_io_xml.DCTOutput.printError(exc.args) + except SystemError as ex: + dct.dct_io_xml.DCTOutput.printError(ex.args) print("Try running:\n # python %s update_conf" % __file__) + except ValueError as ex: + dct.dct_io_xml.DCTOutput.printError(ex.args) diff --git a/zUtil_Python/__init__.py b/zUtil_Python/__init__.py old mode 100644 new mode 100755 index 6f1af165ff2c34b1cb823f2eff33e704383d3414..884f9d5bd029f5ebc28bc8cb45a8d1493326bf50 --- a/zUtil_Python/__init__.py +++ b/zUtil_Python/__init__.py @@ -10,4 +10,6 @@ import dct_utils_git import dct_utils_platform import dct_compile_mex_functions -import dct_compile_matlab_functions \ No newline at end of file +import dct_compile_matlab_functions + +import dct_distrib diff --git a/zUtil_Python/dct_distrib.py b/zUtil_Python/dct_distrib.py new file mode 100755 index 0000000000000000000000000000000000000000..7327b75ce8d4c49c3715b57fdd5512aee05866b2 --- /dev/null +++ b/zUtil_Python/dct_distrib.py @@ -0,0 +1,32 @@ +''' +Created on Feb 4, 2013 + +@author: ben +''' + +import os +import zipfile + +class DCTMakeInstallBundle(object): + + def __init__(self, *args, **kwargs): + object.__init__(self, *args, **kwargs) + + def run(self, dct_dir): + currentDir = os.getcwd() + os.chdir(os.path.join(dct_dir, "zUtil_Python")) + + destFile = os.path.join(currentDir, "DCT_install.zip") + zfid = zipfile.ZipFile(destFile, mode = "w") + try: + zfid.write('dct_compile_matlab_functions.py') + zfid.write('dct_compile_mex_functions.py') + zfid.write('dct_io_xml.py') + zfid.write('dct_utils_git.py') + zfid.write('dct_utils_platform.py') + zfid.write('dct_setup.py') + finally: + zfid.close() + + print("Created file: %s" % destFile) + os.chdir(currentDir)