def send_mail(outgoing_message, Thesender): """ Function that will send out a descriptive message to the build triggerers and not only,to notify about the revision we commited and if they should start an ISO or chech why sanity is red. """ Topeople = [ '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**' ] if options.branch == 'cat_japan' or options.branch == 'ng30_13a': Topeople.append('*****@*****.**') msg = MIMEText(outgoing_message) msg['Subject'] = 'New ISO for dummy ISUG' msg['From'] = Thesender msg['To'] = ','.join(Topeople) s = smtplib.SMTP('localhost') s.sendmail(Thesender, [Thesender, ','.join(Topeople)], msg.as_string()) s.quit() log.info("Mail for iso trigger has been sent out!")
def enter_winterfell(): """ Function that is used when we are doing ISUG in a branch and not in trunk. It fetches a revision file from winterfell machine and opens to examine the green tag that was built the ISO. If branches use the real commited revisions in their ISOs in the future we can skip this call """ log.info('SSH to winterfell for %s.txt' % options.src_build_rev) print 'SSH to winterfell for %s.txt' % options.src_build_rev django = pexpect.spawn(ssh_winterfell) django.expect_exact('$') c = pexpect.spawn( 'scp [email protected]:/home/django/lvnproject/Weblvn/my_media/svnhistory/' + options.src_build_rev + '.txt' ' /home/' + username() + '/') c.expect(pexpect.EOF, timeout=None) c.terminate() django.terminate() if os.path.exists('/home/' + username() + '/' + options.src_build_rev + '.txt'): log.info('Fetched revision file %s.txt' % options.src_build_rev) print 'Fetched revision file %s.txt' % options.src_build_rev print 'Done\n' else: log.error('Did not succeed to fetch %s.txt from winterfell' % options.src_build_rev) sys.exit(14)
def send_mail(outgoing_message, Thesender): """ Function that will send out a descriptive message to the build triggerers and not only,to notify about the revision we commited and if they should start an ISO or chech why sanity is red. """ Topeople = ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**' ] if options.branch == 'cat_japan' or options.branch == 'ng30_13a': Topeople.append('*****@*****.**') msg = MIMEText(outgoing_message) msg['Subject'] = 'New ISO for dummy ISUG' msg['From'] = Thesender msg['To'] = ','.join(Topeople) s = smtplib.SMTP('localhost') s.sendmail(Thesender, [Thesender, ','.join(Topeople)], msg.as_string()) s.quit() log.info("Mail for iso trigger has been sent out!")
def enter_winterfell(): """ Function that is used when we are doing ISUG in a branch and not in trunk. It fetches a revision file from winterfell machine and opens to examine the green tag that was built the ISO. If branches use the real commited revisions in their ISOs in the future we can skip this call """ log.info('SSH to winterfell for %s.txt' % options.src_build_rev) print 'SSH to winterfell for %s.txt' % options.src_build_rev django = pexpect.spawn(ssh_winterfell) django.expect_exact('$') c = pexpect.spawn('scp [email protected]:/home/django/lvnproject/Weblvn/my_media/svnhistory/' + options.src_build_rev + '.txt'' /home/' + username() + '/') c.expect(pexpect.EOF, timeout=None) c.terminate() django.terminate() if os.path.exists('/home/' + username() + '/' + options.src_build_rev + '.txt'): log.info('Fetched revision file %s.txt' % options.src_build_rev) print 'Fetched revision file %s.txt' % options.src_build_rev print 'Done\n' else: log.error('Did not succeed to fetch %s.txt from winterfell' % options.src_build_rev) sys.exit(14)
def set_ISU_flag(line): """ Function that sets the ISU flag of a message given to this. If original message has ISU=1 it sets it to ISU=0 and vice versa """ old_value = re.search('ISU=(\d)', line).group(1) log.info('Old value for ISU flag of %s is %s' % (' '.join(line.split()), old_value)) return str(1) if old_value == str(0) else str(0)
def git_dcommit(): print 'Preparing to commit in svn' log.info('Preparing to commit in svn') print '==========================' c = pexpect.spawn('git svn dcommit') c.expect(username() + "@svne1.access.nokiasiemensnetworks.com's password:") c.sendline(password) c.expect(pexpect.EOF, timeout=None) c.terminate() print 'Commited!\n' log.info('Commited!') print '===========================' print 'Done\n'
def get_src_lvn(): """ Function that retrieves the source lvn from vevak file It also returns apart from the source lvn,the latest lvn in the vevak file.It is used for calculating the target lvn. """ try: response = urllib2.urlopen(vevak_url).readlines() except urllib2.HTTPError: log.error('url %s from vevak not found' % vevak_url) sys.exit(5) else: if not options.branch.startswith('cat'): try: src_lvn = filter( lambda line: re.search( '\\b' + options.src_build_rev + '\\b', line), response)[0].split('|')[7].strip() #src_lvn=re.search(r'(?<= )(\d{1,3})(?= )',filter(lambda line:re.search('\\b'+options.src_build_rev+'\\b',line),response)[0]).group(1) #latest_LVN = re.search(r'(?<= )(\d{1,3})(?= )',response[-1]).group(1) latest_LVN = response[-1].split('|')[7].strip() except IndexError: log.error('Requested wrong revision %s against %s', options.src_build_rev, options.branch) sys.exit(3) else: try: enter_winterfell() file_desc = open( '/home/' + username() + '/' + options.src_build_rev + '.txt', 'r') green_tag = cat_regex.search(file_desc.readlines()[2]).group(2) except AttributeError: log.error('Requested wrong revision %s against %s', options.src_build_rev, options.branch) sys.exit(4) else: log.info('green tag is:%s ', green_tag) #: LVN in branches are most of the times 2-digit string :# src_lvn = filter( lambda line: re.search('\\b' + green_tag + '\\b', line), response)[0].split('|')[7].strip() #src_lvn=re.search(r'(?<= )(\d{1,2})(?= )',filter(lambda line:re.search('\\b'+green_tag+'\\b',line),response)[0]).group(1) #latest_LVN = re.search(r'(?<= )(\d{1,2})(?= )',response[-1]).group(1) latest_LVN = response[-1].split('|')[7].strip() print '================================' print 'You requested %s as source lvn' % src_lvn log.info('You requested %s as source lvn' % src_lvn) print 'Latest LVN in %s is %s ' % (options.branch, latest_LVN) log.info('Latest LVN in %s is %s ' % (options.branch, latest_LVN)) print '================================' print 'Done\n' log.info('Done') return (src_lvn, latest_LVN)
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]
def edit_ipc(message_to_modify): """ Function that edits the ipc encoding scheme. It is called twice via the edit_ipc_supported method as it is actually returned by this. """ for line in fileinput.input(ipc_file, inplace=True): if re.match(message_to_modify.split()[0] + ' ', line): log.info('Match found in ipc scheme for %s.Change that' % message_to_modify.split()[0]) new_flag = set_ISU_flag(line) print re.sub('ISU=\d', 'ISU=' + new_flag, line).replace('\n', '') else: print line.replace('\n', '') git.diff() log.info('ipc scheme edited.This is the diff: =============== \n\n\n %s \n\n\n ============', git.stdOut)
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]
def get_src_lvn(): """ Function that retrieves the source lvn from vevak file It also returns apart from the source lvn,the latest lvn in the vevak file.It is used for calculating the target lvn. """ try: response = urllib2.urlopen(vevak_url).readlines() except urllib2.HTTPError: log.error('url %s from vevak not found' % vevak_url) sys.exit(5) else: if not options.branch.startswith('cat'): try: src_lvn = filter(lambda line: re.search( '\\b' + options.src_build_rev + '\\b', line), response)[0].split('|')[7].strip() #src_lvn=re.search(r'(?<= )(\d{1,3})(?= )',filter(lambda line:re.search('\\b'+options.src_build_rev+'\\b',line),response)[0]).group(1) #latest_LVN = re.search(r'(?<= )(\d{1,3})(?= )',response[-1]).group(1) latest_LVN = response[-1].split('|')[7].strip() except IndexError: log.error('Requested wrong revision %s against %s', options.src_build_rev, options.branch) sys.exit(3) else: try: enter_winterfell() file_desc = open('/home/' + username() + '/' + options.src_build_rev + '.txt', 'r') green_tag = cat_regex.search(file_desc.readlines()[2]).group(2) except AttributeError: log.error('Requested wrong revision %s against %s', options.src_build_rev, options.branch) sys.exit(4) else: log.info('green tag is:%s ', green_tag) #: LVN in branches are most of the times 2-digit string :# src_lvn = filter(lambda line: re.search( '\\b' + green_tag + '\\b', line), response)[0].split('|')[7].strip() #src_lvn=re.search(r'(?<= )(\d{1,2})(?= )',filter(lambda line:re.search('\\b'+green_tag+'\\b',line),response)[0]).group(1) #latest_LVN = re.search(r'(?<= )(\d{1,2})(?= )',response[-1]).group(1) latest_LVN = response[-1].split('|')[7].strip() print'================================' print 'You requested %s as source lvn' % src_lvn log.info('You requested %s as source lvn' % src_lvn) print 'Latest LVN in %s is %s ' % (options.branch, latest_LVN) log.info('Latest LVN in %s is %s ' % (options.branch, latest_LVN)) print'================================' print'Done\n' log.info('Done') return (src_lvn, latest_LVN)
def edit_ipc(message_to_modify): """ Function that edits the ipc encoding scheme. It is called twice via the edit_ipc_supported method as it is actually returned by this. """ for line in fileinput.input(ipc_file, inplace=True): if re.match(message_to_modify.split()[0] + ' ', line): log.info('Match found in ipc scheme for %s.Change that' % message_to_modify.split()[0]) new_flag = set_ISU_flag(line) print re.sub('ISU=\d', 'ISU=' + new_flag, line).replace('\n', '') else: print line.replace('\n', '') git.diff() log.info( 'ipc scheme edited.This is the diff: =============== \n\n\n %s \n\n\n ============', git.stdOut)
def find_commited_revision(): """ Function that will be used to retrieve the revision in svn terms of the 2nd commit we made. This should be the revision from which the ISO will be built. """ print'Find the commited revision' print'===========================' git.log(supported_file) if re.search(username(), git.stdOut): hashvalue = re.search(r'(?<=commit )(\w{10})', git.stdOut).group(1) cmd.run('git svn find-rev ' + hashvalue) com_revision = cmd.stdOut.strip('\n') print 'Commited revision is: ', com_revision log.info('Commited revision is %s: ' % com_revision) print '===========================' print'Done\n' else: log.error('Unable to find %s in %s.Check manually' % (username(), git.stdOut)) sys.exit(3) return com_revision
def find_commited_revision(): """ Function that will be used to retrieve the revision in svn terms of the 2nd commit we made. This should be the revision from which the ISO will be built. """ print 'Find the commited revision' print '===========================' git.log(supported_file) if re.search(username(), git.stdOut): hashvalue = re.search(r'(?<=commit )(\w{10})', git.stdOut).group(1) cmd.run('git svn find-rev ' + hashvalue) com_revision = cmd.stdOut.strip('\n') print 'Commited revision is: ', com_revision log.info('Commited revision is %s: ' % com_revision) print '===========================' print 'Done\n' else: log.error('Unable to find %s in %s.Check manually' % (username(), git.stdOut)) sys.exit(3) return com_revision
def git_rebase(branch): #:begin git svn rebase :# gitobj = Git() global password password = getpass('Password for svn:') print 'Requested: ', branch log.info('Requested:%s ', branch) gitobj.checkout(branch) print 'Switched to %s.Proceed to rebase' % branch log.info('Switched to %s.Proceed to rebase' % branch) child = pexpect.spawn('git svn rebase') child.expect( username() + "@svne1.access.nokiasiemensnetworks.com's password:") child.sendline(password) child.expect(pexpect.EOF, timeout=None) child.terminate() print 'Done\n' log.info('Done\n')
def git_rebase(branch): #:begin git svn rebase :# gitobj = Git() global password password = getpass('Password for svn:') print 'Requested: ', branch log.info('Requested:%s ', branch) gitobj.checkout(branch) print 'Switched to %s.Proceed to rebase' % branch log.info('Switched to %s.Proceed to rebase' % branch) child = pexpect.spawn('git svn rebase') child.expect(username() + "@svne1.access.nokiasiemensnetworks.com's password:") child.sendline(password) child.expect(pexpect.EOF, timeout=None) child.terminate() print 'Done\n' log.info('Done\n')
def edit_supported(source_lvn, current_lvn): """ Function that edits the supported_versions.conf. It opens the file and inserts a line of this form: Adaptation: bfr_<src_lvn> <===> bfr_<trg_lvn> It calculates the target lvn itself by examining what is the latest lvn in the vevak file,and adds 2.The latest lvn should normally be always the same as the src_lvn... @rtype None """ print 'Going to edit supported_versions.conf file\n' log.info('Going to edit supported_versions.conf file') print 'Calculating target LVN' log.info('Calculating target LVN') print '======================' if int(current_lvn) != int(source_lvn): log.critical('It seems that source lvn:%s differs from current lvn:%s in %s.Usually they need to be equal.' % ( source_lvn, current_lvn, options.branch)) trg_lvn = str(int(current_lvn) + 2) print 'Target lvn will be :', trg_lvn log.info('Target lvn will be :%s' % trg_lvn) print'=======================' S = open(supported_file, 'r+') supported_list = S.readlines() for i, line in enumerate(supported_list): if re.search('End of file', line, re.I): # print 'Found End of file at line : ',i break if options.branch == 'trunk': bfr = '1' else: #: 1st way to retrieve BFR :# bfr_lvn = re.findall('\d+' + '_' + '\d+', '\n'.join(supported_list)) bfrs = [line.split('_')[0] for line in bfr_lvn] c = Counter(bfrs) bfr_1 = c.most_common()[0][0] #: 2nd backup way to retrieve BFR :# try: f = open('Makefile.inc') except IOError: log.error('Unable to open Makefile.inc to retrieve the BFR') sys.exit(12) else: for line in f: if (re.search('BFR', line) and re.search('\d{6}', line)) and not re.search('9{4,}', line): bfr_2 = re.search('(\d{6})', line).group(1) if int(bfr_1) == int(bfr_2): bfr = bfr_2 else: print 'Collected BFRs that were retrieved with 2 methods are different' print '%s != %s' % (str(bfr_1), str(bfr_2)) log.critical( 'Collected BFRs that were retrieved with 2 methods are different,but will proceed with %s' % str(bfr_2)) log.critical('%s != %s', str(bfr_1), str(bfr_2)) bfr = bfr_2 # sys.exit(2) supported_list.insert(i, 'Adaptation: ' + str(bfr) + '_' + source_lvn + ' <===> ' + str(bfr) + '_' + trg_lvn + '\n') S.seek(0) S.write(''.join(supported_list)) S.close() git.diff() log.info('supported versions edited.This is the diff: ================= \n\n\n %s ==============', git.stdOut) print 'Done\n' log.info('Done')
def git_stash_list(starting_point): g = Git() print 'Show how is the stash before any further proceeding' g.stash('list') print 'Stash before: \n', g.stdOut log.info('Stash before:\n%s' % g.stdOut) print '\n\n' log.info('\n\n') print 'Stash your local changes if any @%s' % starting_point log.info('Stash your local changes if any @%s' % starting_point) g.stash() print 'Stash is done\n' log.info('Stash is done\n') print 'Show how is the stash after' log.info('Show how the stash is after stash') g.stash('list') print 'Stash after:\n ', g.stdOut log.info('Stash after:\n%s' % g.stdOut) print '\n\n' log.info('\n\n')
def wrap(): print 'Retrieve source LVN' log.info('Retrieve source LVN') return f()
def check_sanity(commited=None): """ Function that checks the sanity status from buildbot If sanity is red it calls itself recursively in order to wait until sanity is green.If it is red for 30 minutes it aborts. @rtype tuple $rvalue flag that tells is sanity is green and the green revision """ global retry is_green = False print'Checking sanity status' #: the buildbot file shall be kept into a list in order to parse it later :# try: f = urllib2.urlopen(buildbot_url).readlines() except urllib2.HTTPError as e: print 'Unable to fetch buildbot url ' print e sys.exit(3) #: it will be used to get the revision in the sanity box :# sanity_reg = re.compile( r'(?<=href=)"builders/SANITY/builds/\d+">(\d{6})</a><br />(\w+)<br') #: check the validity of the buildbot file that has now become a list ---check line 133:# if 'SANITY' in ' '.join(f): log.info('SANITY string is found in the buildbot file.Proceed with parsing') else: log.error('Failed to find SANITY in buildbot file.Check manually') sys.exit(3) if not commited: #: we are in the case where the script calls for the first time check_sanity in order to proceed with the commits :# for line in f: if 'SANITY' in line and 'failed' in line: #: enter an 3min loop periodically until sanity box is green.Break the loop then. :# while (retry < 10): #: give it some time until it tries again :# #: There are some cases about sanity that need to be handled accordingly :# #: 1)The sanity has left in red state and no-one is looking at this #: | #: |-----> the script will try for 30 minutes and abort.Before aborting it must restore #: the files that have been changed to their previous state #: 2)The sanity is either red or green but it is expected by the responsible team to be fixed #: in less than 1h time_period = 180 log.info( 'Sleeping for 3 mins in order to wait for sanity to be green') time.sleep(time_period) log.info('Retrying sanity check:%s' % retry) retry += 1 return check_sanity() log.critical( 'Tried for 30minutes and sanity is still red.Aborting...num of retries:%s' % retry) sys.exit(8) elif 'SANITY' in line and 'successful' in line: green_rev = sanity_reg.search(line).group(1) is_green = True print'=================================================' print 'Green revision currently on buildbot SANITY is ', green_rev print'=================================================' print'Done\n' break else: pass #: we should get here when we call check_sanity with commited revision as parameter :# #: in order to verify if this revision ended with green sanity :# else: #: this is the case that we make sure our commits turned sanity into green :# for line in f: if 'SANITY/builds' in line: while sanity_reg.search(line).group(1) != commited: print 'revision in buildot:', sanity_reg.search(line).group(1) print 'revision that commited:', commited sanity_reg.search(line).group(1) != commited log.info( 'Currently building.Wait until our commited revision is in the sanity box and turns green') time.sleep(120) return check_sanity(commited) log.info('Commited revision %s is in sanity box' % commited) if 'successful' in line: log.info( 'Commited revision %s turned green.SUCCESS!!!' % commited) print'==========================================' print' We commited %s and is green ' % commited print'==========================================' green_rev = commited is_green = True break else: log.error( 'We most probably broke sanity @ %s.Check manually' % commited) error = 'Hi,\n\n Commited revision %s has resulted in red sanity.\n\nCould you please check?' % commited sender = find_sender(username()) # send_mail(error,sender) sys.exit(4) return (is_green, green_rev)
def check_sanity(commited=None): """ Function that checks the sanity status from buildbot If sanity is red it calls itself recursively in order to wait until sanity is green.If it is red for 30 minutes it aborts. @rtype tuple $rvalue flag that tells is sanity is green and the green revision """ global retry is_green = False print 'Checking sanity status' #: the buildbot file shall be kept into a list in order to parse it later :# try: f = urllib2.urlopen(buildbot_url).readlines() except urllib2.HTTPError as e: print 'Unable to fetch buildbot url ' print e sys.exit(3) #: it will be used to get the revision in the sanity box :# sanity_reg = re.compile( r'(?<=href=)"builders/SANITY/builds/\d+">(\d{6})</a><br />(\w+)<br') #: check the validity of the buildbot file that has now become a list ---check line 133:# if 'SANITY' in ' '.join(f): log.info( 'SANITY string is found in the buildbot file.Proceed with parsing') else: log.error('Failed to find SANITY in buildbot file.Check manually') sys.exit(3) if not commited: #: we are in the case where the script calls for the first time check_sanity in order to proceed with the commits :# for line in f: if 'SANITY' in line and 'failed' in line: #: enter an 3min loop periodically until sanity box is green.Break the loop then. :# while (retry < 10): #: give it some time until it tries again :# #: There are some cases about sanity that need to be handled accordingly :# #: 1)The sanity has left in red state and no-one is looking at this #: | #: |-----> the script will try for 30 minutes and abort.Before aborting it must restore #: the files that have been changed to their previous state #: 2)The sanity is either red or green but it is expected by the responsible team to be fixed #: in less than 1h time_period = 180 log.info( 'Sleeping for 3 mins in order to wait for sanity to be green' ) time.sleep(time_period) log.info('Retrying sanity check:%s' % retry) retry += 1 return check_sanity() log.critical( 'Tried for 30minutes and sanity is still red.Aborting...num of retries:%s' % retry) sys.exit(8) elif 'SANITY' in line and 'successful' in line: green_rev = sanity_reg.search(line).group(1) is_green = True print '=================================================' print 'Green revision currently on buildbot SANITY is ', green_rev print '=================================================' print 'Done\n' break else: pass #: we should get here when we call check_sanity with commited revision as parameter :# #: in order to verify if this revision ended with green sanity :# else: #: this is the case that we make sure our commits turned sanity into green :# for line in f: if 'SANITY/builds' in line: while sanity_reg.search(line).group(1) != commited: print 'revision in buildot:', sanity_reg.search( line).group(1) print 'revision that commited:', commited sanity_reg.search(line).group(1) != commited log.info( 'Currently building.Wait until our commited revision is in the sanity box and turns green' ) time.sleep(120) return check_sanity(commited) log.info('Commited revision %s is in sanity box' % commited) if 'successful' in line: log.info('Commited revision %s turned green.SUCCESS!!!' % commited) print '==========================================' print ' We commited %s and is green ' % commited print '==========================================' green_rev = commited is_green = True break else: log.error( 'We most probably broke sanity @ %s.Check manually' % commited) error = 'Hi,\n\n Commited revision %s has resulted in red sanity.\n\nCould you please check?' % commited sender = find_sender(username()) # send_mail(error,sender) sys.exit(4) return (is_green, green_rev)
def edit_supported(source_lvn, current_lvn): """ Function that edits the supported_versions.conf. It opens the file and inserts a line of this form: Adaptation: bfr_<src_lvn> <===> bfr_<trg_lvn> It calculates the target lvn itself by examining what is the latest lvn in the vevak file,and adds 2.The latest lvn should normally be always the same as the src_lvn... @rtype None """ print 'Going to edit supported_versions.conf file\n' log.info('Going to edit supported_versions.conf file') print 'Calculating target LVN' log.info('Calculating target LVN') print '======================' if int(current_lvn) != int(source_lvn): log.critical( 'It seems that source lvn:%s differs from current lvn:%s in %s.Usually they need to be equal.' % (source_lvn, current_lvn, options.branch)) trg_lvn = str(int(current_lvn) + 2) print 'Target lvn will be :', trg_lvn log.info('Target lvn will be :%s' % trg_lvn) print '=======================' S = open(supported_file, 'r+') supported_list = S.readlines() for i, line in enumerate(supported_list): if re.search('End of file', line, re.I): # print 'Found End of file at line : ',i break if options.branch == 'trunk': bfr = '1' else: #: 1st way to retrieve BFR :# bfr_lvn = re.findall('\d+' + '_' + '\d+', '\n'.join(supported_list)) bfrs = [line.split('_')[0] for line in bfr_lvn] c = Counter(bfrs) bfr_1 = c.most_common()[0][0] #: 2nd backup way to retrieve BFR :# try: f = open('Makefile.inc') except IOError: log.error('Unable to open Makefile.inc to retrieve the BFR') sys.exit(12) else: for line in f: if (re.search('BFR', line) and re.search( '\d{6}', line)) and not re.search('9{4,}', line): bfr_2 = re.search('(\d{6})', line).group(1) if int(bfr_1) == int(bfr_2): bfr = bfr_2 else: print 'Collected BFRs that were retrieved with 2 methods are different' print '%s != %s' % (str(bfr_1), str(bfr_2)) log.critical( 'Collected BFRs that were retrieved with 2 methods are different,but will proceed with %s' % str(bfr_2)) log.critical('%s != %s', str(bfr_1), str(bfr_2)) bfr = bfr_2 # sys.exit(2) supported_list.insert( i, 'Adaptation: ' + str(bfr) + '_' + source_lvn + ' <===> ' + str(bfr) + '_' + trg_lvn + '\n') S.seek(0) S.write(''.join(supported_list)) S.close() git.diff() log.info( 'supported versions edited.This is the diff: ================= \n\n\n %s ==============', git.stdOut) print 'Done\n' log.info('Done')
print 'this should not prevent us from proceeding.Please check by yourself' else: rpms = re.findall('href=(.+?)tgz', ' '.join(resp)) if green_revision in rpms[-1]: print 'Found the rpms for the sanity we just got green' else: print 'rpms are not the correct.the iso will most probably wont take the green revision %s ' % green_revision if __name__ == '__main__': try: check_branch_existence() original_branch = find_ini_branch() print 'Initially we are in:', original_branch log.info('Initially we are in:%s' % original_branch) git_stash_list(original_branch) git_rebase(options.branch) srcLVN, latestLVN = get_src_lvn() #: find a message from the db that will edit it's ISU flag:# message = examine_ipc_scheme(ipc_file) #: check if sanity is OK :# green_flag, green_rev = check_sanity() # : change the flag of the message in ipc scheme and show the diff :# print 'First commit will happen now locally'
print 'this should not prevent us from proceeding.Please check by yourself' else: rpms = re.findall('href=(.+?)tgz', ' '.join(resp)) if green_revision in rpms[-1]: print 'Found the rpms for the sanity we just got green' else: print 'rpms are not the correct.the iso will most probably wont take the green revision %s ' % green_revision if __name__ == '__main__': try: check_branch_existence() original_branch = find_ini_branch() print 'Initially we are in:', original_branch log.info('Initially we are in:%s' % original_branch) git_stash_list(original_branch) git_rebase(options.branch) srcLVN, latestLVN = get_src_lvn() #: find a message from the db that will edit it's ISU flag:# message = examine_ipc_scheme(ipc_file) #: check if sanity is OK :# green_flag, green_rev = check_sanity() # : change the flag of the message in ipc scheme and show the diff :# print'First commit will happen now locally'