示例#1
0
def count_contact_wise_mails_for_all_users():
	user_list = token_store.get_email_prio_users()
	# user_list = ['*****@*****.**']
	# print user_list
	for email_id in user_list:
		# try:
			count_contact_wise_mails(email_id)
示例#2
0
def count_contact_wise_mails_for_all_users():
    user_list = token_store.get_email_prio_users()
    # user_list = ['*****@*****.**']
    # print user_list
    for email_id in user_list:
        # try:
        count_contact_wise_mails(email_id)
示例#3
0
def send_daily_digest_to_all_users(nowtime):
	digest_psync = True
	digest_token = token_store.get_token(digest_client_email, source)
	if(digest_token == ""):
		digest_token = token_store.get_token(digest_client_email, source_2)
		digest_psync = False
	
	digestclient = nylas_helper.get_nylas_client_(digest_token, digest_psync)

	user_list = token_store.get_email_prio_users()
	# user_list = ['*****@*****.**', '*****@*****.**']
	# user_list = ['*****@*****.**']
	# print user_list
	digest_times = token_store.get_daily_digest_time(user_list)
	timezones = token_store.get_timezones(user_list)
	for i in range(len(user_list)):
		try:
			user = user_list[i]
			digest_time = digest_times[i]
			timezone = timezones[i]
			tzobj = pytz.timezone(timezone)
			tztime = nowtime.astimezone(tzobj).time()

			dt = digest_time.hour*60+digest_time.minute
			tzt = tztime.hour*60+tztime.minute
			# print tztime, digest_time
			if dt-tzt < 30 and dt-tzt >= 0: #if the current time and time of daily digest are 30 minutes apart, then send the daily digest
				print "Preparing to send daily digest to",user
				send_daily_digest(user, digestclient)
				print 'Sent the digest to',user
			else:
				print "Not the time",user

		except Exception as e:
			print 'Daily digest crashed {' + str(e) + '}'
示例#4
0
def send_daily_digest_to_all_users(nowtime):
    digest_psync = True
    digest_token = token_store.get_token(digest_client_email, source)
    if (digest_token == ""):
        digest_token = token_store.get_token(digest_client_email, source_2)
        digest_psync = False

    digestclient = nylas_helper.get_nylas_client_(digest_token, digest_psync)

    user_list = token_store.get_email_prio_users()
    # user_list = ['*****@*****.**', '*****@*****.**']
    # user_list = ['*****@*****.**']
    # print user_list
    digest_times = token_store.get_daily_digest_time(user_list)
    timezones = token_store.get_timezones(user_list)
    for i in range(len(user_list)):
        try:
            user = user_list[i]
            digest_time = digest_times[i]
            timezone = timezones[i]
            tzobj = pytz.timezone(timezone)
            tztime = nowtime.astimezone(tzobj).time()

            dt = digest_time.hour * 60 + digest_time.minute
            tzt = tztime.hour * 60 + tztime.minute
            # print tztime, digest_time
            if dt - tzt < 30 and dt - tzt >= 0:  #if the current time and time of daily digest are 30 minutes apart, then send the daily digest
                print "Preparing to send daily digest to", user
                send_daily_digest(user, digestclient)
                print 'Sent the digest to', user
            else:
                print "Not the time", user

        except Exception as e:
            print 'Daily digest crashed {' + str(e) + '}'
def archive_blacklist_for_all_users():
	user_list = token_store.get_email_prio_users()
	# user_list = ['*****@*****.**']
	# print user_list
	for email_id in user_list:
		try:
			archive_blacklisted_mails(email_id)
		except Exception as e:
			print 'blacklist background process crashed for ' + email_id + ' Exception : {' + traceback.format_exc() + '}'
	return
def run_blacklist_senders_for_all_users():
	user_list = token_store.get_email_prio_users()
	# user_list = ['*****@*****.**']
	# print user_list
	for email_id in user_list:
		try:
			blacklist_senders(email_id)
		except Exception as e:
			print 'blacklist senders background process crashed for ' + email_id + ' Exception : {' + traceback.format_exc() + '}'
	return
示例#7
0
def run_blacklist_senders_for_all_users():
    user_list = token_store.get_email_prio_users()
    # user_list = ['*****@*****.**']
    # print user_list
    for email_id in user_list:
        try:
            blacklist_senders(email_id)
        except Exception as e:
            print 'blacklist senders background process crashed for ' + email_id + ' Exception : {' + traceback.format_exc(
            ) + '}'
    return
示例#8
0
def run_push_for_all_users():
	user_list = token_store.get_email_prio_users()
	# user_list = ['*****@*****.**', '*****@*****.**', '*****@*****.**']
	# print user_list
	# user_list = ['*****@*****.**']
	white_list = token_store.get_white_list()
	for email_id in user_list:
		try:
			run_push_for_user(email_id,white_list)
		except Exception as e:
			print "push sender crashed for " + email_id + "exp {" + traceback.format_exc() + "}"
	return
示例#9
0
def update_scores():
	user_list = token_store.get_email_prio_users()
	# user_list = ['*****@*****.**']
	for email_id in user_list:
		try:
			contact_score_json = get_score_list_for_user(email_id)
			# print contact_score_json
			update_score_list_for_user(email_id,contact_score_json)
			print "INFO: Updated score for",email_id
		except Exception as e:
			print 'update crashed for user ' + email_id + ' Exception : {' + str(e) + '}'
	return
