def main(): """Begin executing main logic of the script. """ # Parse command line args. parser = argparse.ArgumentParser() parser.add_argument('--config_file', metavar='FILE', help='config YAML', default='config.yaml') parser.add_argument('--symbols_file', metavar='FILE', help=( 'historical_data_config symbols_file')) parser.add_argument('--output_dir', metavar='FILE', help=( 'historical_data_config output_dir')) parser.add_argument('--start_date', metavar='YYYYMMDD', help=( 'historical_data_config start_date')) parser.add_argument('--end_date', metavar='YYYYMMDD', help=( 'historical_data_config end_date')) args = parser.parse_args() # Load config and overwrite any values set by optional command line args. with open(args.config_file, 'r') as config_file: config = yaml.load(config_file.read()) if args.symbols_file is not None: config['historical_data_config']['symbols_file'] = args.symbols_file if args.output_dir is not None: config['historical_data_config']['output_dir'] = args.output_dir if args.start_date is not None: config['historical_data_config']['start_date'] = args.start_date if args.end_date is not None: config['historical_data_config']['end_date'] = args.end_date # Setup logger. logging.config.dictConfig(config['logging_config']) logger = logging.getLogger(__name__) # Get daily historical data. data = historical_data.HistoricalData(config['historical_data_config'], config['tor_scraper_config']) daily = data.get_daily() if daily is None: logger.error('No daily dataframe') sys.exit(1) # If respective configs exist, create and send email reports. if 'portfolio_report_config' in config: portfolio = portfolio_report.PortfolioReport( config['portfolio_report_config'], daily).get_report() sender = emailer.Emailer(config['emailer_config']) sender.send(subject=portfolio['subject'], message_parts={ 'plain_body': portfolio['plain_body'], 'files': portfolio['files']}) if 'universe_report_config' in config: universe = universe_report.UniverseReport( config['universe_report_config'], daily).get_report() sender = emailer.Emailer(config['emailer_config']) sender.send(subject=universe['subject'], message_parts={ 'plain_body': universe['plain_body']})
def __init__(self, login="", password="", key_delay=500, email_delay=1000): self.KEY_DELAY_MAX = key_delay self.EMAIL_DELAY_MAX = email_delay self.captured_keys = [] self.key_delay_counter = ticker.Ticker() self.email_delay_counter = ticker.Ticker() self.sender = emailer.Emailer(login, password) self.sender.start()
def send_email_to_new_user(email, email_config): title = '[{}] Your access request has been approved' subject = title.format(email_config['title']) emailer_ent = emailer.Emailer() emailer_ent.send(to=email, subject=subject, template_path='email_to_new_user.html', kwargs={ 'email': email, 'email_config': email_config }) logging.info('Emailed new user -> {}'.format(email))
def send_email_to_existing_user(email, email_config, kwargs=None): title = '[{}] Your access has been updated' subject = title.format(email_config['title']) params = {'email': email, 'email_config': email_config} if kwargs: params.update(kwargs) emailer_ent = emailer.Emailer() emailer_ent.send(to=email, subject=subject, template_path='email_to_existing_user.html', kwargs=params) logging.info('Emailed existing user -> {}'.format(email))
def send_email(self): ''' (self) -> None Send an email, and create a png of global estimates, but only if the user is not codem or nmarquez. Don't send an email to [email protected] ever (it is a real person). ''' email_body = self.create_email_body() s = email.Server("smtp.gmail.com", 'EMAIL', 'PASSWORD') s.connect() e = email.Emailer(s) # add graphs e.add_attachment('FILEPATH.png') e.add_attachment('FILEPATH.png') e.add_attachment('FILEPATH.png') e.add_attachment('FILEPATH.png') e.add_attachment('FILEPATH.png') # add the submodel table as an attachment e.add_attachment("FILEPATH.csv") e.add_attachment("FILEPATH.csv") recipients = set(self.get_modeler() + [self.inserted_by]) recipients = [x for x in recipients if x not in ["codem"]] for recipient in recipients: e.add_recipient('%s@EMAIL' % recipient) if self.model_version_type_id == 1: model_version_string = "global" else: model_version_string = "data rich" e.set_subject( 'CODEm model complete for {acause}, sex {sex}, age group ids {age_start}-{age_end}, ' '{mtype}, model version {mvid}'.format(acause=self.acause, mvid=self.model_version_id, mtype=model_version_string, sex=self.sex_id, age_start=self.age_start, age_end=self.age_end)) e.set_body(email_body) e.send_email() s.disconnect()
def main(): conf = get_config_yaml(CONF_FILE_NAME) email = conf['gmail']['email'] password = conf['gmail']['password'] subject = 'Have you already written a diary today?' body = ("If you haven't done yet, click the link and write it soon\n" "https://penzu.com/journals") emailer_obj = emailer.Emailer() emailer_obj.set_smtp('smtp.gmail.com', 587, email, password) sending_result = emailer_obj.send(email, conf['to'], subject, body) if sending_result == {}: print("{}: sending a email is success.".format(datetime.now())) else: print("{}: sending a email is failed.".format(datetime.now())) emailer_obj.quit()
def register(): email = flask.request.json.get('email') password = flask.request.json.get('password') if email is None or password is None: raise AuthenticationError('Missing credentials.') if model.User.objects(email=email).first(): raise AuthenticationError('User already exists.') user = model.User(email=email) user.hash_password(password) user.create_activation_token() user.save() mail = emailer.Emailer() message = config.PROD_ACTIVATION_LINK.format(_id=str(user.id), token=user.activation_token) thr = Thread(target=mail.send_text, args=[[user.email], message]) thr.start() return flask.jsonify(make_user_response(user))
def send_email_to_admins(req, email_config): # Normalize encoding for rendering email template. if 'form' in req: for i, question in enumerate(req['form']): answer = question.answer if isinstance(answer, unicode): answer = answer.encode('utf-8') if answer: req['form'][i].answer = answer.decode('utf-8') admin_emails = get_admins(notify_only=True) if not admin_emails: logging.error('No admins to email.') return emailer_ent = emailer.Emailer() emailer_ent.send(to=admin_emails, subject='[{}] Request for access from {}'.format( email_config['title'], req['email']), template_path='email_to_admins.html', kwargs={ 'req': req, 'email_config': email_config }) logging.info('Emailed admins -> {}'.format(', '.join(admin_emails)))
def send_email(self): ''' (self) -> None Send an email, and create a png of global estimates, but only if the user is not codem or nmarquez. ''' email_body = self.create_email_body() if self.inserted_by == "codem" or self.inserted_by == "nmarquez" or self.inserted_by == "unknown": return None s = email.Server("strConnection", 'strUser', 'strPassword') # add covariate run csv df_cov = Q.all_submodel_covs(self.model_version_id) df_cov.to_csv("submodel_covs.csv", index=False) s.connect() e = email.Emailer(s) e.add_attachment('global_estimates.png') e.add_attachment("submodel_covs.csv") e.add_recipient('*****@*****.**' % self.inserted_by) e.set_subject('CODEm run update for {}'.format(self.acause)) e.set_body(email_body) e.send_email() s.disconnect()
import emailer Email = emailer.Emailer('Test Message', 'This is a test message') Email.SendEmail('./test.py')
import pandas as pd import emailer # Initialse all email details and build emailer object email = "" password = "" subject = "RTX 2080ti on sale" message = "Good news! The NVidia RTX 2080ti is now below £1000. Maybe time for an upgrade?" EM = emailer.Emailer(email, password, subject, message) def full_email(): EM.serverConnect() EM.sendMail(subject, message) def checkPrice(): # Checks whether at least one of the products is less than £1000 answer = 'false' df = pd.read_csv("products.csv") for i in df[' price']: if float(i) < 1000: answer = "true" # If item is on sale, email user if answer == "true": full_email()
def main(): scr = scraper.Scraper() sms = emailer.Emailer("fakename", "fakepassword") scr.run() sms.sendSMS("fakenumber", scr.getPreparedMessage())
def __init__(self): self.mailbox = emailer.Emailer() self.browser = None
#https://github.com/miguelgrinberg/flask-video-streaming/issues/39 http = "https://" #async_mode='threading' async_mode = 'eventlet' if async_mode == 'eventlet': # we want to use eventlet (otherwise https certfile doens't work on socketio) # but we're using a python thread - so we have to monkeypatch import eventlet eventlet.monkey_patch() socketio = SocketIO(app, async_mode=async_mode) import emailer sender = emailer.Emailer() # GPIO door2 = 7 # GPIO4 door1 = 37 # GPIO26 relay1 = 8 # GPIO14 relay2 = 10 # GPIO15 def setupgpio(): GPIO.setmode(GPIO.BOARD) # use PHYSICAL GPIO Numbering GPIO.setup(door1, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(door2, GPIO.IN, pull_up_down=GPIO.PUD_UP) # connection is on the NO (normally open) port
global lastMotionTime if motionDetected: motionDetected = False else: lastMotionTime = time.time() motionDetected = True GPIO.add_event_detect(MOTION_PIN, GPIO.BOTH, callback=motion_callback) #main body PiCam = picamera.PiCamera() Filer = Cvt2Mp4.FileHelper() Mailer = emailer.Emailer() Filer = Cvt2Mp4.FileHelper() #state machine variables '''States = { 'idle' : 0, 'start_capture' : 1, 'capture' : 2, 'stop_capture' : 3, 'send_email' : 4 } ''' idle = 0 start_capture = 1 capture = 2 stop_capture = 3