Exemplo n.º 1
0
def examine_ipc_scheme(ipc_file):
    """
        Function that is used along with the above generator function 
        Scope is the same.
        On success from the generator it returns the message.
        On failure it returns a notification that the message is not found in the 
        scheme.
        If the number of failures is 3 it aborts.

        @rtype  file object
        @rvalue string


    """

    cnt = 0
    try:
        with open(ipc_file) as f:
            for message_found in ipc_message_gen(f):
                if message_found[0] == True:
                    log.info('%s is found in ipc scheme.Try to modify this',
                             ' '.join(message_found[1].split()))
                    break
                else:
                    cnt += 1
                    log.warning(
                        '%s is not found in ipc scheme.Try next candidate',
                        ' '.join(message_found[1].split()))

            if cnt == len(ipc_message_db):
                log.error(
                    'ipc message db is examined and no candidate found for editing'
                )
                sys.exit(3)
            else:
                log.info('Will change now %s in ipc file' %
                         message_found[1].split()[0])

    except IOError:
        #: if we get here then something is really messed up... :#
        log.error('ipc encoding scheme seems that does not exist')
        sys.exit(4)

    return message_found[1]
Exemplo n.º 2
0
def examine_ipc_scheme(ipc_file):
    """
        Function that is used along with the above generator function 
        Scope is the same.
        On success from the generator it returns the message.
        On failure it returns a notification that the message is not found in the 
        scheme.
        If the number of failures is 3 it aborts.

        @rtype  file object
        @rvalue string


    """

    cnt = 0
    try:
        with open(ipc_file) as f:
            for message_found in ipc_message_gen(f):
                if message_found[0] == True:
                    log.info('%s is found in ipc scheme.Try to modify this',
                             ' '.join(message_found[1].split()))
                    break
                else:
                    cnt += 1
                    log.warning('%s is not found in ipc scheme.Try next candidate', ' '.join(
                        message_found[1].split()))

            if cnt == len(ipc_message_db):
                log.error(
                    'ipc message db is examined and no candidate found for editing')
                sys.exit(3)
            else:
                log.info('Will change now %s in ipc file' %
                         message_found[1].split()[0])

    except IOError:
        #: if we get here then something is really messed up... :#
        log.error('ipc encoding scheme seems that does not exist')
        sys.exit(4)

    return message_found[1]
Exemplo n.º 3
0
def commit_ban(BanServerUrl):
    """ Function that checks if commit ban is ON/OFF"""

    try:
        resp = urllib2.urlopen(BanServerUrl).readlines()
    except urllib2.HTTPError as e:
        print 'Commit Ban Server is unavailable'
        print 'Will use magic_word_ISUG anyway to be sure'
        return True

    else:
        for line in resp:
            if 'ON' in line and options.branch in line:
                log.warning('COMMIT BAN is ON for %s' % options.branch)
                log.warning('Will use magic_word_ISUG in commit msg')
                print 'COMMIT BAN is ON for %s' % options.branch
                print 'Will use magic_word_ISUG in commit msg'
                return True
            else:
                pass

    return False
Exemplo n.º 4
0
def commit_ban(BanServerUrl):
    """ Function that checks if commit ban is ON/OFF"""

    try:
        resp = urllib2.urlopen(BanServerUrl).readlines()
    except urllib2.HTTPError as e:
        print 'Commit Ban Server is unavailable'
        print 'Will use magic_word_ISUG anyway to be sure'
        return True

    else:
        for line in resp:
            if 'ON' in line and options.branch in line:
                log.warning('COMMIT BAN is ON for %s' % options.branch)
                log.warning('Will use magic_word_ISUG in commit msg')
                print 'COMMIT BAN is ON for %s' % options.branch
                print 'Will use magic_word_ISUG in commit msg'
                return True
            else:
                pass

    return False
Exemplo n.º 5
0
            git.show_branches()
            all_branches = git.stdOut
            #: do git stash pop only if you are in the correct branch! :#
            #: make use of mapping dict as master resolves into trunk... :#

            if stashes and options.branch in [
                    pat.search(line).group(1) for line in stashes
            ] and options.branch == [
                    cur.split()[1]
                    for cur in all_branches.splitlines() if '*' in cur
            ][0]:

                for line in stashes:
                    branch = pat.search(line).group(1)
                    if branch and branch == options.branch:
                        log.warning('Found stash %s for %s' %
                                    (line, options.branch))
                        stash_rev = re.match('stash@{(\d+)}', line).group(1)
                        git.stash('pop stash@{' + stash_rev + '}')
                        log.warning('Pop up this stash %s back to %s' %
                                    (line, options.branch))
                        break
                    else:
                        pass
            else:
                print 'No available stashes.Exit'
                break
        #log.info('Get the files back from stash if any\n %s' % git.stdOut)
        print '========================================'
        print 'Done\n'
        sys.exit(2)
Exemplo n.º 6
0
        print'======================================'
        pat = re.compile('WIP on (\w+):')
        while True:
            git.stash('list')
            stashes = git.stdOut.splitlines()
            git.show_branches()
            all_branches = git.stdOut
            #: do git stash pop only if you are in the correct branch! :#
            #: make use of mapping dict as master resolves into trunk... :#

            if stashes and options.branch in [pat.search(line).group(1) for line in stashes] and options.branch == [cur.split()[1] for cur in all_branches.splitlines() if '*' in cur][0]:

                for line in stashes:
                    branch = pat.search(line).group(1)
                    if branch and branch == options.branch:
                        log.warning('Found stash %s for %s' %
                                    (line, options.branch))
                        stash_rev = re.match('stash@{(\d+)}', line).group(1)
                        git.stash('pop stash@{' + stash_rev + '}')
                        log.warning('Pop up this stash %s back to %s' %
                                    (line, options.branch))
                        break
                    else:
                        pass
            else:
                print 'No available stashes.Exit'
                break
        #log.info('Get the files back from stash if any\n %s' % git.stdOut)
        print '========================================'
        print 'Done\n'
        sys.exit(2)