Ejemplo n.º 1
0
def uiFunc_setLastUpdateDebug(branch='MRS', clear=False):
    var_lastUpdate = cgmMeta.cgmOptionVar('cgmVar_branchLastUpdate',
                                          defaultValue=['None'])
    if clear:
        var_lastUpdate.setValue(['None'])
        var_lastUpdate.report()
        return
    d_branch = cgmUpdate.get_dat(branch, 1, True)
    var_lastUpdate.setValue([
        branch, d_branch[0]['hash'], d_branch[0]['msg'],
        datetime.datetime.now().__str__()[:-7]
    ])
Ejemplo n.º 2
0
    def uiUpdate_commits(self):
        self.uiScroll_commits.clear()
        #_d_ui_annotations = {}

        _sidePadding = 25
        _parent = self.uiScroll_commits
        _branch = self.var_branchMode.value
        _dat = cgmUpdate.get_dat(_branch, _commit_limit, True)

        uiRC = mUI.MelRadioCollection()
        self.uiRC_commits = uiRC
        self.dat_commits = _dat

        for i, d in enumerate(_dat):
            _hash = d['hash']
            _msg = d['msg']
            _date = d['date']
            _url = d['url']

            _ann = '\n {0} commit {1} | {2} | {3} \n {4} \n {5}'.format(
                _branch, i, _hash, _date, _msg, _url)
            _report = '{0} | {1}'.format(_hash, _msg[:50])
            _label = "{0} - {1} | {3}...".format(i, _date, _hash[:8],
                                                 _msg[:40])
            #log.debug(_report)
            #cgmUI.mUI.MelLabel(_parent, l = _msg,
            #                   annotation = d['msg'])

            #mc.separator(parent = _parent, height = 5,
            #ut='cgmUISubTemplate'
            #             )
            cgmUI.mUI.MelSpacer(_parent, h=5)
            uiRC.createButton(
                _parent,
                label=_label,
                annotation=_ann,
                onCommand=cgmGEN.Callback(log.info, _ann),
                #ut='cgmUIHeader',
                #onCommand = lambda*a:(log.info("{0} | {1} | {2}".format(uiRC.getSelectedIndex(), _branch, self.dat_commits[uiRC.getSelectedIndex()]['hash'])))
                #sl=_rb,
                #onCommand = cgmGEN.Callback(_var.setValue,i)
            )
            mc.setParent(_parent)
            cgmUI.add_LineSubBreak()
Ejemplo n.º 3
0
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: