def loginRobot(): logger.info("Robot login") if not settings.IS_TEST_ENV: Slack.sendLoginNotice("Robot *{}* had login.".format( robotName, robotId)) robot.releaseLoginRobot(robotId) robot.updateHeartBeat(robotId) try: _thread.start_new_thread(robot.online, (robotId, )) except: logger.error("Error: unable to start thread") sys.exit(0) group = Group(newInstance, robotId) try: _thread.start_new_thread(group.fetechAndAddGroupRepeat, ()) except: logger.error("Error: unable to start thread") sys.exit(0) try: _thread.start_new_thread(group.fetechAndInvitRequestRepeat, ()) except: logger.error("Error: unable to start thread") sys.exit(0)
def logoutRobot(): logger.info("Robot logout") if not settings.IS_TEST_ENV: Slack.sendLoginNotice("Robot *{}* had logout.".format(robotName, robotId)) robot.logout(robotId)
def logoutRobot(): logger.info("Robot logout") Slack.sendLoginNotice("Robot *{}* had logout.".format(robotName, robotId)) sql = "insert into temp (temp) values (%s) " connection = mysql_pool.connection() cur = connection.cursor() cur.execute(sql, ("Robot logout"))
def loginRobot(): logger.info("Robot login") Slack.sendLoginNotice("Robot *{}* had login.".format(robotName, robotId)) sql = "insert into temp (temp) values (%s) " connection = mysql_pool.connection() cur = connection.cursor() cur.execute(sql, ("Robot login")) robot.releaseLoginRobot(robotId) robot.updateHeartBeat(robotId) try: _thread.start_new_thread(robot.online, (robotId, )) except: logger.error("Error: unable to start thread") exit()
newInstance = itchat.new_instance() storageFile = 'newInstance{}.pkl'.format(robotId) robot_qrcode_file = "{}/qr{}.png".format(settings.ROBOT_QRCODE_DIR, robotId) if not settings.IS_TEST_ENV: loggerItchat.info( "=================== LOGIN URL =====================") loggerItchat.info( "Scan QR code at http://199.167.138.175/qr{}.png".format(robotId)) Slack.sendLoginNotice( "Robot *{}* requests to login: http://199.167.138.175/qr{}.png". format(robotName, robotId)) #picDir=robot_qrcode_file newInstance.auto_login(enableCmdQR=settings.enableCmdQR, hotReload=True, statusStorageDir=storageFile, loginCallback=loginRobot, exitCallback=logoutRobot, picDir=robot_qrcode_file) # # save group general information # GroupInfo = newInstance.get_chatrooms() # # GroupNickName = GroupInfo['GroupNickName'] # for group in GroupInfo: # # get member list for each group
if currentFailoverIPServer is None: #FailoverIP is not assigned logger.warn('FailoverIP is not assigned. Assign to ' + firstPingableServer.nickname) netcupAPI.setFailoverIPRouting(firstPingableServer) logger.info('FailoverIP assigned, continue monitoring...') time.sleep(10) continue else: logger.info('Current failover server is ' + currentFailoverIPServer.nickname) ####### FAILOVER ####### # delete IP Routing logger.info("Delete FailoverIP from " + currentFailoverIPServer.nickname + " ... ") if netcupAPI.deleteFailoverIPRouting(currentFailoverIPServer): logger.info("FailoverIP routing deleted...") logger.info("Set new FailoverIP routing to " + firstPingableServer.nickname + " ... ") if netcupAPI.setFailoverIPRouting(firstPingableServer): slack = Slack(slackWebhookURL, logger) slack.sendMessage('Failover successfull from ' + currentFailoverIPServer.nickname + ' to ' + firstPingableServer.nickname) else: logger.error('Error in new Routing ... Restart') slack.sendMessage('Error in Failover ...') else: slack.sendMessage('Error in Failover ...')
import sys import time import requests from bs4 import BeautifulSoup as bs from multiprocessing import Pool # ../ 에 있는 애들부터 참조 가능 sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) # from modules.SeleniumDriver import selenium # from modules.Slack.slack import Slack from modules.slack import Slack from modules.selenium import Selenium from modules.mysql import Mysql slack = Slack() def get_leads(): mysql = Mysql() sql = ''' SELECT l.id AS leadId, l.title, l.instagram, n.thumbnailUrl AS latestThumbnailUrl, n.link AS latestLink FROM leads l