def run(self): try: print "Begin to download web template ..." self.dl = UrlDownload(self.caller.siteUrl) self.dl.execute() print "End to download web template" if self.caller.isCopyToTomcat: print "Begin to copy template to tomcat ..." try: clientdir = os.path.join(self.caller.TOMCAT_HOME, r"webapps\np\clients", self.caller.instanceName) print "Copy from %s to %s" % (self.dl.resultPath, clientdir) if os.path.exists(clientdir): shutil.rmtree(clientdir) shutil.copytree(self.dl.resultPath, clientdir) except: print "[ERROR] Copy template to tomcat failed. From %s to %s" % (self.dl.resultPath, clientdir) print "End to copy template to tomcat" if self.caller.isAddDataSource: print "Begin to add datasource ..." try: mysqlds.mysql_ds_file = os.path.join(self.caller.JBOSS_HOME, r"server\default\deploy\mysql-ds.xml") mysqlds.add_datasource(self.caller.instanceName, self.caller.dbHost, self.caller.dbPort, self.caller.dbName) except: print "[ERROR] Add datasource failed." print "End to add datasource" print "======================================" print "Finish." print "======================================" wx.CallAfter(self.caller.OnFinish) except Exception as e: wx.CallAfter(self.caller.handleException, (e,))
def OnDownload(self, evt): if not self.GetValue(): return try: self.executeBtn.Disable() print "Begin to download web template ..." #dl = UrlDownload(self.siteUrl) #dl.execute() threadDown = ThreadDownload(self) threadDown.setDaemon(True) threadDown.start() while True: time.sleep(10) self.queue.put(time.asctime()) if not threadDown.isAlive(): break threadDown.join() print "End to download web template" if self.isCopyToTomcat: print "Begin to copy template to tomcat ..." try: clientdir = os.path.join(self.TOMCAT_HOME, r"webapps\np\clients", self.instanceName) if os.path.exists(clientdir): shutil.rmtree(clientdir) os.makedirs(clientdir) shutil.copytree(dl.resultFolder, clientdir) except: print "[ERROR] Copy template to tomcat failed. From %s to %s" % ( dl.resultFolder, clientdir) print "End to copy template to tomcat" if self.isAddDataSource: print "Begin to add datasource ..." try: mysqlds.mysql_ds_file = os.path.join( self.JBOSS_HOME, r"server\default\deploy\mysql-ds.xml") mysqlds.add_datasource(self.instanceName, self.dbHost, self.dbPort, self.dbName) except: print "[ERROR] Add datasource failed." print "End to add datasource" self.MessageBox("Finish!") self.executeBtn.Enable() except Exception, e: self.executeBtn.Enable() print e self.MessageBox("Failed! Some errors occur." + e.message)
def OnDownload(self, evt): if not self.GetValue(): return try: self.executeBtn.Disable() print "Begin to download web template ..." #dl = UrlDownload(self.siteUrl) #dl.execute() threadDown = ThreadDownload(self) threadDown.setDaemon(True) threadDown.start() while True: time.sleep(10) self.queue.put(time.asctime()) if not threadDown.isAlive(): break threadDown.join() print "End to download web template" if self.isCopyToTomcat: print "Begin to copy template to tomcat ..." try: clientdir = os.path.join(self.TOMCAT_HOME, r"webapps\np\clients", self.instanceName) if os.path.exists(clientdir): shutil.rmtree(clientdir) os.makedirs(clientdir) shutil.copytree(dl.resultFolder, clientdir) except: print "[ERROR] Copy template to tomcat failed. From %s to %s" % (dl.resultFolder, clientdir) print "End to copy template to tomcat" if self.isAddDataSource: print "Begin to add datasource ..." try: mysqlds.mysql_ds_file = os.path.join(self.JBOSS_HOME, r"server\default\deploy\mysql-ds.xml") mysqlds.add_datasource(self.instanceName, self.dbHost, self.dbPort, self.dbName) except: print "[ERROR] Add datasource failed." print "End to add datasource" self.MessageBox("Finish!") self.executeBtn.Enable() except Exception, e: self.executeBtn.Enable() print e self.MessageBox("Failed! Some errors occur." + e.message)
def run(self): try: print "Begin to download web template ..." self.dl = UrlDownload(self.caller.siteUrl) self.dl.execute() print "End to download web template" if self.caller.isCopyToTomcat: print "Begin to copy template to tomcat ..." try: clientdir = os.path.join(self.caller.TOMCAT_HOME, r"webapps\np\clients", self.caller.instanceName) print "Copy from %s to %s" % (self.dl.resultPath, clientdir) if os.path.exists(clientdir): shutil.rmtree(clientdir) shutil.copytree(self.dl.resultPath, clientdir) except: print "[ERROR] Copy template to tomcat failed. From %s to %s" % ( self.dl.resultPath, clientdir) print "End to copy template to tomcat" if self.caller.isAddDataSource: print "Begin to add datasource ..." try: mysqlds.mysql_ds_file = os.path.join( self.caller.JBOSS_HOME, r"server\default\deploy\mysql-ds.xml") mysqlds.add_datasource(self.caller.instanceName, self.caller.dbHost, self.caller.dbPort, self.caller.dbName) except: print "[ERROR] Add datasource failed." print "End to add datasource" print "======================================" print "Finish." print "======================================" wx.CallAfter(self.caller.OnFinish) except Exception as e: wx.CallAfter(self.caller.handleException, (e, ))