from tools.os import OS from tools.yml import YML from settings.log import Log from settings.config import Config from settings.cli import CLIArguments # ============================================================================== # GLOBAL # ============================================================================== MAX_RETRIES = 50 config, args, yml = Config(), CLIArguments().args, YML().get_content() twitter_consumer_key = config.get_env("TWITTER_CONSUMER_KEY") twitter_consumer_secret = config.get_env("TWITTER_CONSUMER_SECRET") twitter_access_token = config.get_env("TWITTER_ACCESS_TOKEN") twitter_access_token_secret = config.get_env("TWITTER_ACCESS_TOKEN_SECRET") twitter_consumer_key = twitter_consumer_key if twitter_consumer_key else yml["twitter"]["consumer"]["key"] twitter_consumer_secret = twitter_consumer_secret if twitter_consumer_secret else yml["twitter"]["consumer"]["secret"] twitter_access_token = twitter_access_token if twitter_access_token else yml["twitter"]["access"]["token"] twitter_access_token_secret = twitter_access_token_secret if twitter_access_token_secret else yml["twitter"]["access"]["secret"] log_path = config.get_env("LOG_PATH") if config.get_env("LOG_PATH") else "/var/log/code" log_file = config.get_env("LOG_FILE") if config.get_env("LOG_FILE") else "file.log" log_level = config.get_env("LOG_LEVEL") if config.get_env("LOG_LEVEL") else "DEBUG" logger_name = config.get_env("LOGGER_NAME") if config.get_env("LOGGER_NAME") else "Twitter Realtime Processing" logger = Log(log_path, log_file, log_level, logger_name).logger
# ============================================================================== # GLOBAL # ============================================================================== config = Config() logging.basicConfig( level=logging.INFO, format= "%(asctime)s %(levelname)-10s %(processName)s %(name)s %(message)s", datefmt="%Y-%m-%d-%H-%M-%S") ec2_client = boto3.client( "ec2", aws_access_key_id=config.get_env("AWS_ACCESS_KEY_ID"), aws_secret_access_key=config.get_env("AWS_SECRET_ACCESS_KEY"), region_name=config.get_env("AWS_REGION")) s3_client = boto3.client( "s3", aws_access_key_id=config.get_env("AWS_ACCESS_KEY_ID"), aws_secret_access_key=config.get_env("AWS_SECRET_ACCESS_KEY"), region_name=config.get_env("AWS_REGION")) route_client = boto3.client( "route53", aws_access_key_id=config.get_env("AWS_ACCESS_KEY_ID"), aws_secret_access_key=config.get_env("AWS_SECRET_ACCESS_KEY"), region_name=config.get_env("AWS_REGION"))
# -*- coding: utf-8 -*- from tools.os import OS from settings.log import Log from settings.config import Config config = Config() twitter_consumer_key = config.get_env("TWITTER_CONSUMER_KEY") twitter_consumer_secret = config.get_env("TWITTER_CONSUMER_SECRET") twitter_access_token = config.get_env("TWITTER_ACCESS_TOKEN") twitter_access_token_secret = config.get_env("TWITTER_ACCESS_TOKEN_SECRET") log_path = config.get_env("LOG_PATH") if config.get_env("LOG_PATH") else "/var/log/code" log_file = config.get_env("LOG_FILE") if config.get_env("LOG_FILE") else "file.log" log_level = config.get_env("LOG_LEVEL") if config.get_env("LOG_LEVEL") else "DEBUG" logger_name = config.get_env("LOGGER_NAME") if config.get_env("LOGGER_NAME") else "Sentiment Analysis" logger = Log(log_path, log_file, log_level, logger_name).logger
import sys from colorama import init init(strip=not sys.stdout.isatty()) # strip colors if stdout is redirected from termcolor import cprint from pyfiglet import figlet_format # ============================================================================== # GLOBAL # ============================================================================== config, args = Config(), Arguments(description="GitLab Analytics").args yml = YmlReader("/usr/src/code", "values.yml") gitlab_url = config.get_env("GITLAB_URL") if config.get_env("GITLAB_URL") else (args["url"] if args["url"] else "https://git.stfcia.com.br") gitlab_token = config.get_env("GITLAB_TOKEN") if config.get_env("GITLAB_TOKEN") else (args["token"] if args["token"] else None) log_path = config.get_env("LOG_PATH") if config.get_env("LOG_PATH") else "/var/log/code" log_file = config.get_env("LOG_FILE") if config.get_env("LOG_FILE") else "file.log" log_level = config.get_env("LOG_LEVEL") if config.get_env("LOG_LEVEL") else "DEBUG" logger_name = config.get_env("LOGGER_NAME") if config.get_env("LOGGER_NAME") else "Code" logger = Log(log_path, log_file, log_level, logger_name).logger gitlab_client = GitLabClient(gitlab_url, gitlab_token, retry=False, is_secure=True, session=None, logger=logger) gitlab = Gitlab(gitlab_client) gitlab_resources = gitlab.resources() # ============================================================================== # FUNCTIONS