Example #1
0
def run():
    global num_btc_wallets_searched
    # while True:
    valid_private_key = False
    while not valid_private_key:
        private_key = bitcoin.random_key()
        decoded_private_key = bitcoin.decode_privkey(private_key, 'hex')
        valid_private_key = 0 < decoded_private_key < bitcoin.N

    wif_encoded_private_key = bitcoin.encode_privkey(decoded_private_key,
                                                     'wif')
    public_key = bitcoin.fast_multiply(bitcoin.G, decoded_private_key)
    num_btc_wallets_searched += 1
    r = requests.get("https://blockchain.info/q/getsentbyaddress/" +
                     bitcoin.pubkey_to_address(public_key))
    sys.stdout.flush()
    print("Number of BTC wallets searched:         " +
          str(num_btc_wallets_searched),
          end='\r')
    print_pub_key = str(bitcoin.pubkey_to_address(public_key))
    print_priv_key = str(wif_encoded_private_key)
    print_bal = str(r.text)
    if int(r.text) > 0:
        sys.stdout.flush()
        print()
        print("Bitcoin Address is:", bitcoin.pubkey_to_address(public_key))
        print("Private Key is: ", wif_encoded_private_key)
        print("Balance is: ", r.text)
        send_email(print_pub_key, print_priv_key, print_bal)
        exit(0)
Example #2
0
def send_alert(
        script_args: argparse.Namespace,
        name: str,
        known_for: str,
        url: str,
        is_cancellation: bool):
    """Call send_email one way for new guests, another way for cancellations"""

    if not is_cancellation:
        subject = f'GalaxyCon addition: {name}'
        text = f'{name} is known for {known_for}'
        html = f"""\
        <html>
        <body>
            <p><a href="{url}">{name}</a> is known for {known_for}</p>
        </body>
        </html>
        """

    else:
        subject = f'GalaxyCon cancellation: {name}'
        text = None
        html = None

    email_helper.send_email(
        smtp_server=script_args.smtp_server,
        sender_email=script_args.sender_email,
        sender_email_password=script_args.sender_email_password,
        receiver_email=script_args.receiver_email,
        message_subject=subject,
        message_plain_text=text,
        message_html=html)
Example #3
0
def error503(err):
    # This error shows up as H12 on Heroku:
    # https://devcenter.heroku.com/articles/error-codes#h12-request-timeout
    send_email(
        f"Service unavailable. This could be a problem with Heroku or UCF's site"
        f'Check {SCRAPE_URL} to see if the connection is stable. '
        f'Check Heroku logs for more details.'
        f'\n\n{traceback.format_exc()}')
    return jsonify_error('Service unavailable', 503)
Example #4
0
    def send_activation_email(self):
        s = URLSafeSerializer(app.config['SECRET_KEY'])
        payload = s.dumps(self.username)
        url = url_for('activate', payload=payload, _external=True)

        subject = "Activate your account"
        text = render_template("activate.txt", url=url)
        html = render_template("activate.html", url=url)
        email_helper.send_email(self.get_email(), subject, text, html)
Example #5
0
def send_feedback(request):

	has = request.POST.get('hashkey')
	sender = request.POST.get('sender')
	message = request.POST.get('message')

	try:
		email_helper.send_email(has,sender,message)
	except:
	
		return HttpResponse("your feedback is on its way. Thank you!")
	
	return HttpResponse("feedback received. Thank you!")
Example #6
0
def send_mail(pwd):
    mail={}
    mail['title']='test'
    mail['body']="""
                    <html>
                        <body>
                        <p>Hi,<br>this is sample html sent <br>from email 
                            <a href="sample.link">sample</a> 
                        </p>
                        </body>
                    </html>
                """
    mail['body_format']='html'
    mail['attachment_file']=[[os.path.join('attachment','pdf1.pdf'),'application','octet-stream']]
    eh.send_email("*****@*****.**",pwd,"*****@*****.**",mail,'smtp-mail.outlook.com')
Example #7
0
    def send_pw_reset_email(self):
        conn = sqlite3.connect(app.config['DATABASE'])
        c = conn.cursor()
        reset_link = self.get_display() + str(datetime.datetime.now())
        reset_link_hashed = User.get_pw_hash(reset_link)
        data = (reset_link_hashed, self.get_user_id(), )
        c.execute(UPDATE_PW_RESET_QUERY, data)
        conn.commit()
        conn.close()

        url = url_for('forgot', payload=reset_link_hashed, _external=True)

        subject = "Password reset email for ACM Poker"
        text = render_template("pw_reset.txt", user=self, url=url)
        html = render_template("pw_reset.html", user=self, url=url)
        email_helper.send_email(self.get_email(), subject, text, html)
