
import os,sys
import java

class launcher:
   def __init__(self):
          self.system = os._getOsType()
          print 'system= '+self.system
          self.osName = java.lang.System.getProperty("os.name")
          print 'OS name= '+self.osName
          self.platform=sys.platform
          print 'JVM= '+self.platform
          self.javaHome = java.lang.System.getProperty("java.home")
          print 'Java home= '+ self.javaHome
          self.JyConsoleHome= os.getcwd()
          print 'JyConsole Home= '+self.JyConsoleHome

          self.setScripts()


   def perform(self, inputCmd):
         os.system(inputCmd)


   def setScripts(self):

        # for Mac OS X
        self.OSXSettingScript = {}
        self.OSXCmd = "java -cp JyConsole.jar:ThirdPart/ArtTk.jar:ThirdPart/jython-2.1/jython.jar com.artenum.jyconsole.JyConsole"

        # for embeded Linux version
        self.LinuxSettingScript = {}
        self.LinuxCmd = "java -cp JyConsole.jar:ThirdPart/ArtTk.jar:ThirdPart/jython-2.1/jython.jar com.artenum.jyconsole.JyConsole"

        # for windows 
        self.winSettingScript = {}
        self.winCmd = 'java -cp "JyConsole.jar;ThirdPart\\ArtTk.jar;ThirdPart\\jython-2.1\\jython.jar" com.artenum.jyconsole.JyConsole'


   if __name__ == "__main__":
      
       from run import launcher
 
       lh = launcher()

       if (lh.system == "posix"):
          if(lh.osName == "Mac OS X"):
              settingScript = lh.OSXSettingScript
              launchCmd = lh.OSXCmd 
          elif(lh.osName == "Linux"):
              settingScript = lh.LinuxSettingScript
              launchCmd = os.path.join(lh.javaHome, 'bin', lh.LinuxCmd)

       else:
              settingScript = lh.winSettingScript
              #launchCmd = os.path.join(lh.javaHome, "bin", lh.winCmd)
              launchCmd = lh.winCmd
              print launchCmd

       # now we start the action
       for key in settingScript.keys():
              os.environ[key]=settingScript[key]
       os.system(launchCmd)

