#!/usr/bin/env python # -*- coding: utf-8 -*- from sys import stderr from traceback import format_exc # Check dependencies try: from colifrapy.tools.colorize import colorize colorize('a', style='bold') except (ImportError, TypeError) as e: stderr.write("ERROR: Could not load module colifrapy.\nERROR: Please check your install or run `./bin/update_requirements.sh` to update the dependencies.") exit(1) try: import pymongo, txmongo, lxml, twisted, twitter, feedparser, pypump except ImportError as e: stderr.write(colorize("ERROR: Could not load module%s.\nERROR: Please check your install or run `./bin/update_requirements.sh` to update the dependencies.\n" % str(e).replace('No module named', ''), 'red', style='bold')) exit(1) #Load decorator from gazouilleur.lib.log import logerr # Check config.py try: from gazouilleur import config except ImportError: logerr("Could not find `gazouilleur/config.py`.\nERROR: Please run `bash bin/configure.sh` to create it, then edit it to prepare your bot.") exit(1) except SyntaxError as e: logerr("Could not read `gazouilleur/config.py`.\nERROR: Please edit it to fix the following syntax issue:\nERROR: %s\n%s" % (e, "\n".join(format_exc().splitlines()[-3:-1]))) exit(1)
#!/usr/bin/env python # -*- coding: utf-8 -*- from sys import stderr from traceback import format_exc # Check dependencies try: from colifrapy.tools.colorize import colorize colorize('a', style='bold') except (ImportError, TypeError) as e: stderr.write("ERROR: Could not load module colifrapy.\nERROR: Please check your install or run `./bin/update_requirements.sh` to update the dependencies.\n") exit(1) try: import pymongo, txmongo, txmongo.connection, lxml, twisted, twitter, feedparser, pypump except ImportError as e: stderr.write(colorize("ERROR: Could not load module%s.\nERROR: Please check your install or run `./bin/update_requirements.sh` to update the dependencies.\n" % str(e).replace('No module named', ''), 'red', style='bold')) exit(1) # Check config.py try: from gazouilleur import config except ImportError: stderr.write(colorize("Could not find `gazouilleur/config.py`.\nERROR: Please run `bash bin/configure.sh` to create it, then edit it to prepare your bot.\n", 'red', style='bold')) exit(1) except SyntaxError as e: stderr.write(colorize("Could not read `gazouilleur/config.py`.\nERROR: Please edit it to fix the following syntax issue:\nERROR: %s\n%s\n" % (e, "\n".join(format_exc().splitlines()[-3:-1])), 'red', style='bold')) exit(1) #Load decorator from gazouilleur.lib.log import logerr
def colr(text, color, bold=True): if COLOR_LOGS: return colorize(text, color, style='bold' if bold else '') return text
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, traceback # Check dependencies try: from colifrapy.tools.colorize import colorize colorize('a', style='bold') except (ImportError, TypeError) as e: sys.stderr.write("ERROR: Could not load module colifrapy.\nERROR: Please check your install or run `pip install -r requirements.txt` from gazouilleur's virtualenv.") exit(1) try: import pymongo, lxml, twisted, twitter, feedparser, pypump except ImportError as e: sys.stderr.write(colorize("ERROR: Could not load module%s.\nERROR: Please check your install or run `pip install -r requirements.txt` from gazouilleur's virtualenv.\n" % str(e).replace('No module named', ''), 'red', style='bold')) exit(1) #Load decorator from gazouilleur.lib.log import logerr # Check config.py try: from gazouilleur import config except ImportError: logerr("Could not find `gazouilleur/config.py`.\nERROR: Please run `bash bin/configure.sh` to create it, then edit it to prepare your bot.") exit(1) except SyntaxError as e: _, _, exc_traceback = sys.exc_info() logerr("Could not read `gazouilleur/config.py`.\nERROR: Please edit it to fix the following syntax issue:\nERROR: %s\n%s" % (e, "\n".join(traceback.format_exc().splitlines()[-3:-1]))) exit(1)
def colr(text, color, bold=True): return colorize(text, color, style="bold" if bold else "")