Пример #1
0
 def __init__(self, sheet_key: str):
     k = Keys()
     try:
         gsheets_creds = k.get_key('gsheet-reader')
     except Exception as e:
         local_key_path = os.path.join(Path().keys_dir, 'GSHEET_READER')
         with open(local_key_path) as f:
             gsheets_creds = json.loads(f.read())
     os.environ['GDRIVE_API_CREDENTIALS'] = json.dumps(gsheets_creds)
     self.gc = pygsheets.authorize(
         service_account_env_var='GDRIVE_API_CREDENTIALS')
     self.sheets = self.gc.open_by_key(sheet_key).worksheets()
Пример #2
0
 def __init__(self):
     creds = Keys().get_key('ecobee')
     app_key = creds['app-key']
     # Device serial number
     self.sn = creds['serial']
     # Connect to the service
     self.service = EcobeeService('Home', app_key)
     # Get auth tokens
     self.auth_protocol()
Пример #3
0
 def setUpClass(cls) -> None:
     cls.key = Keys()
Пример #4
0
 def __init__(self):
     self.api_key = Keys().get_key('td-ameritrade-developer').get('CONSUMER_KEY')
Пример #5
0
"""Message links to memes for Viktor to post periodically"""
import os
import re
import time
import numpy as np
from typing import List
from datetime import datetime, timedelta
from slacktools import SlackTools
from kavalkilu import Keys, LogWithInflux


logg = LogWithInflux('memeraker')
vcreds = Keys().get_key('viktor')
st = SlackTools(**vcreds)
user_me = 'UM35HE6R5'

# Wine review text & previous stop timestamp
ddir = os.path.join(os.path.expanduser('~'), 'data')
fpath = os.path.join(ddir, 'mkov_wines.txt')
ts_path = os.path.join(ddir, 'last_memeraker_ts')


def post_memes(reviews: List[str], memes: List[str], wait_min: int = 5, wait_max: int = 60):
    # Begin the upload process, include a review
    for meme in memes:
        review = np.random.choice(reviews, 1)[0]
        st.upload_file('memes-n-shitposts', meme, 'image', is_url=True, txt=review)
        # Wait some seconds before posting again
        wait_s = np.random.choice(range(wait_min, wait_max), 1)[0]
        logg.debug(f'Waiting {wait_s}s.')
        time.sleep(wait_s)
Пример #6
0
 def setUpClass(cls) -> None:
     props = Keys().get_key('gnucash-report')
     cls.gcash = GNUCash(props.get('path'))
Пример #7
0
# -*- coding: utf-8 -*-
import time
from datetime import datetime as dtt
from kavalkilu import LogWithInflux, Keys, NetTools, Hosts, HOME_SERVER_HOSTNAME
from servertools import BrowserAction, SlackComm

ip = NetTools().get_ip()
debug = Hosts().get_ip_from_host(HOME_SERVER_HOSTNAME) != ip
logg = LogWithInflux('vpulse_auto')

# TODO
# build out a table of when monthly, weekly things were last done.
# Handle weekly tasks either based on DOW or recorded table with date_last_done and freq columns

# Get credentials
creds = Keys().get_key('vpulse-creds')


def message_channel_and_log(msg):
    slack_comm.send_message(notify_channel, msg)
    if debug:
        logg.debug(msg)


def get_vpoints():
    """Collects amount of points currently available"""
    points_script = "return document.getElementById('progress-bar-menu-points-total-value')"
    points = ba.driver.execute_script(points_script).get_attribute(
        'textContent').strip()

    if points.isdigit():
Пример #8
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import time
import requests
from grafana_api.grafana_face import GrafanaFace
from kavalkilu import Keys, LogWithInflux
from servertools import SlackComm


log = LogWithInflux('grafana_snapper')
creds = Keys().get_key('grafana')
scom = SlackComm()


def get_pic_and_upload(url, name):
    """Captures dashboard panel at URL and uploads to #notifications slack channel"""

    resp = requests.get(url, headers={'Authorization': f'Bearer {creds["token"]}'})

    temp_file = os.path.abspath('/tmp/dash_snap.png')
    with open(temp_file, 'wb') as f:
        for chunk in resp:
            f.write(chunk)
    scom.st.upload_file(scom.notify_channel, temp_file, name)


# The URL template to use
base_url = 'http://{host}/render/{name}?orgId=1&from={from}&to={to}&panelId={pid}&width=1000&height=500'

# time range to snap
Пример #9
0
 def __init__(self, location: str, timezone: str = 'US/Central'):
     sk = Keys()
     self.api_key = sk.get_key('openweather').get('token', '')
     self.owm = OWM(self.api_key)
     self.location = location
     self.tz = timezone
Пример #10
0
 def _get_creds() -> Tuple[str, str]:
     """Collects the credentials"""
     creds = Keys().get_key('hidden-openwrt')
     return creds['un'], creds['pw']