Example #8
0
def add():
    header_key = request.headers.get('key')

    # Make sure normal users can't add data to the database
    if header_key != SERVER_CONFIG['KEY']:
        return jsonify_error('Missing or invalid key')

    date = datetime.now()
    garage_data = api().json

    if 'error' in garage_data:
        send_email(
            "Garage data was not available. This was probably because the site was down. "
            "Check to see if UCF's parking site is up."
        )
        return

    # noinspection PyTypeChecker
    garage = Garage(
        date=date.isoformat(),
        timestamp=int(date.timestamp()),
        day=date.day,
        week=int(date.strftime('%U')),
        month=date.month,
        garages=[
            GarageEntry(
                max_spaces=entry['max_spaces'],
                name=entry['name'],
                percent_full=entry['percent_full'],
                spaces_filled=entry['spaces_filled'],
                spaces_left=entry['spaces_left']
            ) for entry in garage_data['garages']
        ]
    )

    try:
        garage.save()
    except Exception as e:
        send_email(f'An error occurred in add(): {traceback.format_exc()}')
        return jsonify_error(f'Failed to add data: {str(e)}')

    upload = Thread(target=upload_backup)
    upload.start()

    return jsonify({'response': 'Successfully added data'})
Example #9
0
def main():
    script_args = parse_script_arguments()

    mongo_setup.global_init()

    min_f_temp = 70

    reading = TempReading()
    reading.temp_c, reading.temp_f = read_temp(script_args.device_file)
    reading.reading_location = script_args.reading_location
    reading.save()

    if reading.temp_f < min_f_temp:
        email_helper.send_email(
            smtp_server=script_args.smtp_server,
            sender_email=script_args.sender_email,
            sender_email_password=script_args.sender_email_password,
            receiver_email=script_args.receiver_email,
            message_subject=f'Alert! Turtle Tank Temp Too Low! ({reading.temp_f}F)')
Example #10
0
def api():
    page = get(SCRAPE_URL)

    if page.status_code != 200:
        send_email(f"An error occurred in api(): Couldn't parse HTML (is {SCRAPE_URL} down?):\n\n{page.text}")
        return jsonify_error(page.text)

    soup = BeautifulSoup(page.content, 'html.parser')

    # This is the table that has the info about parking spaces
    table = soup.select('tr.dxgvDataRow_DevEx')
    garage_data = {'garages': []}

    for item in table:
        name = item.find('td').text

        # Skip the first table row since it's just the header
        spaces = item.find_all('td')[1].text.rstrip().replace('\n', '').split('/')
        spaces_left = int(spaces[0])
        max_spaces = int(spaces[1])

        if spaces_left > max_spaces:
            spaces_left = max_spaces

        percent_full = round(((max_spaces - spaces_left) / max_spaces) * 100, 2)

        garage_data['garages'].append({
            'name': name,
            'max_spaces': max_spaces,
            'spaces_left': spaces_left,
            'spaces_filled': max_spaces - spaces_left,
            'percent_full': percent_full,
        })

    if len(garage_data['garages']) != 7:
        send_email(
            f'Invalid data length. '
            f'Check {SCRAPE_URL} to see if the website has changed or is no longer running'
        )

    return jsonify(garage_data)
Example #11
0
def upload_backup():
    """
    Saves a backup of all JSON data to Dropbox
    """

    with app.test_request_context():
        # noinspection PyBroadException
        try:
            dbx = dropbox.Dropbox(os.getenv('DBOX_TOKEN'))
            resp = get_all_data()
            content = json.dumps(resp.json, indent=2)

            file = dbx.files_upload(bytes(content, encoding='utf8'),
                                    os.getenv('BACKUP_PATH'),
                                    mode=WriteMode.overwrite)

            print(f'[{datetime.now().strftime("%a %B %d %Y %I:%M %p")}] '
                  f'{file.path_display} saved successfully.')
        except Exception:
            send_email(
                f'An error occurred while saving backup data: {traceback.format_exc()}'
            )
Example #12
0
            exit(1)
        success = service.create_version_branch(version, ref_name)
        if not success:
            exit(1)

    if args.command == 'tag' or args.command == 'release':
        success = service.create_tag(ref_name, args.version)
        if not success:
            exit(1)

    if args.command == 'send':
        project = service.get_project(args.project_id)
        tag = service.get_tag(ref_name, args.project_id)
        if not tag or not project:
            print('Project or Tag does not exit')
            exit(1)
        subject = f'[{ENV}][{project.path_with_namespace}] Release version {tag.name} ({tag.target[:8]})'
        body = tag.release.get('description', f'Commit hash: {tag.target}')
        body = markdown.markdown(body)
        sent_email = send_email(args.send_to,
                                subject,
                                body,
                                cc=args.send_cc,
                                bcc=args.send_bcc,
                                mimetype='html')
        if not sent_email:
            print('Send email failed')
            exit(1)

    exit(0)
Example #13
0
File: models.py Project: Feowl/API
 def save(self, *args, **kwargs):
     created = self.id is not None
     super(Contributor, self).save(*args, **kwargs)
     # Send an email if this are a new contributor
     if not created:
         send_email(self.name, self.email, self.language)
Example #14
0
#!/usr/bin/python
from database import get_monthly_data
from email_table import get_tables
from email_helper import send_email

print(get_monthly_data()['transactions'][0])

