def monitor(): ''' monitor() - Main function... creates and starts threads ''' import argparse parser = argparse.ArgumentParser() parser.add_argument("-v", "--verbose", help="more verbose", action="store_true") args = parser.parse_args() level = logging.INFO if args.verbose: level = logging.DEBUG logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s', filename=log_file, level=level) logging.debug('Monitoring...') pastebin_thread = threading.Thread(target=Pastebin().monitor, args=[]) slexy_thread = threading.Thread(target=Slexy().monitor, args=[]) pastie_thead = threading.Thread(target=Pastie().monitor, args=[]) for thread in (pastebin_thread, slexy_thread, pastie_thead): thread.daemon = True thread.start() # Let threads run try: while (1): sleep(5) except KeyboardInterrupt: logging.warn('Stopped.')
def monitor(): ''' monitor() - Main function... creates and starts threads ''' import argparse parser = argparse.ArgumentParser() parser.add_argument( "-v", "--verbose", help="more verbose", action="store_true") args = parser.parse_args() rotate() level = logging.INFO if args.verbose: level = logging.DEBUG logging.basicConfig( format='%(asctime)s [%(levelname)s] %(message)s', filename=log_file, level=level) logging.info('Monitoring...') bot = Twitter( auth=OAuth(ACCESS_TOKEN, ACCESS_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET) ) # Create lock for both output log and tweet action log_lock = threading.Lock() tweet_lock = threading.Lock() pastebin_thread = threading.Thread( target=Pastebin().monitor, args=[bot, tweet_lock]) slexy_thread = threading.Thread( target=Slexy().monitor, args=[bot, tweet_lock]) pastie_thead = threading.Thread( target=Pastie().monitor, args=[bot, tweet_lock]) pastebin_ru_thread = threading.Thread( target=Pastebin_ru().monitor, args=[bot, tweet_lock]) nopaste_thread = threading.Thread( target=Nopaste().monitor, args=[bot, tweet_lock]) safebin_thread = threading.Thread( target=Safebin().monitor, args=[bot, tweet_lock]) """for thread in (pastebin_thread, slexy_thread, pastie_thead, pastebin_ru_thread, nopaste_thread, safebin_thread): thread.daemon = True thread.start()""" for thread in (pastebin_thread, slexy_thread, pastie_thead, pastebin_ru_thread, nopaste_thread, safebin_thread): thread.daemon = True thread.start() # Let threads run try: # i = 0 while(1): # i += 1 sleep(5) # if i == 6: # for thread in (pastebin_thread, slexy_thread, pastie_thead, pastebin_ru_thread, nopaste_thread): # if not thread.isAlive: # thread.daemon = True # thread.start() except KeyboardInterrupt: logging.warn('Stopped.')
def monitor(): ''' monitor() - Main function... creates and starts threads ''' import argparse parser = argparse.ArgumentParser() parser.add_argument( "-v", "--verbose", help="more verbose", action="store_true") args = parser.parse_args() level = logging.INFO if args.verbose: level = logging.DEBUG logging.basicConfig( format='%(asctime)s [%(levelname)s] %(message)s', datefmt="%d-%m-%Y %H:%M:%S", filename=log_file, level=level) logging.info('Monitoring...') ### To enable tweets, uncomment the following lines ### '''bot = Twitter( auth=OAuth(ACCESS_TOKEN, ACCESS_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET) )''' ### And delete the next ones ### bot = None ########## # Create lock for both output log and tweet action log_lock = threading.Lock() tweet_lock = threading.Lock() if not os.path.isdir("saves"): try: os.makedirs("saves") except Exception: logging.error("Failed to create the 'saves' directory") sys.exit() pastebin_thread = threading.Thread( target=Pastebin().monitor, args=[bot, tweet_lock]) slexy_thread = threading.Thread( target=Slexy().monitor, args=[bot, tweet_lock]) pastie_thead = threading.Thread( target=Pastie().monitor, args=[bot, tweet_lock]) for thread in (pastebin_thread, slexy_thread, pastie_thead): thread.daemon = True thread.start() # Let threads run try: while(1): sleep(5) except KeyboardInterrupt: logging.warn('Stopped.')
def monitor(): setLog() check_req() pastebin_thread = threading.Thread(target=Pastebin().monitor, args=[]) slexy_thread = threading.Thread(target=Slexy().monitor, args=[]) pastie_thead = threading.Thread(target=Pastie().monitor, args=[]) for thread in (pastebin_thread, slexy_thread, pastie_thead): thread.daemon = True thread.start() try: while (1): sleep(5) except KeyboardInterrupt: logging.warn('Stopped.')
def monitor(): ''' monitor() - Main function... creates and starts threads ''' import argparse parser = argparse.ArgumentParser() parser.add_argument("-v", "--verbose", help="more verbose", action="store_true") parser.add_argument("-t", "--test", help="test a plugin") args = parser.parse_args() if not args.test: rotate() # do not rotate in test mode level = logging.INFO if args.verbose: level = logging.DEBUG logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s', filename=log_file, level=level) logging.info('Monitoring...') if USE_TWITTER: bot = Twitter(auth=OAuth(ACCESS_TOKEN, ACCESS_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET)) else: bot = None # Create lock for both output log and tweet action log_lock = threading.Lock() tweet_lock = threading.Lock() threads = [] if args.test: # test mode if args.test == 'pastebin': Pastebin().monitor(bot, tweet_lock, False) if args.test == 'pastebin_ru': Pastebin_ru().monitor(bot, tweet_lock, False) logging.info('Test finished') sys.exit(0) else: if USE_PASTEBIN: threads.append( threading.Thread(target=Pastebin().monitor, args=[bot, tweet_lock])) if USE_SLEXY: threads.append( threading.Thread(target=Slexy().monitor, args=[bot, tweet_lock])) if USE_PASTIE: threads.append( threading.Thread(target=Pastie().monitor, args=[bot, tweet_lock])) if USE_PASTEBIN_RU: threads.append( threading.Thread(target=Pastebin_ru().monitor, args=[bot, tweet_lock])) if USE_NOPASTE: threads.append( threading.Thread(target=Nopaste().monitor, args=[bot, tweet_lock])) if USE_SAFEBIN: threads.append( threading.Thread(target=Safebin().monitor, args=[bot, tweet_lock])) for thread in threads: thread.daemon = True thread.start() # Let threads run try: # i = 0 while (1): sleep(5) except KeyboardInterrupt: logging.warn('Stopped.')