Exemple #1
0
    def run(self, dispatcher: CollectingDispatcher, tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        dispatcher.utter_message(text='Storing Booking')
        cuisine = tracker.get_slot('cuisine_slot')
        numberofpeople = tracker.get_slot('num_people')
        API_KEY = '3bba5e87-358c-498c-9e19-01ee158fddd0'
        docid = "hiDjxzDYZT"
        tabid = "grid-VaHaPUZKkn"
        columnid = "c-NXfRNP3U0x"  #Tipo Comida
        columnind = "c-FOYgcNlXos"  # Número de comensales
        if hasattr(ssl, '_create_unverified_context'):
            ssl._create_default_https_context = ssl._create_unverified_context

        coda = Coda(API_KEY)
        payload = {
            'rows': [
                {
                    'cells': [{
                        'column': columnid,
                        'value': cuisine
                    }, {
                        'column': columnind,
                        'value': numberofpeople
                    }],
                },
            ],
            "keyColumns": [columnid]
        }
        coda.upsert_row(docid, tabid, payload)
        return []
Exemple #2
0
def report_usage_to_coda():
    """
    report key performance metrics to coda.io

    runs only if `CODA_API_KEY` is set. It should only be configured in production
    to prevent reporting data from local or staging environments.
    """
    if not settings.CODA_API_KEY:
        return "CODA_API_KEY is not set."

    coda = Coda(settings.CODA_API_KEY)
    doc_id, table_id = settings.CODA_DOC_ID, settings.CODA_TABLE_ID
    doc = Document(doc_id, coda=coda)
    table = doc.get_table(table_id)

    rows = []
    for user in User.objects.exclude(athlete=None):
        mapping = {
            "ID": user.id,
            "Username": user.username,
            "Email": user.email,
            "Date Joined": user.date_joined.__str__(),
            "Last Login": user.last_login.__str__(),
            "Routes Count": user.athlete.tracks.count(),
            "Strava Activities Count": user.athlete.activities.count(),
        }
        try:
            rows.append([
                Cell(column=table.get_column_by_name(key), value_storage=value)
                for key, value in mapping.items()
            ])
        except codaio.err.ColumnNotFound as error:
            message = f"Missing column in coda document at https://coda.io/d/{doc_id}: {error}"
            logger.error(message)
            raise ImproperlyConfigured(message)

    table.upsert_rows(rows, key_columns=["ID"])

    return f"Updated {len(rows)} rows in Coda table at https://coda.io/d/{doc_id}"
#    print(i) ESTE SCRIPT RECOGE LAS NOTICIAS DE FEEDLY Y 
# LAS RECOGE EN CODA
API_KEY = 'c5d228f1-a38e-4956-b6e6-f6ceaac089d0'
#rss = 'https://www.incibe-cert.es/feed/avisos-sci/all'
b = float('0.0') lenlista = len(listaulr) for rss in 
listaulr :
    print((b/lenlista)*100)
    if hasattr(ssl, '_create_unverified_context'):
        ssl._create_default_https_context = 
ssl._create_unverified_context
    d = feedparser.parse(rss.replace('"','')) #<<WORKS!!
    if (len(d.entries) > 10) :
        ent = 10
    else:
        ent = len(d.entries)
    coda = Coda('c5d228f1-a38e-4956-b6e6-f6ceaac089d0')
    for i in range(0,int(ent)) :
        try :
            publicada = d.entries[i].published_parsed
            publicadodate = date (publicada.tm_year, 
publicada.tm_mon,publicada.tm_mday)
            if ( publicadodate > limite) :
                #print(d.entries[i].title) 
                #print(d.entries[i].description) 
                #print(d.entries[i].link) 
                #print('--------------------------------------------------------------')
                payload = {
                  'rows': [
                    {
                      'cells': [
                        {'column': 'c-_zKlSZgEHp', 
#            "href": "https://coda.io/apis/v1beta1/docs/G6ody-h41g/tables/grid-bkLoQsMy38",
#            "browserLink": "https://coda.io/d/_dG6ody-h41g#_tugrid-bkLoQsMy38",
#            "name": "Fuentes añadidas",
#            "parent": {
#                "id": "canvas-_43PyvtFma",
#                "type": "section",
#                "href": "https://coda.io/apis/v1beta1/docs/G6ody-h41g/sections/canvas-_43PyvtFma",
#                "browserLink": "https://coda.io/d/_dG6ody-h41g/_suFma",
#                "name": "Feed Noticias"
#            }
API_KEY = 'c5d228f1-a38e-4956-b6e6-f6ceaac089d0'
if hasattr(ssl, '_create_unverified_context'):
	 ssl._create_default_https_context = ssl._create_unverified_context
docid = 'G6ody-h41g'
tabid='grid-bkLoQsMy38'
coda = Coda(API_KEY)
b = coda.list_rows(docid,tabid)

for i in range (0,len(b['items'])):
	aux = '"' + b['items'][i]['values']['c-H6Y2WhxKjs'] + '"'
	listaulr.append(aux)
### La Tabla de la que quiero leer datos es:
print("------------------------------")
for i in listaulr: 
    print(i)

# ESTE SCRIPT RECOGE LAS NOTICIAS DE FEEDLY Y LAS RECOGE EN CODA
API_KEY = 'c5d228f1-a38e-4956-b6e6-f6ceaac089d0'
#rss = 'https://www.incibe-cert.es/feed/avisos-sci/all'
b = float('0.0')
lenlista = len(listaulr)
]

# Hacemos la petición a BOR La Rioja
#fecha =  time.strftime("%Y/%m/%d", time.gmtime())
fecha = '2019/10/09'
url = "https://ias1.larioja.org/boletin/ExportarBoletinServlet?tipo=1&fecha=" + fecha
response = requests.get(url)
#print(response.text)
#print(response.content)

# Hacemos el parseo del XML
soup = BeautifulSoup(response.content, 'xml')
titsoup = soup.find_all('titulo')

# Empezamos con la integración con CODA
coda = Coda(API_KEY)

for i in range(0, len(titsoup)):
    entries_interesante = "false"
    entries_title = titsoup[i].text
    for c in range(0, len(intwords)):
        if (str(entries_title).lower().find(intwords[c]) >= 0):
            entries_interesante = "true"
        payload = {
            'rows': [
                {
                    'cells': [{
                        'column': titleid,
                        'value': entries_title
                    }, {
                        'column': interesanteid,
CODA_COLS = [
    "Task ID",
    "Task",
    "Labels",
    "Priority",
    "Project",
    "Due date",
    "Dependency",
    "Modified on",
]

# Coda api
# NOTE: This package doesn't support v1.0 of the api yet
CODA_API_KEY = os.getenv("CODA_API_KEY")
CODA_API_ENDPOINT = os.getenv("CODA_API_ENDPOINT")
CODA_API = Coda(CODA_API_KEY, CODA_API_ENDPOINT)

# Todoist api
TODOIST_API_KEY = os.getenv("TODOIST_API_KEY")
TODOIST_API = todoist.TodoistAPI(TODOIST_API_KEY)
TODOIST_API.sync()


def get_todoist_tasks() -> dict:
    """ Get a dictionary containing `task id` -> `Item` object """
    task_dict = {item["id"]: item for item in TODOIST_API.items.all()}
    return task_dict


def get_todoist_labels() -> dict:
    """ Get a dictionary containing `label id` -> `Label` object """
Exemple #7
0
def coda():
    API_KEY = env("CODA_API_KEY", cast=str)
    return Coda(API_KEY)
Exemple #8
0
def coda():
    API_KEY = "ANY_KEY"
    return Coda(API_KEY)
Exemple #9
0
 def fake_coda(self):
     return Coda("foo")