Example #1
0
 def save(self,
          subject,
          email_template_name='registration/password_reset_email.html',
          use_https=False,
          token_generator=default_token_generator,
          from_email=None,
          request=None):
     """
     Generates a one-use only link for resetting password and sends to the
     user.
     """
     for user in self.users_cache:
         ctx = {
             'email': user.business_email,
             'site': settings.SITE_HOSTNAME,
             'uid': urlsafe_base64_encode(force_bytes(user.pk)),
             'user': user,
             'token': token_generator.make_token(user),
             'protocol': use_https and 'https' or 'http',
             'site_name': settings.SITE_NAME,
             'contact_address': settings.CONTACT_ADDRESS,
         }
         options = {
             'subject': subject,
             'from_email': from_email,
             'to': [user.business_email],
             'template_name': email_template_name,
             'context': ctx
         }
         mail.notify(options)
Example #2
0
def process(filename):		
	reader = csv.DictReader(open('//barnabas/Users/applyweb/' + filename, "rb"))	
	flagged_records = {}
	fileinfo = {}	
	fileinfo['StartTime'] = datetime.now().strftime('%m-%d-%Y %H:%M:%S')
	records = 0
	for row in reader:
		records += 1
		dup_info = {}
		row["FULLNAME"] = "%s, %s %s" % (row["NAME_LAST"].strip(), row["NAME_FIRST"].strip(), row["NAME_MIDDLE"].strip())		
		dup_info, isdup = scan_dupe(row["NAME_LAST"].strip(), row["NAME_FIRST"].strip(), row["NAME_MIDDLE"].strip(), row["STATE"].strip())		
		if not isdup:
			#load_data(row)			
			pass
		else: #finished here on 7 march, 2011. flagged_records should contain all of the matches for each record
			flagged_records[row["FULLNAME"]] = dup_info
	'''
		now i just need to load the file info into the redis db
	'''
	fileinfo['TotalRecords'] = records	
	fileinfo['FinishTime'] = datetime.now().strftime('%m-%d-%Y %H:%M:%S')
	fileinfo['FileName'] = filename
	if len(flagged_records) > 0:
		fileinfo['Flagged'] = flagged_records
	import mail
	mail.notify(fileinfo)
	print json.dumps(fileinfo)
	
	import dbi
	db = dbi.dbi()
	db.conn()
	db.set(filename.split('.')[0], json.dumps(fileinfo))
	
	print 'Data Stored'
Example #3
0
def test_notify_uses_default_from_when_missing_from_address():
    params = options.copy()
    del params['from_email']

    notify(params)
    msg = django_mail.outbox[0]
    assert msg.from_email == DEFAULT_FROM
Example #4
0
    def save(
        self,
        subject,
        email_template_name="registration/password_reset_email.html",
        use_https=False,
        token_generator=default_token_generator,
        from_email=None,
        request=None,
    ):
        """
        Generates a one-use only link for resetting password and sends to the
        user.
        """
        for user in self.users_cache:
            ctx = {
                "email": user.business_email,
                "site": settings.SITE_HOSTNAME,
                "uid": urlsafe_base64_encode(str(user.pk)),
                "user": user,
                "token": token_generator.make_token(user),
                "protocol": use_https and "https" or "http",
            }
            options = {
                "subject": subject,
                "from_email": from_email,
                "to": [user.business_email],
                "template_name": email_template_name,
                "context": ctx,
            }

            mail.notify(options)
Example #5
0
def test_notify_uses_default_from_when_missing_from_address():
    params = options.copy()
    del params['from_email']

    notify(params)
    msg = django_mail.outbox[0]
    assert msg.from_email == DEFAULT_FROM
Example #6
0
 def save(self, subject,
          email_template_name='registration/password_reset_email.html',
          use_https=False, token_generator=default_token_generator,
          from_email=None, request=None):
     """
     Generates a one-use only link for resetting password and sends to the
     user.
     """
     for user in self.users_cache:
         ctx = {
             'email': user.business_email,
             'site': settings.SITE_HOSTNAME,
             'uid': int_to_base36(user.pk),
             'user': user,
             'token': token_generator.make_token(user),
             'protocol': use_https and 'https' or 'http',
         }
         options = {
             'subject': subject,
             'from_email': from_email,
             'to': [user.business_email],
             'template_name': email_template_name,
             'context': ctx
         }
         mail.notify(options)
Example #7
0
def test_notify_works_with_non_valid_parameters():
    params = options.copy()
    params.update({
        'junk': False
    })
    assert len(django_mail.outbox) == 0
    notify(params)
    assert len(django_mail.outbox) == 1
