def __init__(self): self.__test = configHelper.readMode('test') # construct logger instance self.__logger = self.__getLogger() self.__dao = dao.Dao(self.__test) self.__models = self.__initModelDict() self.__maindict = self.__initClients()
def __init__(self): self.mail_host = "smtp.163.com" # SMTP服务器 self.mail_user = "******" # 用户名 self.mail_pass = "******" # 授权密码,非登录密码 self.sender = "*****@*****.**" self.receivers = ["*****@*****.**"] self.dao = dao.Dao()
def delete(task_id): error = None if request.method == 'POST': task_dao = dao.Dao() task_dao.delete(task_id) list = task_dao.get() return render_template('show_entries.html', entries=list) return render_template('login.html', error=error)
def registration(): error = None if request.method == 'POST': if request.form['name'] is None: error = '作業名称を入力してください' else: task_dao = dao.Dao() task_dao.add(request.form["name"]) list = task_dao.get() return render_template('show_entries.html', entries=list) return render_template('login.html', error=error)
def __init__(self): self.db = dao.Dao() self.db.init_tables() self.render = settings.render self.form = web.form.Form( web.form.Textbox('title', web.form.notnull, size=30, description=u'邮件标题'), web.form.Textarea('content', web.form.notnull, rows=30, cols=80, description=u'邮件内容'), web.form.Button(u'SEND'))
def __init__(self): self.render = settings.render self.db = dao.Dao() self.db.init_tables() self.datas = {} self.datas['account'] = self.db.get_num_account(100) self.datas['accountlen'] = self.db.total_row('account') self.datas['receiver'] = self.db.get_data('receiver', 100) self.datas['receiverlen'] = self.db.total_row('receiver') self.datas['name'] = self.db.get_data('names', 100) self.datas['namelen'] = self.db.total_row('names') self.datas['title'] = self.db.get_data('subjects', 100) self.datas['titlelen'] = self.db.total_row('subjects') self.datas['quote'] = self.db.get_data('quotes', 100) self.datas['quotelen'] = self.db.total_row('quotes') self.tmpfiledir = '/tmp'
def find_command(message): config = configparser.RawConfigParser() config.read('command.cfg') commands = config.items('commands') command = None for key, value in commands: ret = re.search(r"{}".format(key), message) if (ret is not None): class_ = getattr(importlib.import_module("cmd." + value), value.capitalize()) command = class_(dao.Dao(), message) logger.info('command: ' + value) find_command_arguments(message, command, value) return command return None
def handler(event, context): logger.info('event: ' + json.dumps(event)) # Get from POST or GET requests if 'body' in event and \ event['body'] is not None: try: event = json.loads(event['body']) except ValueError: event = json.loads(parse_qs(event['body'])['payload'][0]) logger.info('decoded event: ' + json.dumps(event)) elif 'queryStringParameters' in event and \ event['queryStringParameters'] is not None: event = event['queryStringParameters'] logger.info('event: ' + str(event)) # Discard bot responses if 'event' in event and \ event['event'] is not None and \ 'bot_id' in event['event']: return # Execute cron jobs if 'source' in event and \ event['source'] == 'cron' and \ 'action' in event: class_ = getattr(importlib.import_module("jobs." + event['action']), event['action'].capitalize()) job = class_(dao.Dao(), event) job.execute() ret = get_return(True, 'job ' + event['action'] + ' executed') # Execute html requests elif 'source' in event and \ event.pop('source') == 'html' and \ 'action' in event: functionAttr = getattr(dao.Dao(), event.pop('action')) jsonr = functionAttr(**event) return get_return(True, jsonr) # Execute BOT commands else: # Get the right parser parser = find_parser(event) if parser is not None: if hasattr(parser, 'validate'): ret = get_return(True, parser.validate) return ret if hasattr(parser, 'event'): command = find_command(parser.event) if command is not None: msg = command.execute() else: config = configparser.RawConfigParser() config.read('command.cfg') msg = Message(message=config.get('default-messages', 'command-not-found')) if msg is not None: if isinstance(msg, list): for message in msg: ret = parser.send_message(message) else: ret = parser.send_message(msg) else: ret = get_return(False, 'invalid command') else: ret = get_return(False, 'invalid parser') return get_return(True, 'Success')
def __init__(self, csvfile): self.csvfile = csvfile self.db = dao.Dao() self.db.init_tables()
def __init__(self): self.urls = url_manager.UrlManager() self.downloader = html_downloader.HtmlDownloader() self.parser = html_parser.HtmlParser() self.outputer = html_output.HtmlOutputer() self.dao = dao.Dao()
#from .dao import def import dao as d dd = d.Dao() print(dd.save())
test = configHelper.readMode('test') logger = logging.getLogger('mylogger') logger.setLevel(logging.DEBUG) fh = logging.FileHandler('iphoneStock.log') fh.setLevel(logging.DEBUG) formatter = logging.Formatter( '%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) logger.addHandler(fh) d = dao.Dao(test) def signal_handler(signal, frame): print(' - Stop Monitoring') sys.exit(0) # Handle Ctrl+C in terminal signal.signal(signal.SIGINT, signal_handler) print('Apple Store Monitoring \n') def getModelName(k): # Incase of a new version, update models here. model_mapping = {
def __init__(self): super(IReserveHTTP, self).__init__() print("IReserveHTTP init") self.__session = requests.Session() self.__dao = dao.Dao(False) print("IReserveHTTP init")
def show_entries(): task_dao = dao.Dao() list = task_dao.get() return render_template('show_entries.html', entries=list)