Пример #1
0
    def __init__(self, tempCacheSize=4096):
        ### configuration
        conf = read_config()
        self.nickname    = conf['nick']
        self.password    = conf['password']
        self.channel     = '#%s' % conf['channel']
        self.network     = conf['network']
        self.port        = int(conf['port'])

        self.command_prefix    = conf['command_prefix']
        self.quitCmd           = conf['quit']
        self.logAllToConsole   = conf['logAllToConsole'] == 'True'
        self.respondToNotFound = conf['respondToNotFound'] == 'True'

        ### connection
        self.socket        = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.tempCacheSize = tempCacheSize

        ### addons
        self.addonList = list()

        ### tests for messages received from server
        self.regexIsError             = re.compile(r"^ERROR.*|\\r\\nError.*")
        self.regexIsJoin              = re.compile(r":(?P<user>\w+)!.+\sJOIN\s")
        self.regexIsQuit              = re.compile(r":(?P<user>\w+)!.+\sPART\s")
        self.regexIsCommand           = re.compile(r"^%s{1}(?P<command>\w+)" % self.command_prefix)
        self.regexCommandSplitCommand = re.compile(r"^%s{1}(?P<command>\w+)\s(?P<arguments>.*).*" % self.command_prefix)
        self.regexIsChat              = re.compile(r":(?P<user>\w+)!(?P<isp>.+)\sPRIVMSG\s(?P<channel>[#\w-]+)\s:(?P<message>.+)")
        self.regexIsNickInUse         = re.compile(r".*\s433\s.?%s.*" % self.nickname)
        self.regexIsAskForLogin       = re.compile(r".*ʌ")
Пример #2
0
    def __init__(self, tempCacheSize=4096):
        ### configuration
        conf = read_config()
        self.nickname = conf['nick']
        self.password = conf['password']
        self.channel = '#%s' % conf['channel']
        self.network = conf['network']
        self.port = int(conf['port'])

        self.command_prefix = conf['command_prefix']
        self.quitCmd = conf['quit']
        self.logAllToConsole = conf['logAllToConsole'] == 'True'
        self.respondToNotFound = conf['respondToNotFound'] == 'True'

        ### connection
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.tempCacheSize = tempCacheSize

        ### addons
        self.addonList = list()

        ### tests for messages received from server
        self.regexIsError = re.compile(r"^ERROR.*|\\r\\nError.*")
        self.regexIsJoin = re.compile(r":(?P<user>\w+)!.+\sJOIN\s")
        self.regexIsQuit = re.compile(r":(?P<user>\w+)!.+\sPART\s")
        self.regexIsCommand = re.compile(r"^%s{1}(?P<command>\w+)" %
                                         self.command_prefix)
        self.regexCommandSplitCommand = re.compile(
            r"^%s{1}(?P<command>\w+)\s(?P<arguments>.*).*" %
            self.command_prefix)
        self.regexIsChat = re.compile(
            r":(?P<user>\w+)!(?P<isp>.+)\sPRIVMSG\s(?P<channel>[#\w-]+)\s:(?P<message>.+)"
        )
        self.regexIsNickInUse = re.compile(r".*\s433\s.?%s.*" % self.nickname)
        self.regexIsAskForLogin = re.compile(r".*ʌ")
Пример #3
0
 def db_connect(self):
     config = settings.read_config()
     try:
         conn = psycopg2.connect(database=config['db_name'],
                                 user=config['db_user'],
                                 password=config['db_pass'],
                                 host=config['db_host'],
                                 port=config['db_port'])
         return conn
     except psycopg2.Error as e:
         print("!! Error connecting to db")
         print(e)
         return None
Пример #4
0
 def db_connect(self):
     config = settings.read_config()
     try:
         conn = psycopg2.connect(
                         database = config['db_name'],
                         user     = config['db_user'],
                         password = config['db_pass'],
                         host     = config['db_host'],
                         port     = config['db_port'])
         return conn
     except psycopg2.Error as e:
         print("!! Error connecting to db")
         print(e)
         return None
Пример #5
0
    def __init__(self, tempCacheSize=4096):
        conf = read_config()
        self.network = conf['network']
        self.port = int(conf['port'])
        self.channel = conf['channel']
        self.quitCmd = conf['quit']
        self.nickname = conf['nick']
        self.password = conf['password']
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        
        self.tempCacheSize = tempCacheSize
        self.cLog = chatLog.ChatLog()

        self.addonList = list()

        self.regexIsCommand = re.compile(r"(?P<command>!!..+)")
        self.regexCommandSplitCommand = re.compile(r"!!(?P<command>\w+)\s(?P<arguments>.*).*")
        self.regexIsChat = re.compile(r":(?P<user>\w+)!(?P<isp>.+)\sPRIVMSG\s(?P<channel>[#\w-]+)\s:(?P<message>.+)")
Пример #6
0
    def __init__(self, tempCacheSize=4096):
        conf = read_config()
        self.network = conf["network"]
        self.port = int(conf["port"])
        self.channel = conf["channel"]
        self.quitCmd = conf["quit"]
        self.nickname = conf["nick"]
        self.password = conf["password"]
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        self.tempCacheSize = tempCacheSize
        self.cLog = chatLog.ChatLog()

        self.behaviourModule = BehaviourModule()
        self.commandModule = CommandModule()

        self.regexIsCommand = re.compile(r"(?P<command>!!..+)")
        self.regexIsChat = re.compile(r":(?P<user>\w+)!(?P<isp>.+)\sPRIVMSG\s(?P<channel>[#\w-]+)\s:(?P<message>.+)")
Пример #7
0
    def __init__(self, tempCacheSize=4096):
        conf = read_config()
        self.network = conf['network']
        self.port = int(conf['port'])
        self.channel = conf['channel']
        self.quitCmd = conf['quit']
        self.nickname = conf['nick']
        self.password = conf['password']
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        self.tempCacheSize = tempCacheSize
        self.cLog = chatLog.ChatLog()

        self.addonList = list()

        self.regexIsCommand = re.compile(r"(?P<command>!!..+)")
        self.regexCommandSplitCommand = re.compile(
            r"!!(?P<command>\w+)\s(?P<arguments>.*).*")
        self.regexIsChat = re.compile(
            r":(?P<user>\w+)!(?P<isp>.+)\sPRIVMSG\s(?P<channel>[#\w-]+)\s:(?P<message>.+)"
        )
Пример #8
0
            'question_id': 1
        },
        {
            'choice_text': 'The sky',
            'votes': 0,
            'question_id': 1
        },
        {
            'choice_text': 'Just hacking again',
            'votes': 0,
            'question_id': 1
        },
    ])
    conn.close()


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--config', help='config file path')
    args = parser.parse_args()

    if not args.config:
        print("--config flag should be given")

    config = read_config(args.config)

    db_url = DSN.format(**config['mysql'])
    engine = create_engine(db_url)
    create_tables(engine)
    insert_sample_data(engine)
Пример #9
0
if __name__ == '__main__':

    try:
        # 出品商品リスト
        item_list = []

        # 出品成功した商品リスト
        success_list = []
        # 出品スキップした商品リスト
        skip_list = []

        print('処理を開始します')

        # 設定ファイル読み込み
        config_default = settings.read_config('DEFAULT')

        print('出品商品リストを読み込みます')

        # 出品用ファイルのパス取得
        path = config_default.get('ITEM_FILE_PATH')
        if path == None:
            # 値が存在しない場合
            raise Exception

        # 出品用ファイルのシート名取得
        sheet_name = config_default.get('ITEM_FILE_SHEET')
        if sheet_name == None:
            # 値が存在しない場合
            raise Exception