def btn_LoadOnButtonClick(self, event): # TODO: Implement btn_LoadOnButtonClick validation_check = self.check_validation() if not validation_check: return # Check whether WaDE data to load if self.data_xml.__len__() <= 0: from viewer.Messages_forms.generalMsgDlg import messageDlg msg = "Warning!\n'Please click at the 'Retrieve Data' button." instance = messageDlg(None) instance.setMessage(msg) instance.ShowModal() instance.Destroy() return False #///////////////////////////////////////////////////////////////////////# self.btn_RetrieveData.Enabled = False self.btn_Load.Enabled = False # Show a msg to tell the user to wait. from viewer.Messages_forms.generalMsgDlg import messageDlg self.waiting_dlg = messageDlg(None) self.waiting_dlg.btn_OK.Shown = False self.waiting_dlg.Title = "Loading Data..." self.waiting_dlg.setMessage( "Please wait for Wizard to call and retrieve WaDE portal.\n It might take seconds to several minutes depending on the \n\tsize of the data" ) self.waiting_dlg.Show() #///////////////////////////////////////////////////////////////////////# # Start thread to load data our_thread = threading.Thread(None, self.load_data) our_thread.start()
def btn_ConvertCrossTabTimeSeriesToWaMDaMOnButtonClick(self, event): # TODO: Implement btn_ConvertCrossTabTimeSeriesToWaMDaMOnButtonClick define.logger = define.create_logger( self.cross_file.split('\\')[-1].split('.')[0]) define.logger.name = __name__ define.logger.info("Start time series data convert.") if self.cross_file: try: TimeSeriesDataShaper(workbook=self.cross_file) self.allDone() define.logger.info( "You successfully transformed the series data.") # self.Destroy() except Exception as e: define.logger.error('Failed time series data convert.\n' + e.message) from viewer.Messages_forms.generalMsgDlg import messageDlg msgDlg = messageDlg(None) msgDlg.SetTitle("Sorry: something went wrong") msgDlg.setMessage(e.message) # message = msg_somethigWrong(None, msg=u'{}, \n\n[*] Could not complete CrossTabulated Task'.format(e)) msgDlg.Show() else: from viewer.Messages_forms.msg_selectWorkbokFirst import msg_selectWorkbokFirst instance = msg_selectWorkbokFirst(None) result = instance.ShowModal() instance.Destroy()
def check_validation(self): # Check whether user select needed item correctly from viewer.Messages_forms.generalMsgDlg import messageDlg msg = "" if self.path is None or self.path == "": msg = "Warning!\n Please select a valid wml file." elif self.wml_str is None or self.wml_str == "": msg = "Warning!\n The selected file could not be opened. Please select a valid wml file." if msg != "": instance = messageDlg(None) instance.setMessage(msg) instance.ShowModal() instance.Destroy() return False #///////////////////////////////////////////////////////////////////////# # Check whether Sqlite db is connected. setup = DB_Setup() if not setup.get_session(): message = msg_somethigWrong( None, msg= '\n\n\nError, No Database connection found, Please first connect to a database.' ) message.ShowModal() return False #///////////////////////////////////////////////////////////////////////# return True
def btn_ConvertShapefileDataOnButtonClick(self, event): # TODO: Implement btn_ConvertShapefileDataOnButtonClick if self.shape_file: try: # Show a msg to tell the user to wait. from viewer.Messages_forms.generalMsgDlg import messageDlg self.waiting_dlg = messageDlg(None) self.waiting_dlg.btn_OK.Shown = False self.waiting_dlg.Title = "Loading Data..." self.waiting_dlg.setMessage( "Please wait a moment until loading is done.") self.waiting_dlg.Show() #///////////////////////////////////////////////////////////////////////# # Start thread to load data our_thread = threading.Thread(None, self.load_data) our_thread.start() #///////////////////////////////////////////////////////////////////////# # self.Destroy() except Exception as e: message = msg_somethigWrong( None, msg=u'{}, \n\n[*] Could not complete ShapeFile Task'. format(e)) message.Show() else: from viewer.Messages_forms.msg_selectWorkbokFirst import msg_selectWorkbokFirst instance = msg_selectWorkbokFirst(None) result = instance.ShowModal() instance.Destroy()
def check_validation(self): # Check whether user select needed items correctly from viewer.Messages_forms.generalMsgDlg import messageDlg msg = "" if self.comboBox_Code.Value is None or self.comboBox_Code.Value == "": msg = "Warning!\n'Site Code' field can not be empty. Please provide CUAHSI Site Code." elif self.comboBox_VariableCode.Value is None or self.comboBox_VariableCode.Value == "": msg = "Warning!\n'Variable Code' field can not be empty. Please provide CUAHSI Variable Code." elif self.m_textCtrl24.Value is None or self.m_textCtrl24.Value == "": msg = "Warning!\n'Time Series Begin Date' field can not be empty. Please provide Time Series Begin Date [yyyy-mm-dd]." elif self.m_textCtrl25.Value is None or self.m_textCtrl25.Value == "": msg = "Warning!\n'Time Series End Date' field can not be empty. Please provide Time Series End Date [yyyy-mm-dd]." if msg != "": instance = messageDlg(None) instance.setMessage(msg) instance.ShowModal() instance.Destroy() return False #///////////////////////////////////////////////////////////////////////# # Check whether Sqlite db is connected. setup = DB_Setup() if not setup.get_session(): message = msg_somethigWrong( None, msg= '\n\n\nError, No Database Found, Please first connect to a database.' ) message.ShowModal() return False #///////////////////////////////////////////////////////////////////////# return True
def btn_LoadOnButtonClick(self, event): # TODO: Implement btn_LoadOnButtonClick # Check whether user select needed items correctly validation_check = self.check_validation() if not validation_check: return self.btn_RetrieveData.Enabled = False self.btn_Load.Enabled = False # Show a msg to tell the user to wait. from viewer.Messages_forms.generalMsgDlg import messageDlg self.waiting_dlg = messageDlg(None) self.waiting_dlg.btn_OK.Shown = False self.waiting_dlg.Title = "Loading Data..." self.waiting_dlg.setMessage( "Please wait for Wizard to call and retrieve Water One Flow web-service.\nIt might take seconds to several minutes depending on the \n\tsize of the data. \n" "Warning!! this loader is inefficient and takes much longer than expected " ) self.waiting_dlg.btn_Cancel.Bind(wx.EVT_BUTTON, self.stop_loading) self.waiting_dlg.Show() #///////////////////////////////////////////////////////////////////////# # Start thread to load data self.our_thread = threading.Thread(None, self.load_data) self.our_thread.start()
def occuredError(self): from viewer.Messages_forms.generalMsgDlg import messageDlg instance = messageDlg(None) instance.setMessage(self.errorMsg.message) result = instance.ShowModal() instance.Destroy() self.msgDlg.Destroy() self.btn_LoadDataGroups.Enabled = True
def allDone(self): from viewer.Messages_forms.generalMsgDlg import messageDlg instance = messageDlg(None) instance.SetTitle(u"Successfully loaded data") # instance.Show() instance.setMessage(u"\n\nYou successfully loaded '" + self.cross_file.split('\\')[-1] + u"'.") result = instance.ShowModal() instance.Destroy() self.Destroy()
def allDone(self): self.waiting_dlg.Destroy() from viewer.Messages_forms.generalMsgDlg import messageDlg instance = messageDlg(None) instance.SetTitle(u"Successfully loaded data") # instance.Show() instance.setMessage( u"Conversion was Successful. Please find the results in the excel file '{}'." .format(self.shape_file)) result = instance.ShowModal() instance.Destroy() self.Destroy()
def btn_LoadRwiseFileOnButtonClick(self, event): # TODO: Implement btn_LoadRwiseFileOnButtonClick # Read data(string type) from wml file. f = open(self.path, 'r') self.wml_str = f.read() # print self.wml_str #/////////////////////////////////////////// if not self.check_validation(): return # Show a msg to tell the user to wait. from viewer.Messages_forms.generalMsgDlg import messageDlg self.waiting_dlg = messageDlg(None) self.waiting_dlg.btn_OK.Shown = False self.waiting_dlg.Title = "Loading Data..." self.waiting_dlg.setMessage( "Please wait a moment still loading is done.") self.waiting_dlg.btn_Cancel.Bind(wx.EVT_BUTTON, self.stop_loading) self.waiting_dlg.Show() #///////////////////////////////////////////////////////////////////////# # Start thread to load data self.our_thread = threading.Thread(None, self.load_data) self.our_thread.start()
def check_validation(self): # Check whether user select needed items correctly from viewer.Messages_forms.generalMsgDlg import messageDlg msg = "" if self.comboBox_State.Value == None or self.comboBox_State.Value == "": msg = "Warning!\n'State' field can not be empty. Please select a state." elif self.comboBox_PlanningBasin.Value == None or self.comboBox_PlanningBasin.Value == "": msg = "Warning!\n'Planing Basin' field can not be empty. Please select a planing basin." elif self.comboBox_year1.Value == None or self.comboBox_year1.Value == "": msg = "Warning!\n'Year' field can not be empty. Please select begining year." elif self.comboBox_year2.Value == None or self.comboBox_year2.Value == "": msg = "Warning!\n'Year' field can not be empty. Please select end year." elif int(self.comboBox_year1.Value) > int(self.comboBox_year2.Value): msg = "Warning!\n'End Year' must be more than 'Begining Year'. Please select again." if msg != "": instance = messageDlg(None) instance.setMessage(msg) instance.ShowModal() instance.Destroy() return False #///////////////////////////////////////////////////////////////////////# # Check whether Sqlite db is connected. setup = DB_Setup() if not setup.get_session(): message = msg_somethigWrong( None, msg= '\n\n\nError, No Database connection found, Please first connect to a database.' ) message.ShowModal() return False #///////////////////////////////////////////////////////////////////////# return True