def generate(): repeat = True while repeat == True: letter_total = 0 cons_count = 0 vow_count = 0 force_vow_amt = False # Get center letter center = get_cen_letter() for each in lib_vowels: if center[0] == each[0]: vow_count += 1 force_vow_amt = [True, center[0]] if vow_count == 0: cons_count += 1 force_vow_amt = [False, center[0]] letter_total += len(center) / 2 # Get vowel letters vowels = get_vow_letters(force_vow_amt) vow_count += len(vowels) letter_total += len(vowels) / 1 # Get remaining letters cons_count = 7 - letter_total consonants = get_cons_letters(cons_count) letter_total += len(consonants) / 1 all_letters = [center] for each in vowels: all_letters += [each] for each in consonants: all_letters += [each] # CHECK FOR REDUNDANCIES redundancies = 0 for each in all_letters: for all in all_letters: if check_letter(all[0], each[0]) == True: # Count of 7 is normal redundancies += 1 # Redundancy action if redundancies > 7: repeat = True else: repeat = False exit all_letters_freq = 0 for each in all_letters: all_letters_freq += each[1] all_letters_freq_mean = all_letters_freq / 7 return all_letters, all_letters_freq_mean
def main(): # MAIN repeat = True while repeat == True: letter_total = 0 cons_count = 0 vow_count = 0 force_vow_amt = False # Get center letter center = get_cen_letter() for each in lib_vowels: if center[0] == each[0]: vow_count += 1 force_vow_amt = [True, center[0]] if vow_count == 0: cons_count += 1 force_vow_amt = [False, center[0]] letter_total += len(center)/2 # Get vowel letters vowels = get_vow_letters(force_vow_amt) vow_count += len(vowels) letter_total += len(vowels)/1 # Get remaining letters cons_count = 7-letter_total consonants = get_cons_letters(cons_count) letter_total += len(consonants)/1 all_letters = [center] for each in vowels: all_letters += [each] for each in consonants: all_letters += [each] # CHECK FOR REDUNDANCIES redundancies = 0 for each in all_letters: for all in all_letters: if check_letter(all[0],each[0])== True: # Count of 7 is normal redundancies += 1 # Redundancy action if redundancies > 7: repeat = True else: repeat = False sys.exit all_letters_freq = 0 for each in all_letters: all_letters_freq += each[1] all_letters_freq_mean = all_letters_freq/7 # TWITTER DISTRO AND FORMAT # 30 characters to work with in top and bottom messages #date = datetime.today().strftime('%m/%d/%y') # load letters from letter generator functions "gen_x_letter" #hive_let = [0] * 6 i=0 let_vow = [0] * len(vowels) for each in vowels: let_vow[i] = each[0] i+=1 i=0 let_cons = [0] * len(consonants) for each in consonants: let_cons[i] = each[0] i+=1 hive_let = let_vow + let_cons #print hive_let hive_cen_let = center[0] # 140 character limit #22 characters header = 'Beehive for ' + date + ':' + '\n' # 69 characters hive = [0] * 6 hive[0]=' \ '+str(hive_let[0]).upper()+' /' + '\n' hive[1]=str(hive_let[1]).upper()+' \ / '+str(hive_let[2]).upper() + '\n' hive[2]='---( '+str(hive_cen_let).upper()+' )---' + '\n' hive[3]=str(hive_let[3]).upper()+' / \ '+str(hive_let[4]).upper() + '\n' hive[4]=' / '+str(hive_let[5]).upper()+' \\' # 9 characters footer = '\nALF: ' + str("%.2f" % all_letters_freq_mean) # 40 character possbility for top message if len(sys.argv) > 1: cmd = sys.argv[1] top_message = cmd payload = top_message + '\n' + header + hive[0] + hive [1] + hive[2] + hive[3] + hive[4] + footer else: payload = header + hive[0] + hive [1] + hive[2] + hive[3] + hive[4] + footer print payload status = api.PostUpdate(payload) # Logger with open('server.log', 'a') as logfile: import time import datetime timestamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S') logfile.write('time:'+timestamp+',center:'+str(center)+',vowels:'+str(vowels)+',consonants:'+str(consonants)+',all_letters:'+str(all_letters)+',freq_mean:'+str(all_letters_freq_mean)+'\n')
def main(): # MAIN repeat = True while repeat == True: letter_total = 0 cons_count = 0 vow_count = 0 force_vow_amt = False # Get center letter center = get_cen_letter() for each in lib_vowels: if center[0] == each[0]: vow_count += 1 force_vow_amt = [True, center[0]] if vow_count == 0: cons_count += 1 force_vow_amt = [False, center[0]] letter_total += len(center) / 2 # Get vowel letters vowels = get_vow_letters(force_vow_amt) vow_count += len(vowels) letter_total += len(vowels) / 1 # Get remaining letters cons_count = 7 - letter_total consonants = get_cons_letters(cons_count) letter_total += len(consonants) / 1 all_letters = [center] for each in vowels: all_letters += [each] for each in consonants: all_letters += [each] # CHECK FOR REDUNDANCIES redundancies = 0 for each in all_letters: for all in all_letters: if check_letter(all[0], each[0]) == True: # Count of 7 is normal redundancies += 1 # Redundancy action if redundancies > 7: repeat = True else: repeat = False sys.exit all_letters_freq = 0 for each in all_letters: all_letters_freq += each[1] all_letters_freq_mean = all_letters_freq / 7 # TWITTER DISTRO AND FORMAT # 30 characters to work with in top and bottom messages #date = datetime.today().strftime('%m/%d/%y') # load letters from letter generator functions "gen_x_letter" #hive_let = [0] * 6 i = 0 let_vow = [0] * len(vowels) for each in vowels: let_vow[i] = each[0] i += 1 i = 0 let_cons = [0] * len(consonants) for each in consonants: let_cons[i] = each[0] i += 1 hive_let = let_vow + let_cons #print hive_let hive_cen_let = center[0] # 140 character limit #22 characters header = 'Beehive for ' + date + ':' + '\n' # 69 characters hive = [0] * 6 hive[0] = ' \ ' + str(hive_let[0]).upper() + ' /' + '\n' hive[1] = str(hive_let[1]).upper() + ' \ / ' + str( hive_let[2]).upper() + '\n' hive[2] = '---( ' + str(hive_cen_let).upper() + ' )---' + '\n' hive[3] = str(hive_let[3]).upper() + ' / \ ' + str( hive_let[4]).upper() + '\n' hive[4] = ' / ' + str(hive_let[5]).upper() + ' \\' # 9 characters footer = '\nALF: ' + str("%.2f" % all_letters_freq_mean) # 40 character possbility for top message if len(sys.argv) > 1: cmd = sys.argv[1] top_message = cmd payload = top_message + '\n' + header + hive[0] + hive[1] + hive[ 2] + hive[3] + hive[4] + footer else: payload = header + hive[0] + hive[1] + hive[2] + hive[3] + hive[ 4] + footer print payload status = api.PostUpdate(payload) # Logger with open('server.log', 'a') as logfile: import time import datetime timestamp = datetime.datetime.fromtimestamp( time.time()).strftime('%Y-%m-%d %H:%M:%S') logfile.write('time:' + timestamp + ',center:' + str(center) + ',vowels:' + str(vowels) + ',consonants:' + str(consonants) + ',all_letters:' + str(all_letters) + ',freq_mean:' + str(all_letters_freq_mean) + '\n')