Example #8
0
def test_notify_renders_template_given_as_string():
    params = options.copy()
    params['context'] = {'var': 'world'}
    params['template_name'] = 'Hello {{ var }}!'

    notify(params)
    msg = django_mail.outbox[0]
    assert msg.body == 'Hello world!'
Example #9
0
def test_notify_renders_template_given_as_string():
    params = options.copy()
    params['context'] = {'var': 'world'}
    params['template_name'] = 'Hello {{ var }}!'

    notify(params)
    msg = django_mail.outbox[0]
    assert msg.body == 'Hello world!'
Example #10
0
def test_notify_sends_all_parameters():
    params = options.copy()

    assert len(django_mail.outbox) == 0
    notify(params)
    assert len(django_mail.outbox) == 1
    msg = django_mail.outbox[0]
    for key in params:
        assert getattr(msg, key) == params[key]
Example #11
0
def test_notify_renders_template_referenced_by_name():
    template_name = 'test_email_template.html'
    params = options.copy()
    params['context'] = {'var': 'world'}
    params['template_name'] = template_name

    notify(params)
    msg = django_mail.outbox[0]
    assert msg.body == 'Hello world!\n'
Example #12
0
def test_notify_sends_all_parameters():
    params = options.copy()

    assert len(django_mail.outbox) == 0
    notify(params)
    assert len(django_mail.outbox) == 1
    msg = django_mail.outbox[0]
    for key in params:
        assert getattr(msg, key) == params[key]
Example #13
0
def test_notify_renders_template_referenced_by_name():
    template_name = 'test_email_template.html'
    params = options.copy()
    params['context'] = {'var': 'world'}
    params['template_name'] = template_name

    notify(params)
    msg = django_mail.outbox[0]
    assert msg.body == 'Hello world!\n'
Example #14
0
 def notify_email_change(
     self,
     old_address,
     new_address,
     subject="{0}: email change notification".format(settings.SITE_NAME),
     template_name="contacts/email/email_changed_body.email",
 ):
     ctx = {"user": self.instance, "old_email": old_address, "new_email": new_address}
     options = {"subject": subject, "to": [old_address, new_address], "template_name": template_name, "context": ctx}
     mail.notify(options)
Example #15
0
def run_all():
	packages = os.listdir(Software_Repo+"/apps")
	cs = capd.JSS()
	for pkg in packages:
		if not pkg.startswith('.') or pkg.endswith('.xml'):
			p = capd.Package()
			p.name = os.path.splitext(pkg)[0]
			p.extension = os.path.splitext(pkg)[1]
			create_pkg_xml(cs.jss_pkg_id(), cs.category_name, p.pkg_xml(), p.full_name())
			post_pkg(cs.url, cs.jss_category_id(), p.pkg_xml(), cs.jss_pkg_url(), cs.api_user, cs.api_pass)
			upload_pkg_to_JSS(cs.share, cs.share_username, cs.share_password, cs.hostname, p.absolute_path())
			create_pol_xml(cs.jss_category_id(), cs.category_name, cs.jss_pol_id(), cs.jss_pkg_id(), p.pol_xml(), p.full_name())
			post_pol(cs.url, cs.api_user, cs.api_pass, cs.jss_pol_url(), p.pol_xml(),)
			pkg_name = p.name.split("_")[1]
			capd.call_fabfile(pkg_name)
			mail.notify(p.full_name())
	mv_pkg_to_sequenced()
Example #16
0
 def notify_email_change(self,
                         old_address,
                         new_address,
                         subject='{0}: email change notification'.format(settings.SITE_NAME),
                         template_name='contacts/email/email_changed_body.email'):
     ctx = {
         'user': self.instance,
         'old_email': old_address,
         'new_email': new_address,
         'site_name': settings.SITE_NAME,
         'contact_address': settings.CONTACT_ADDRESS
     }
     options = {
         'subject': subject,
         'to': [old_address, new_address],
         'template_name': template_name,
         'context': ctx
     }
     mail.notify(options)
