def define_lambda_role(conf, rolename): if rolename == "": if 'C_DEFAULT_ROLE' in conf.vars: rolename = conf.vars['C_DEFAULT_ROLE'] logger.get_my_logger("utils").info( "Using the default lambda role: " + rolename) else: logger.get_my_logger("utils").critical( "Parameter --rolename or set a default-role is required.") return rolename
def __init__(self, conf, lambdaname): self.log = logger.get_my_logger("tail") self.conf = conf if lambdaname != "": self.lambdaname = lambdaname else: self.log.critical("Parameter --lambdaname are required.")
def __init__(self, conf, projectname): self.log = logger.get_my_logger("project") self.conf = conf if projectname != "": self.projectname = projectname else: self.log.critical("Parameter --projectname is required.")
def __init__(self, conf, rolename): self.log = logger.get_my_logger("role") if rolename == "": self.log.critical("Parameter --rolename is required.") self.conf = conf self.rolename = rolename
def __init__(self, conf, sqsname): self.log = logger.get_my_logger("queue") self.conf = conf if sqsname != "": self.sqsname = Utils.append_fifo_in_queue(sqsname) else: self.log.critical("Parameter --sqsname is required.")
def delete_project(self): if Utils.validate_reserved_sections(self.conf, self.projectname): logger.get_my_logger("utils").critical("Reserved name: " + self.projectname) if self.conf.config.has_section(self.projectname): self.conf = self.undeploy_project() self.conf.config.remove_section(self.projectname) rmtree(self.conf.vars['C_LAMBDAS_DIR'] + self.projectname) self.log.info("Project '" + self.projectname + "' has been deleted.") else: self.log.critical("Project '" + self.projectname + "' does not exist.") return self.conf
def __init__(self, conf, sqsname, projectname): self.log = logger.get_my_logger("receiver") self.conf = conf if sqsname != "" and projectname != "": self.sqsname = sqsname self.projectname = projectname else: self.log.critical( "Parameter --sqsname and --projectname are required.")
def click_validate_required_options(ctx, conf): if ctx.info_name in conf.cli: if ctx.params['action'] in conf.cli[ctx.info_name]['commands']: for check in conf.cli[ctx.info_name]['commands'][ ctx.params['action']]: if isinstance(check, unicode): c = check.replace("-", "_") if ctx.params[c] is None: logger.get_my_logger("Utils").critical( "The option '--" + check + "' is required") elif isinstance(check, list): # At least one parameter in the list should be informed find = False for c in check: c = c.replace("-", "_") if c in ctx.params and ctx.params[c] is not None: find = True break if find: continue logger.get_my_logger("Utils").critical( "One of those parameters should be included: " + ', '.join(map(str, check))) else: logger.get_my_logger("Utils").critical( "Invalid cli conf file in: " + check)
def create_project(self): if Utils.validate_reserved_sections(self.conf, self.projectname): logger.get_my_logger("utils").critical("Reserved name: " + self.projectname) if self.conf.config.has_section(self.projectname): self.log.critical("Project '" + self.projectname + "' already exists.") else: self.conf.config.add_section(self.projectname) mkdir(self.conf.vars['C_LAMBDAS_DIR'] + self.projectname) open( self.conf.vars['C_LAMBDAS_DIR'] + self.projectname + "/__init__.py", 'a').close() copy2( self.conf.vars['C_LAMBDASTANDARD_FUNC'], self.conf.vars['C_LAMBDAS_DIR'] + self.projectname + "/index.py") self.log.info("Project " + self.projectname + " has been created.") self.conf.config.set(self.projectname, "deployed", "False") return self.conf
def click_validate_required_options(ctx,conf): if ctx.info_name in conf.cli: if ctx.params['action'] in conf.cli[ctx.info_name]['commands']: for check in conf.cli[ctx.info_name]['commands'][ctx.params['action']]: if isinstance(check, unicode): c = check.replace("-", "_") if ctx.params[c] is None: logger.get_my_logger("Utils").critical("The option '--" + check + "' is required"); elif isinstance(check, list): # At least one parameter in the list should be informed find = False for c in check: c = c.replace("-", "_") if c in ctx.params and ctx.params[c] is not None: find = True break if find: continue logger.get_my_logger("Utils").critical("One of those parameters should be included: " + ', '.join(map(str, check))) else: logger.get_my_logger("Utils").critical("Invalid cli conf file in: " + check)
#-*- coding: utf-8 -*- import random import logging import os import datetime import time from selenium import webdriver from selenium.webdriver.common.keys import Keys from logger import get_my_logger from slack import slack_mapianist from environments import Env logger = get_my_logger('mapiacrawler') def setup_chrome(): chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("headless") chrome_options.add_argument("window-size=1280x900") chrome_options.add_argument("--no-sandbox") chrome_options.add_argument("disable-gpu") chrome_options.add_argument("--disable-dev-shm-usage") # driver = webdriver.Chrome("./chromedriver", chrome_options=chrome_options) driver = webdriver.Chrome("/app/chromedriver", chrome_options=chrome_options) time.sleep(5) return driver
def __init__(self): self.log = logger.get_my_logger(self.__class__.__name__) self.config_file = os.path.join(os.path.expanduser('~'), ".tail-toolkit.json") self.read_config() self.region = boto3.session.Session().region_name
def __init__(self, config_file): self.log = logger.get_my_logger("conf") self.config_file = os.path.join(os.path.expanduser('~'), config_file) self.read_config() self.load_variables()
import datetime from logger import get_my_logger from slack import slack_google_home_mini from chromedriver import ChromeDriver logger = get_my_logger('google_home_mini') def crawling(): chrome = ChromeDriver() chrome.driver.get( 'https://home.google.com/promotions?utm_campaign=GS104586&utm_source=support&utm_term=support&utm_content=MY' ) if not chrome.driver.title == 'Google Nest': logger.info(chrome.driver.page_source) return '[%s] 타이틀이 Google Nest가 아닌 페이지가 탐지됐어!!!' % datetime.datetime.now( ) if chrome.driver.page_source.find( 'Google Korea LLC에서 제공하는 프로모션 코드(쿠폰)에는 다음 약관이 적용됩니다. 쿠폰을 2020년 3월 31일 오후 11:59(KST)까지 사용하지 않으면 만료됩니다. 2020년 2월 19일 기준으로 YouTube Premium을 이용 중인 유료 회원에 한해 제공됩니다. 사용자는 쿠폰 사용 날짜를 기준으로 멤버십이 일시중지되거나, 이용을 취소 내지 비활성화한 상태가 아닌 회원이어야 합니다. 프로모션 코드당 Google Home Mini 1대를 신청할 수 있으며 재고가 소진될 때까지 선착순으로 제공됩니다. Google은 필요에 따라 관련 약관을 수정할 권리를 유보합니다.' ) == -1: logger.info(chrome.driver.page_source) return '[%s] 만료 내용이 나오던 곳의 내용이 바뀌었어!!!' % datetime.datetime.now() if chrome.driver.page_source.find('만료된 혜택입니다.') == -1: logger.info(chrome.driver.page_source) return '[%s] 물량 들어왔나?!?!?!?!' % datetime.datetime.now() return '[%s] 아직 아닌가봐...' % datetime.datetime.now() if __name__ == '__main__':
def __init__(self, action, args): self.log = logger.get_my_logger("gateway") self.action = action self.get_args(args)
def __init__(self, conf, kwargs): self.log = logger.get_my_logger(self.__class__.__name__) self.conf = conf self.loggroupname = kwargs['loggroupname']