def checkBranch(): """ Standalone update call """ _str_func = 'checkBranch' log.debug("|{0}| >> ...".format(_str_func)) try: var_lastUpdate except: var_lastUpdate = cgmMeta.cgmOptionVar('cgmVar_branchLastUpdate', defaultValue=['']) _lastUpdate = var_lastUpdate.getValue() var_lastUpdate.report() if _lastUpdate == 'None': return log.error("No last update found. Can't check for updates") _lastBranch = _lastUpdate[0] try: _lastHash = _lastUpdate[1] except: _lastHash = None try: _lastMsg = _lastUpdate[2] except: _lastMsg = None try: _lastDate = _lastUpdate[3] except: _lastDate = None #Get our dat from the server _d_serverDat = cgmUpdate.get_dat(_lastBranch, 1, True) _targetHash = _d_serverDat[0].get('hash') _targetMsg = _d_serverDat[0].get('msg') _targetDate = _d_serverDat[0].get('date') if _d_serverDat[0]['hash'] == _lastHash: return log.info( "No update necessary. Branch [{0}] Up to date! Last update: {2} | Hash: [{1}]" .format(_lastBranch, _lastHash, _lastDate)) result = mc.confirmDialog( title="Update your local cgmTools...", message= 'Are you sure you want to get and update to build: \n Last update: {0} \n [{1}] | [{2}] \n \n {3} \n \n Target updated: {4} \n [{1}] | [{5}] \n \n {6}' .format(_lastDate, _lastBranch, _lastHash, _lastMsg, _targetDate, _targetHash, _targetMsg), messageAlign='center', button=['OK', 'Cancel'], #text = self.value, defaultButton='OK', cancelButton='Cancel', dismissString='Cancel') if result == 'OK': log.debug("|{0}| >> go!".format(_str_func)) try: cgmUpdate.here(_branch, 0) var_lastUpdate.setValue([ _branch, _targetHash, _targetMsg, datetime.datetime.now().__str__()[:-7] ]) except Exception, err: print err finally:
def uiFunc_updateMyStuff(self): _str_func = 'uiFunc_updateMyStuff' log.debug("|{0}| >> ...".format(_str_func)) if self.uiRC_commits.getSelectedIndex() == None: return log.error("No commit selected.") try: self.var_lastUpdate except: self.var_lastUpdate = cgmMeta.cgmOptionVar( 'cgmVar_branchLastUpdate', defaultValue=['None']) _branch = self.var_branchMode.value _idx = self.uiRC_commits.getSelectedIndex() _d = self.dat_commits[_idx] _hash = _d['hash'] _msg = _d['msg'] _lastBranch = None _lastHash = None _lastUpdate = self.var_lastUpdate.getValue() or None if _lastUpdate and _lastUpdate[0] != 'None': try: _lastBranch = _lastUpdate[0] except: pass try: _lastHash = _lastUpdate[1] except: pass try: _lastMsg = _lastUpdate[2] except: pass try: _lastDate = _lastUpdate[3] except: _lastDate = None result = mc.confirmDialog( title="Update your local cgmTools...", message= 'Are you sure you want to get and update to build? \n Last update: {4} \n Selected: [{0}] | [{1}] \n Last: [{2}] | [{3}]' .format(_branch, _hash, _lastBranch, _lastHash, _lastDate), messageAlign='center', button=['OK', 'Cancel'], #text = self.value, defaultButton='OK', cancelButton='Cancel', dismissString='Cancel') if result == 'OK': log.debug("|{0}| >> go!".format(_str_func)) try: cgmUpdate.here(_branch, _idx) self.var_lastUpdate.setValue([ _branch, _hash, _msg, datetime.datetime.now().__str__()[:-7] ]) self.uiUpdate_topReport() except Exception, err: pprint.pprint(vars()) finally: