Beispiel #1
0
def get_token():

    token_url = 'https://auth.emsicloud.com/connect/token'

    client_id = creds.credentials()['username']
    client_secret = creds.credentials()['password']
    scope = 'emsiauth'
    grant = 'client_credentials'
    token_headers = {'content-type': 'application/x-www-form-urlencoded'}

    token_payload = f'grant_type={grant}&client_id={client_id}&client_secret={client_secret}&scope={scope}'

    token_response = requests.request(url=token_url,
                                      method='POST',
                                      data=token_payload,
                                      headers=token_headers)
    token = (token_response.json())['access_token']
    return token
Beispiel #2
0
def send_txt_msg(msg):
    """Send text message via Twilio with msg as the body."""
    account_sid, auth_token = credentials()
    to_number, from_number = tel_numbers()
    client = Client(account_sid, auth_token)

    client.messages.create(to=to_number,
                           from_=from_number,
                           body='Dates found:' + str(msg))
Beispiel #3
0
__version__ = 'mdl 1.0.1'
__author__ = 'Chris Pickford <*****@*****.**>'
'''
Ensure any virtual environments have been activated before running scripts
'''
import os
import sys
import config as cfg

os.chdir(os.path.dirname(os.path.abspath(__file__)))
cwd = os.getcwd()
print('Working directory set as:', cwd)

PROJECT_NAME = 'TimeSeriesKb'
config = cfg.privateConfig(cfg.OS, PROJECT_NAME)
newUser = cfg.credentials()
logFileName = PROJECT_NAME + '.log'
_ = config.set_logging(logFileName)

rootPath = config.ROOT
sys.path.append(os.path.join(rootPath))
sys.path.append(os.path.join(config.PACKAGE_ROOT, 'DataCrane'))

config.abort_pass_programme(logString='-------Program Started-------')

from DataCrane.dbutility import gnrl_database_interaction as gdbi
from DataCrane.dbutility import credentials
config.abort_pass_programme(logString=' Imported DataCrane ')

##################################################################################################################
Beispiel #4
0
import wikipedia
import re
import praw
from urllib.parse import urlparse
from config import credentials

# create reddit instance
info = credentials()
reddit = praw.Reddit(user_agent="Wikipedia Summary Bot (by /u/KobeeKodes)",
                     client_id=info[0],
                     client_secret=info[1])

for comment in reddit.subreddit('all').stream.comments():
    if ('https://en.wikipedia.org/wiki'
            or 'http://en.wikipedia.org/wiki') in str(comment.body):
        #print(str(comment.body))

        urls = re.findall(
            r'http[s]?://en.wikipedia.org/wiki/(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+[^]?]',
            comment.body)
        print(urls)
        # extract topic
        topics = []
        for url in urls:
            if 'https' in url:
                topics.append(url[30:])
            else:
                topics.append(url[29:])

        for topic in topics:
            topic = topic.replace('_', ' ').replace('%', '').replace(
Beispiel #5
0
# Import librerie
from collections import OrderedDict
from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt
from datetime import date, datetime
from calendar import monthrange
import os
from schema import selectImages
from config import credentials

copernicusHubAuth = credentials()
username = copernicusHubAuth[0]
password = copernicusHubAuth[1]

# Connessione alle API
api = SentinelAPI(username, password)

# Parametri di ricerca variabili
platform = 'Sentinel-2'
product = 'S2MSI2A'  #'S2MSI2A' (mesi da 03 a 12 del 2018) o 'S2MSI2Ap' (mesi 01, 02, 03 del 2018)
regione = 'Puglia'
anno = '2019'
# Parametri di ricerca derivati
# fromDate = date(int(anno), int(mese),1).strftime('%Y%m%d')
# toDate = date(int(anno), int(mese), monthrange(int(anno), int(mese))[1]).strftime('%Y%m%d')
tiles = selectImages(regione)

# Directory di download
sentinel_dir = os.path.join(r'\\izsfs\dati-gis\SENTINEL2', anno)
# img_dir = os.path.join(regione, anno+'_'+mese)
download_dir = os.path.join(sentinel_dir, regione)
Beispiel #6
0
import pandas as pd
import config
from pymysql import connect, Error

credentials = config.credentials()
password = credentials.pass_sql
user = credentials.text_user


class conn_sql():

    # Constructor
    def __init__(self,
                 host='162.243.165.69',
                 port=3306,
                 user=user,
                 passwd=password,
                 db=None):
        self.host = host
        self.port = port
        self.user = user
        self.passwd = passwd
        self.db = db

    # Methods
    def create_connection(self):
        self.db_connection = connect(host=self.host,
                                     port=self.port,
                                     user=self.user,
                                     passwd=self.passwd,
                                     database=self.db)