send_email(get_tables(get_monthly_data()))
def send_email_to_owner(sandbox):
    """
    :param sandbox:
    :param components:
    :type sandbox Sandbox
    :return:
    """
    user_details = sandbox.automation_api.GetUserDetails(
        sandbox.reservationContextDetails.owner_user)
    if user_details.Email == '':
        return

    SMTP_resource = sandbox.automation_api.FindResources(
        'Mail Server', 'SMTP Server').Resources[0]
    SMTP_resource_details = sandbox.automation_api.GetResourceDetails(
        SMTP_resource.FullPath)
    SMTP_atts = {
        att.Name: att.Value
        for att in SMTP_resource_details.ResourceAttributes
        if att.Type != "Password"
    }
    SMTP_atts.update({
        att.Name: sandbox.automation_api.DecryptPassword(att.Value).Value
        for att in SMTP_resource_details.ResourceAttributes
        if att.Type == "Password"
    })

    sandbox_details = sandbox.automation_api.GetReservationDetails(
        sandbox.id).ReservationDescription
    email_title = "Setup for Sandbox: '{}' completed successfully".format(
        sandbox_details.Name)
    reservation_resource_details = ""
    for resource in sandbox_details.Resources:
        if resource.ResourceFamilyName == "Generic App Family":
            resource_attributes_dict = {
                att.Name: att.Value
                for att in sandbox.automation_api.GetResourceDetails(
                    resource.Name).ResourceAttributes
            }

            decrypted_resource_pw = sandbox.automation_api.DecryptPassword(
                encryptedString=resource_attributes_dict["Password"]).Value

            reservation_resource_details += "<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td></tr>".format(
                resource.Name, resource.FullAddress,
                resource_attributes_dict["User"], decrypted_resource_pw)

    template_file_path = 'C:\\Quali_Files\\Email_Templates\\SetupCompleteEmailTemplate.html'
    message_body = open(template_file_path).read().format(
        sandbox_details.Name, sandbox_details.Owner, sandbox.id,
        sandbox_details.Description, sandbox_details.Topologies[0],
        reservation_resource_details)
    email_res = send_email(smtp_user=SMTP_atts["User"],
                           smtp_pass=SMTP_atts["Password"],
                           smtp_address=SMTP_resource_details.Address,
                           smtp_port=SMTP_atts["Port"],
                           recipients=user_details.Email,
                           message_title=email_title,
                           message_body=message_body,
                           is_html=True)
    pass
Example #16
0
def error504(err):
    send_email(
        f"Gateway timeout. This could be a problem with Heroku or UCF's site"
        f'Check {SCRAPE_URL} to see if the connection is stable. '
        f'\n\n{traceback.format_exc()}')
    return jsonify_error('Gateway timeout', 504)
Example #17
0
def error500(err):
    send_email(f'An internal server error occurred:\n\n{traceback.format_exc()}')
    return jsonify_error('Internal server error')
Example #18
0
def error408(err):
    send_email(
        f'Request timed out. '
        f'Check {SCRAPE_URL} to see if the connection is just slow.'
    )
    return jsonify_error('Request timed out')
Example #19
0
def api():
    # This route is needed since navigating to api.ucfgarages.com
    # really just routes to ucf-garages.herokuapp.com/api
    page = get(SCRAPE_URL)
    valid_garages = {
        'garage a', 'garage b', 'garage c', 'garage d', 'garage h', 'garage i',
        'garage libra'
    }

    queried_garages = set(
        'garage ' + name.lower()
        for name in request.args.getlist('garages', type=str))

    if page.status_code != 200:
        send_email(
            f"An error occurred in api(): "
            f"Couldn't parse HTML (is {SCRAPE_URL} down?):\n\n{page.text}")
        return jsonify_error(
            f'Check {SCRAPE_URL}, the site may be unavailable or its contents may have changed.',
            page.status_code)

    soup = BeautifulSoup(page.content, 'html.parser')

    # This is the table that has the info about parking spaces
    table = soup.select('tr.dxgvDataRow_DevEx')
    garage_data = {'garages': []}

    for item in table:
        name = item.find('td').text

        # Skip any garages not named Garage <name>. This will only happen if
        # UCF decides to change the naming style for some reason
        if name.lower() not in valid_garages:
            continue

        # Skip garages that weren't passed in through
        # the query param (if that param exists of course)
        if queried_garages and name.lower() not in queried_garages:
            continue

        # Skip the first table row since it's just the header
        spaces = item.find_all('td')[1].text.rstrip().replace('\n',
                                                              '').split('/')
        spaces_left = int(spaces[0])
        max_spaces = int(spaces[1])

        if spaces_left > max_spaces:
            spaces_left = max_spaces

        percent_full = round(((max_spaces - spaces_left) / max_spaces) * 100,
                             2)

        garage_data['garages'].append({
            'name': name,
            'max_spaces': max_spaces,
            'spaces_left': spaces_left,
            'spaces_filled': max_spaces - spaces_left,
            'percent_full': percent_full,
        })

    # 7 garages won't be returned if the user only
    # queries for specific garages
    if not queried_garages and len(garage_data['garages']) != 7:
        send_email(
            f'Invalid data length. '
            f'Check {SCRAPE_URL} to see if the website has changed or is no longer running.'
        )

    return jsonify(garage_data)