Example #17
0
def handle_request(request_json, app):
	if "commits" not in request_json:  # Top-level "commits" only in https://developer.github.com/v3/activity/events/types/#pushevent
		return

	gh_repo = gh.get_repo(request_json["repository"]["full_name"])
	gh_commit = gh_repo.get_commit(request_json["after"])
	gh_commit.create_status("pending", context="continuous-integration/format-ci")

	this_job_id = data.max_job_id() + 1

	start_time = datetime.datetime.utcnow().timestamp()
	success = not build(request_json["repository"]["full_name"], request_json["after"], gh_repo, gh_commit, this_job_id, app)
	end_time = datetime.datetime.utcnow().timestamp()
	repo_id, repo_job_num = data.update_repo_job_ids(request_json["repository"]["owner"]["name"], request_json["repository"]["name"], success, this_job_id)
	data.add_job(this_job_id, repo_id, success, start_time, end_time - start_time, request_json["after"], request_json["before"])

	if not success:
		mail.notify(set([request_json["head_commit"]["author"]["email"], request_json["head_commit"]["committer"]["email"],
		                 request_json["repository"]["owner"]["email"]]),
		            this_job_id, repo_job_num, request_json["repository"]["full_name"], request_json["after"])
Example #18
0
 def notify_email_change(
         self,
         old_address,
         new_address,
         subject='{0}: email change notification'.format(
             settings.SITE_NAME),
         template_name='contacts/email/email_changed_body.email'):
     ctx = {
         'user': self.instance,
         'old_email': old_address,
         'new_email': new_address,
         'site_name': settings.SITE_NAME,
         'contact_address': settings.CONTACT_ADDRESS
     }
     options = {
         'subject': subject,
         'to': [old_address, new_address],
         'template_name': template_name,
         'context': ctx
     }
     mail.notify(options)
Example #19
0
def test_notify_works_with_non_valid_parameters():
    params = options.copy()
    params.update({'junk': False})
    assert len(django_mail.outbox) == 0
    notify(params)
    assert len(django_mail.outbox) == 1
Example #20
0
def test_passed_connection_get_used(params):
    connection = django_mail.get_connection()
    email = notify(params, connection=connection)
    assert email.connection == connection
Example #21
0
from config import people, debug
from derangement import get_derangement
from mail import notify

names = list(people.keys())

shuffled = get_derangement(names)
if debug: print(shuffled)

i = 0
for name, email in people.items():
    chosen_person = shuffled[i]
    notify(name, email, chosen_person)
    i += 1
Example #22
0
        now = datetime.datetime.now()
        if measure.time_is_available(now):
            print("yes")
        else:
            print("no")
    elif args[0] == "list":
        epoch = datetime.datetime.utcfromtimestamp(0)
        times = measure.read_times()
        for time in times:
            millis = int((time - epoch).total_seconds() * 1000)
            print(millis)
    elif args[0] == "time":
        ms = int(time.time() * 1000)
        print(ms)
    elif args[0] == "notify":
        mail.notify()
    elif args[0] == "subscribe":
        email = args[1]

        if not mail.is_valid_email(email):
            print("Ugyldig formatert epostadresse.")
            logging.info("denied subscription from %s due to format error",
                         email)
            exit()

        if mail.is_subscribed(email):
            print("Epostadressen er allerede registrert.")
            logging.info("denied second subscription request from %s", email)
            exit()

        mail.add_subscriber(email)
Example #23
0
def test_passed_connection_get_used(params):
    connection = django_mail.get_connection()
    email = notify(params, connection=connection)
    assert email.connection == connection
Example #24
0
        #############
        #   IMAGES  #
        #############
        str_up = 'UP: ' + str(cnt_up)
        str_down = 'DOWN: ' + str(cnt_down)
        frame = cv2.polylines(frame, [pts_L1], False, line_down_color, thickness=2)
        frame = cv2.polylines(frame, [pts_L2], False, line_up_color, thickness=2)
        # line limit
        frame = cv2.polylines(frame, [pts_L3], False, (255,255,255), thickness=1)
        frame = cv2.polylines(frame, [pts_L4], False, (255,255,255), thickness=1)
        cv2.putText(frame, str_up, (10,40), font, 0.5, (255,255,255), 2, cv2.LINE_AA)
        cv2.putText(frame, str_up, (10,40), font, 0.5, (0,0,255), 1, cv2.LINE_AA)
        cv2.putText(frame, str_down, (10,90), font, 0.5, (255,255,255), 2, cv2.LINE_AA)
        cv2.putText(frame, str_down, (10, 90), font, 0.5, (255,0,0), 1, cv2.LINE_AA)
        cv2.imshow('Frame', frame)





    ### Abort and exit with 'q' or ESC ###
    if cv2.waitKey(1) & 0xff == ord('q'):
        mail.notify(cnt_down,cnt_up)
        break

### Release video file
cap.release()
cv2.destroyAllWindows() ### Close all opencv windows