예제 #1
0
    def __init__(self):
        super(EchoLayer, self).__init__()
        YowInterfaceLayer.__init__(self)
        self.connected = False
        self.serve = Serve()

        self.bus_service = ServiceBusService(
            service_namespace='msgtestsb',
            shared_access_key_name='RootManageSharedAccessKey',
            shared_access_key_value=
            'Ar9fUCZQdTL7cVWgerdNOB7sbQp0cWEeQyTRYUjKwpk=')
예제 #2
0
def main(mode: str, log_level: str, log_dir: str):
    log_dir = log_dir or os.getcwd()

    if mode is None:
        log_name = f"Debugger_Main({os.getpid()})"
        log_name = f"{log_dir}\\{log_name}" if platform.system(
        ) == "Windows" else f"{log_dir}/{log_name}"
        loggers.set_filename(log_name)
        if log_level == "info":
            loggers.set_use_console(False)
            loggers.set_use_file(True)
            loggers.set_level(loggers.INFO)
        elif log_level == "debug":
            loggers.set_use_console(True)
            loggers.set_use_file(True)
            loggers.set_level(loggers.DEBUG)
        else:
            loggers.set_use_console(False)
            loggers.set_use_file(True)
            loggers.set_level(loggers.ERROR)

        Serve(IP, PORT, log_name, log_level, log_dir).start()
    elif mode == "debug":
        loggers.set_use_console(False)
        loggers.set_use_file(True)
        log_name = f"Debugger_Sub({os.getpid()})"
        log_name = f"{log_dir}\\{log_name}" if platform.system(
        ) == "Windows" else f"{log_dir}/{log_name}"

        loggers.set_filename(log_name)
        if log_level == "info":
            loggers.set_level(loggers.INFO)
        elif log_level == "debug":
            loggers.set_level(loggers.DEBUG)
        else:
            loggers.set_level(loggers.ERROR)

        print(f"pid {os.getpid()}")

        debug(log_level, log_dir)
    else:
        raise Exception("Invaild params.")
예제 #3
0
First, a few handler functions are defined. Then, those functions are passed to
the Dispatcher and registered at their respective places.
Then, the bot is started and runs until we press Ctrl-C on the command line.

Usage:
Basic Echobot example, repeats messages.
Press Ctrl-C on the command line or send a signal to the process to stop the
bot.
"""

from telegram import Updater
import logging
import json, sys

from serve import Serve, TESTSCRIPT
serve = Serve()

BOTKEY = ""
if not BOTKEY:
    try:
        BOTKEY = sys.argv[1]
    except:
        print "BOTKEY not provided"
        sys.exit()

# Enable logging
logging.basicConfig(filename="/tmp/" + TESTSCRIPT + "telegram.log",
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        level=logging.INFO)

logger = logging.getLogger(__name__)