コード例 #1
0
ファイル: text.py プロジェクト: rt0112358/texter
def send_message(destination):
    email = credentials.username()
    pssword = credentials.password()

    server = sign_in(email, pssword)

    num_messages = 10
    for i in range(num_messages):
        # time.sleep(0.5) # Uncomment to ensure chronological order
        server.sendmail(email, destination, "Hello " + str(i))
コード例 #2
0
def sendEmail(to, content):
    import credentials
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.ehlo()
    server.starttls()

    # Enable low security in gmail
    server.login(credentials.email(), credentials.password())
    server.sendmail(credentials.email(), to, content)
    server.close()
コード例 #3
0
ファイル: server.py プロジェクト: faketastic/server
# XXX: The Database URI should be in the format of: 
#
#     postgresql://USER:PASSWORD@<IP_OF_POSTGRE_SQL_SERVER>/<DB_NAME>
#
# For example, if you had username ewu2493, password foobar, then the following line would be:
#
#     DATABASEURI = "postgresql://*****:*****@<IP_OF_POSTGRE_SQL_SERVER>/postgres"
#
# For your convenience, we already set it to the class database

# Use the DB credentials you received by e-mail
# DB_USER = "******"
# DB_PASSWORD = "******"
DB_USER = credentials.username()
DB_PASSWORD = credentials.password()

# DB_SERVER = "w4111.cisxo09blonu.us-east-1.rds.amazonaws.com"
DB_SERVER = "mydbinstance.cmgiyjltohsu.us-east-1.rds.amazonaws.com"

# DATABASEURI = "postgresql://"+DB_USER+":"+DB_PASSWORD+"@"+DB_SERVER+"/w4111"
DATABASEURI = "postgresql://"+DB_USER+":"+DB_PASSWORD+"@"+DB_SERVER+"/FakeTasticdb"

#
# This line creates a database engine that knows how to connect to the URI above
#
engine = create_engine(DATABASEURI)


# Here we create a test table and insert some values in it
engine.execute("""DROP TABLE IF EXISTS test;""")
コード例 #4
0
## Psycopg2 remote setup
try:
    remoteDB = psycopg2.connect(database=rc.database(), host=rc.hostname(), port=rc.port(),
                  user=rc.username(), password=rc.password())
    remoteCUR = remoteDB.cursor()
except:
    print "Unable to connect to remote database"
    print sys.exc_info()[1]
    sys.exit()


## Psycopg2 local setup
try:
    DB = psycopg2.connect(database=c.database(), host=c.hostname(), user=c.username(), 
            password=c.password())
    CUR = DB.cursor()
except:
    print "Unable to connect to local database"
    print sys.exc_info()[1]
    sys.exit()


## Desc - Gets the remote comments such that start <= x < end, where x is the comments.
## In   - (chunkSize) integer of the number of comments to pull from remote database
## Out  - list of comment objects
## Mod  - Nothing
## ToDo - Return status code?
##      - Add try except block for connection issues?
def getRemoteComments(chunkSize=25):
    comments = []
コード例 #5
0
ファイル: __init__.py プロジェクト: Marczok/BachelorProject
            rem_in_percents, wake_in_percents, phase_duration_average_in_hours,
            phase_duration_average_in_percents, deviation_in_hours,
            deviation_in_percents, all_count, deep_count, light_count,
            rem_count, wake_count, deep_count_per_hour, light_count_per_hour,
            rem_count_per_hour, wake_count_per_hour, one, two, three,
            one_per_hour, two_per_hour, three_per_hour
        ]


if __name__ == '__main__':
    locale.setlocale(locale.LC_ALL, 'czech')
    try:
        cnx = mysql.connector.connect(user=cr.user(),
                                      database=cr.database(),
                                      host=cr.host(),
                                      password=cr.password())
        cursor = cnx.cursor()
        parsing = Parsing()
        chart_class = Chart()
        csv_save = CSVSave()
        database = DatabaseWorks()
        data_processing = DataProcessing()

        print(
            "\n##################################################################################\n"
        )
        database.print_last_sync_info(cursor, parsing)
        print(
            "\n##################################################################################\n"
        )
        database.print_fitbit_sync_info(cursor, parsing)
コード例 #6
0
'''

import imaplib
import credentials
import re
import numpy as np
import pandas as pd
import os
import glob

## ---- preamble [some info to edit] ---- ##
imap_ssl_host = 'imap.gmail.com'
imap_ssl_port = 993
username = credentials.username()
password = credentials.password()
mission_id = 'M333'
paths = [
    '/home/cyrf0006/data/gliders_data/SEA003/M333/Nav',
    '/home/cyrf0006/data/gliders_data/SEA003/M333/science'
]

## ---- PART 1 - get time from gmail ---- ##
print('PART 1 - get time from gmail')
# initialize fields to fill
lat_dec = []
lat_min = []
lon_dec = []
lon_min = []
time_str = []
cycle_no = []
コード例 #7
0
## Globals
WAIT_INTERVAL = 1
MAX_WAIT_TIME = 60
WAIT_TIME = 30
MIN_WAIT_TIME = 2  ## Minimum time between requests (according to reddit API)
ROWS = 0

## Praw setup
USER_AGENT = ("F1Bot 0.1")
REDDIT = praw.Reddit(USER_AGENT)
SUBREDDIT = REDDIT.get_subreddit("formula1")

## Psycopg2 setup
try:
    DB = psycopg2.connect(database=c.database(), host=c.hostname(),
                  user=c.username(), password=c.password())
    CUR = DB.cursor()
except:
    print "Unable to connect to database"
    print sys.exc_info()[1]
    sys.exit()


## Desc - Counts the number of rows in the database
## In   - Nothing (cursor defined globally)
## Out  - long int rows
## Mod  - Nothing
## ToDo - Nothing
def countRows():
    CUR.execute("SELECT COUNT(*) FROM f1_bot;")
    return CUR.fetchone()[0]
コード例 #8
0
def main():
    """ Пример получения последнего сообщения со стены """

    login, password = credentials.login(), credentials.password()
    vk_session = vk_api.VkApi(login, password)

    try:
        vk_session.auth(token_only=True)
    except vk_api.AuthError as error_msg:
        print(error_msg)
        return

    vk = vk_session.get_api()
    """ VkApi.method позволяет выполнять запросы к API. В этом примере
        используется метод wall.get (https://vk.com/dev/wall.get) с параметром
        count = 1, т.е. мы получаем один последний пост со стены текущего
        пользователя.
    """

    items = set()

    with open(f'events_{location_name}.txt', 'r') as fp:
        num_lines = sum(1 for ln in fp)
        events_count = 0
        fp.seek(0)
        for event in fp:
            events_count += 1
            print(f'{events_count}/{num_lines}')
            print(f'Event {event}')
            offset = 0
            while True:
                try:
                    q = vk.groups.getMembers(group_id=event, offset=offset)
                    items.update(q['items'])
                    if len(q['items']) < 1000:
                        break
                    offset += 1000
                except vk_api.exceptions.ApiError as e:
                    print(e)
                    break
                except:
                    break

            offset = 0
            while True:
                try:
                    q = vk.groups.getMembers(group_id=event,
                                             offset=offset,
                                             filter='unsure')
                    items.update(q['items'])
                    if len(q['items']) < 1000:
                        break
                    offset += 1000
                except vk_api.exceptions.ApiError as e:
                    print(e)
                    break
                except:
                    break

            print(len(items))
            pass

    with open(f'events_members_{location_name}.txt', 'w') as f:
        for item in items:
            f.write("%s\n" % item)