示例#1
0
def db_connect():
    """
    For connecting to a POSTGRES database on the local machine.
    """
    vv = dotenv.get_variables('.env')
    dbname = str(vv[u'dbname'])
    user = str(vv[u'db_user'])
    pwd = str(vv[u'db_pwd'])
    host = str(vv[u'db_host'])
    conn_string = "host='%s' dbname='%s' " \
                  "user='******' password='******'"%(host, dbname, user, pwd)
    return psycopg2.connect(conn_string)
示例#2
0
# speedtest information about my work ISP
# https://jtprog.ru/

__author__ = 'jtprogru'
__version__ = '0.0.1'
__author_email__ = '*****@*****.**'

import os
import csv
import datetime
import time
import twitter
import dotenv as d
from pathlib import Path

env = d.get_variables(str(Path(__file__).parent / '.env'))

# tweet_speed = f'My speedtest now is: {0}'  # \n Hey! {env["MY_ISP_TW"]}'


def test_speed():
    # run speedtest-cli
    print("running test speed")
    resp = os.popen("python speedtest-cli --simple").read()
    print('ran')
    # split the 3 line result (ping,down,up)
    lines = resp.split('\n')
    print(resp)
    ts = time.time()
    date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
    # if speedtest could not connect set the speeds to 0
示例#3
0
    def test_get_variables(self):
        result = get_variables(self.file_path)

        dotenv = Dotenv(self.file_path)

        self.assertEqual(result, dotenv)
示例#4
0
    def test_get_variables(self):
        result = get_variables(self.file_path)

        dotenv = Dotenv(self.file_path)

        self.assertEqual(result, dotenv)
示例#5
0
from ccxt import gdax
import time
import pandas as pd
import datetime
import dotenv
variables = dotenv.get_variables('.env')


def getenv(key):
    return variables[key]


class GDAXTracer:
    def __init__(self):
        self.api = gdax({
            'apiKey': getenv('gdax_api_key'),
            'secret': getenv('gdax_api_secret'),
            'password': getenv('gdax_api_passphrase')
        })
        self.accounts = pd.DataFrame(self.api.privateGetAccounts())

    def send_fills_and_accounts(self, email):
        for account_id in self.accounts.id.values:
            self.api.privatePostReports({
                'email': email,
                'type': 'account',
                'account_id': account_id
            })

        for market in self.api.fetch_markets():
            self.api.privatePostReports({
示例#6
0
from dotenv import get_variable, set_variable, get_variables, __version__


parser = argparse.ArgumentParser()

parser.add_argument("key", nargs='?')
parser.add_argument("value", nargs='?')

parser.add_argument('--file', default='.env')

parser.add_argument('--version', action='version', version=__version__)

parser.add_argument('--shell', action='store_true', default=False)

args = parser.parse_args()


if args.shell:
    PRINT_FORMAT = '%s=%s'
else:
    PRINT_FORMAT = '%s: %s'

if args.key is None:
    for key, value in get_variables(args.file).items():
        print(PRINT_FORMAT % (key, value))
elif args.value is None:
    print(PRINT_FORMAT % (args.key, get_variable(args.file, args.key)))
else:
    set_variable(args.file, args.key, args.value)
    print(PRINT_FORMAT % (args.key, args.value))
示例#7
0
import argparse
from dotenv import get_variable, set_variable, get_variables, __version__


parser = argparse.ArgumentParser()

parser.add_argument("key", nargs='?')
parser.add_argument("value", nargs='?')

parser.add_argument('--file', default='.env')

parser.add_argument('--version', action='version', version=__version__)

args = parser.parse_args()

if args.key is None:
	for key, value in get_variables(args.file).items():
		print("%s: %s" % (key, value))
elif args.value is None:
	print("%s: %s" % (args.key, get_variable(args.file, args.key)))
else:
	set_variable(args.file, args.key, args.value)
	print("%s: %s" % (args.key, args.value))
示例#8
0
import datetime

from airtable.airtable import Airtable
from twilio.rest import Client
from os.path import join, dirname
from dotenv import get_variables


dotenv_path = join(dirname(__file__), '.env')
env = get_variables(dotenv_path)
airtable_client = Airtable(env['AIRTABLE_BASE_ID'],env['AIRTABLE_API_KEY'])


def text_reminder(client, records):
	return


def archive_records(client, table_name, records):
	return
示例#9
0
A basic Maltego script to get DNS resource records for an IPv4Address via OpenDNS Investigate.

Requires the MaltegoTransform Python library in your Python Path.
https://github.com/sroberts/MaltegoTransform-Python
"""

import dotenv
import requests
import sys

# from MaltegoTransform import MaltegoEntity
from lib.MaltegoTransform import MaltegoTransform

# Pull in API Key from .env
OPENDNS_TOKEN = dotenv.get_variables(".env")['OPENDNS_TOKEN']


def main():

    # Set up your Transform object. This is the basis for returning results.
    trx = MaltegoTransform()

    # The first item on the commandline is the calling object.
    ipv4address = sys.argv[1]

    try:
        # Make request to OpenDNS Investigate API
        r = requests.get(
            url="https://investigate.api.opendns.com/dnsdb/ip/a/{}.json".
            format(ipv4address),
from dotenv import get_variables

from instabot import Bot

from utils import get_files_path_from_dir, get_ext

IMG_EXT_SET = {'.png', '.jpg', '.jpeg', '.gif', '.tif'}


def upload_photo_to_instagram(img_dir, username, password):
    files = get_files_path_from_dir(img_dir)

    image_files = filter(lambda path: get_ext(path).lower() in IMG_EXT_SET,
                         files)

    bot = Bot()
    bot.login(username, password)

    for img in image_files:
        bot.upload_photo(img)


if __name__ == '__main__':
    variables = get_variables('.env')

    upload_photo_to_instagram('images', variables['USERNAME'],
                              variables['PASSWORD'])