示例#10
0
def run_reminder_sender_for_all_users():
	user_list = token_store.get_email_prio_users()
	# print user_list
	# user_list = ['*****@*****.**']
	for email_id in user_list:
		# print '***************************'
		# print email_id
		try:
			run_reminder_sender_for_user(email_id)
		except Exception as e:
			print "reminder sender crashed for " + email_id + "exp {" + str(e) + "}"
	return
示例#11
0
def run_followup_manager_for_all_users():
	user_list = token_store.get_email_prio_users()
	# print user_list
	# user_list = ['*****@*****.**']
	for email_id in user_list:
		#print '***************************'
		# print email_id
		try:
			run_followup_manager_for_user(email_id)
		except Exception as e:
			print "follow up manager crashed for " + email_id + "exp {" + str(e) + "}"
	return
示例#12
0
def run_push_for_all_users():
    user_list = token_store.get_email_prio_users()
    # user_list = ['*****@*****.**', '*****@*****.**', '*****@*****.**']
    # print user_list
    # user_list = ['*****@*****.**']
    white_list = token_store.get_white_list()
    for email_id in user_list:
        try:
            run_push_for_user(email_id, white_list)
        except Exception as e:
            print "push sender crashed for " + email_id + "exp {" + traceback.format_exc(
            ) + "}"
    return
示例#13
0
def update_scores():
    user_list = token_store.get_email_prio_users()
    # user_list = ['*****@*****.**']
    for email_id in user_list:
        try:
            contact_score_json = get_score_list_for_user(email_id)
            # print contact_score_json
            update_score_list_for_user(email_id, contact_score_json)
            print "INFO: Updated score for", email_id
        except Exception as e:
            print 'update crashed for user ' + email_id + ' Exception : {' + str(
                e) + '}'
    return
示例#14
0
def tag_new_mails_for_all_users():

	user_list = token_store.get_email_prio_users()
	# user_list = ['*****@*****.**']
	white_list = token_store.get_white_list()
	# print white_list
	# print user_list
	for email_id in user_list:
		try:
			tag_new_mails(email_id,white_list)
		except Exception as e:
			try:
				if type(e) == nylas.client.errors.NotFoundError:
					if e.as_dict()['message'] == 'Account deleted':
						token_store.remove_user_from_prio(email_id)
						print "Removed "+email_id+". Showed 'Account deleted' error."
				else:
					print 'tagger crashed for ' + email_id + ' Exception : {' + traceback.format_exc() + '}'
			except Exception as e2:
				print 'tagger deleter crashed for ' + email_id + ' Exception : {' + traceback.format_exc() + '}'
	return
示例#15
0
def tag_new_mails_for_all_users():

    user_list = token_store.get_email_prio_users()
    # user_list = ['*****@*****.**']
    white_list = token_store.get_white_list()
    # print white_list
    # print user_list
    for email_id in user_list:
        try:
            tag_new_mails(email_id, white_list)
        except Exception as e:
            try:
                if type(e) == nylas.client.errors.NotFoundError:
                    if e.as_dict()['message'] == 'Account deleted':
                        token_store.remove_user_from_prio(email_id)
                        print "Removed " + email_id + ". Showed 'Account deleted' error."
                else:
                    print 'tagger crashed for ' + email_id + ' Exception : {' + traceback.format_exc(
                    ) + '}'
            except Exception as e2:
                print 'tagger deleter crashed for ' + email_id + ' Exception : {' + traceback.format_exc(
                ) + '}'
    return
示例#16
0
        else:
            sync_url = "https://api.nylas.com"

        if nylas_helper.use_labels(ns):
            for label in remove_label:
                lid = nylas_helper.get_id(ns, label)
                if lid is None:
                    continue
                url = sync_url + "/labels/" + lid
                response = requests.delete(url, auth=(token, ""))
                print label, ":", response
        else:
            for label in remove_label:
                lid = nylas_helper.get_folder_id(ns, label)
                if lid is None:
                    continue
                url = sync_url + "/folders/" + lid
                response = requests.delete(url, auth=(token, ""))
                print label, ":", response
    except Exception as e:
        print "Account doesn't exist"
    return


if __name__ == '__main__':
    user_list = token_store.get_email_prio_users()
    # user_list = ['*****@*****.**']
    for email in user_list:
        print email
        remove_useless_labels(email)
			sync_url = "https://api.nylas.com"
		
		if nylas_helper.use_labels(ns):
			for label in remove_label:
				lid = nylas_helper.get_id(ns, label)
				if lid is None:
					continue
				url = sync_url+"/labels/" + lid
				response = requests.delete(url, auth=(token, ""))
				print label,":",response
		else:
			for label in remove_label:
				lid = nylas_helper.get_folder_id(ns, label)
				if lid is None:
					continue
				url = sync_url+"/folders/" + lid
				response = requests.delete(url, auth=(token, ""))
				print label,":",response
	except Exception as e:
		print "Account doesn't exist"
	return


if __name__ == '__main__':
	user_list = token_store.get_email_prio_users()
	# user_list = ['*****@*****.**']
	for email in user_list:
		print email
		remove_useless_labels(email)