コード例 #1
0
def load_local_vars():
    hostname = utils.getenv('HOSTNAME')
    ext_ip = utils.getenv('EXTERNAL_IP')
    int_ip = utils.getenv('INTERNAL_IP1')
    try:
        server = utils.getenv('CENTRAL_SERVER')
    except:
        env_notice()
        exit()
    return hostname, ext_ip, int_ip, server
コード例 #2
0
class DevelopmentConfig(BaseConfig):
    """Development configuration."""

    DEBUG_TB_ENABLED = True
    DEBUG_TB_INTERCEPT_REDIRECTS = False
    SQLALCHEMY_BINDS = {
        "swachh_manch":
        f'mysql+pymysql://'
        f'{getenv("SWACHHATA_MYSQL_DB_USERNAME")}:{getenv("SWACHHATA_MYSQL_DB_PASSWORD")}'
        f'@{getenv("SWACHHATA_MYSQL_DB_HOST")}/{getenv("SWACHHATA_MYSQL_DB_NAME")}',
        "icmyc":
        f'mysql+pymysql://'
        f'{getenv("ICMYC_MYSQL_DB_USERNAME")}:{getenv("ICMYC_MYSQL_DB_PASSWORD")}'
        f'@{getenv("ICMYC_MYSQL_DB_HOST")}/{getenv("ICMYC_MYSQL_DB_NAME")}',
    }
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    MONGODB_SETTINGS = {
        'db': getenv("SWACHHATA_MONGO_DB_NAME"),
        'host': getenv("SWACHHATA_MONGO_DB_HOST"),
        'port': int(getenv("SWACHHATA_MONGO_DB_PORT")),
        'username': getenv("SWACHHATA_MONGO_DB_USERNAME"),
        'password': getenv("SWACHHATA_MONGO_DB_PASSWORD"),
    }
コード例 #3
0
def autodiscover_local():
	internal_addr = utils.getenv('INTERNAL_IP1')
	subnet = '.'.join(internal_addr.split('.')[0:-1])+'.0/24'
	cmd = 'sudo nmap -T5 -p 22 %s' % subnet
	reporting_on = ''; current_mac = '' 
	possible_peers = []
	for line in utils.cmd(cmd, False):
		if len(line.split('Nmap scan ')) > 1:
			try:
				reporting_on = line.split('for ')[1].split(')')[0]
			except IndexError:
				print(line.split(' for '))
				pass
		if 'MAC' in line.split(' '):
			current_mac = line.split(': ')[1].split(' (')[0]
		if len(line.split('22/tcp')) > 1:
			if 'open' in line.split(' '):
				possible_peers.append([reporting_on, current_mac])
	return possible_peers
コード例 #4
0
ファイル: main.py プロジェクト: JYisus/BotBlockTwitter
#!/usr/bin/python3

from twitter_bot import TwitterBot
from os import environ
import utils

API_KEY = utils.getenv('API_KEY', '')
API_KEY_SECRET = utils.getenv('API_KEY_SECRET', '')
ACCESS_TOKEN = utils.getenv('ACCESS_TOKEN', '')
ACCESS_TOKEN_SECRET = utils.getenv('ACCESS_TOKEN_SECRET', '')
STALKER_ACCOUNT = utils.getenv('STALKER_ACCOUNT', '')
ACCOUNT = utils.getenv('ACCOUNT', '')


def check_credentials(credentials):
    not_empty_items = list(filter(lambda item: item != '', credentials))
    return len(not_empty_items) == len(credentials)


if __name__ == "__main__":
    credentials = {
        'api_key': API_KEY,
        'api_key_secret': API_KEY_SECRET,
        'access_token': ACCESS_TOKEN,
        'access_token_secret': ACCESS_TOKEN_SECRET
    }

    if check_credentials(credentials) & (STALKER_ACCOUNT != ''):
        bot = TwitterBot(credentials, ACCOUNT, STALKER_ACCOUNT)
        bot.block_followersOf_replying()
    else:
コード例 #5
0
from mongoengine import connect
from dotenv import load_dotenv
from utils import getenv, now
from models import Ward, City
from base_sqlalchemy import Base, SmMetaDataSession
from profile import Profile

# Swachhata Mongo connection
connect(getenv('SM_MONGO_DB_NAME'),
        host=getenv("SM_MONGO_DB_HOST"),
        port=int(getenv("SM_MONGO_DB_PORT")),
        username=getenv('SM_MONGO_DB_USERNAME'),
        password=getenv("SM_MONGO_DB_PASSWORD"))


def fetchProfiles(fromUserId, toUserId):
    return Profile.objects(
        user_id__gte=fromUserId,
        user_id__lte=toUserId,
        ward_id__in=[],
        ward_id__ne=300,
        city_id__nin=[None, 4500],
    )


def updateProfile(profile):
    # Extract session
    session = SmMetaDataSession()

    # Get Ward - MySQL
    ward = session.query(Ward).filter(Ward.meta_data_ward_id == profile.ward_id).\
コード例 #6
0
 def __init__(self):
     text_source = utils.getenv('TEXT_SOURCE', 'resources/edgy.txt')
     textfile = open(text_source, "r")
     texts = textfile.readlines()
     textfile.close()
     self.texts = utils.clean_carriage_return(texts)
コード例 #7
0
ファイル: etcd_store.py プロジェクト: rancho1112/cowry
def etcd_client():
    global ETCD_CLIENT
    if not ETCD_CLIENT:
        ETCD_CLIENT = etcd.Client(host=utils.getenv('etcd', 'etcd'), port=2379)
    return ETCD_CLIENT
コード例 #8
0
import hmac
import hashlib
import requests
import traceback
from .blocks import (
    slack_help_menu_blocks,
    slack_results_blocks,
    RESULTS_PER_REQUEST,
    MAX_RECORDS_PER_MSG,
)

import logging

logger = logging.getLogger()

SLACK_SIGNING_SECRET = getenv("SLACK_SIGNING_SECRET")
STACK_NAME = getenv("STACK_NAME")
SLACK_ZIP_CHANNEL = getenv("SLACK_ZIP_CHANNEL", required=False)
SLACK_API_TOKEN = getenv("SLACK_API_TOKEN")
SLACK_ALLOWED_GROUPS = getenv("SLACK_ALLOWED_GROUPS").split(",")
ZOOM_MID_LENGTHS = [10, 11]


class SlackApiRequestError(Exception):
    pass


def resp_204(msg):
    logger.info(f"http 204 response: {msg}")
    return {"statusCode": 204, "headers": {}, "body": ""}  # 204 = no content