Exemplo n.º 1
0
def init():
    if __name__ == '__main__':
        try:
            import colored_traceback
            colored_traceback.add_hook(always=True)
        except ModuleNotFoundError:
            pass
        main()
Exemplo n.º 2
0
 def wrapped(args=None):
     colored_traceback.add_hook()
     try:
         main_func(args=args)
     except tsrc.Error as e:
         # "expected" failure, display it and exit
         if e.message:
             ui.error(e.message)
         sys.exit(1)
     except KeyboardInterrupt:
         ui.warning("Interrupted by user, quitting")
         sys.exit(1)
Exemplo n.º 3
0
def init_color():
    ''' encapsulate terminal color configuration so it could be more easily turned off if necessary
        only call this inside functions to prevent configuration bleed during module import
    '''
    ### enable color on windows
    with suppress(ImportError):
        import colorama
        colorama.init()

    ###
    import colored_traceback
    colored_traceback.add_hook( style='dark' )
Exemplo n.º 4
0
def main():
    args = parse_args()
    if args.shortcut:
        if args.always:
            import colored_traceback.always
        else:
            import colored_traceback.auto
    else:
        from colored_traceback import add_hook
        add_hook(always=args.always, debug=args.debug)

    x = object()
    x.thing()
Exemplo n.º 5
0
def main():
    args = parse_args()
    if args.shortcut:
        if args.always:
            import colored_traceback.always
        else:
            import colored_traceback.auto
    else:
        from colored_traceback import add_hook
        add_hook(always=args.always, colors=args.colors, debug=args.debug)

    x = object()
    x.thing()
Exemplo n.º 6
0
 def wrapped(args: ArgsList = None) -> None:
     colored_traceback.add_hook()
     try:
         main_func(args=args)
     except tsrc.Error as e:
         # "expected" failure, display it and exit note: we allow
         # tsrc.Error instances to have an empty message. In that
         # case, do not print anything and assume relevant info has
         # already been printed.
         if e.message:
             ui.error(e.message)
         sys.exit(1)
     except KeyboardInterrupt:
         ui.warning("Interrupted by user, quitting")
         sys.exit(1)
Exemplo n.º 7
0
def main():
    colored_traceback.add_hook()
    """Run administrative tasks."""
    dot_env_path = os.path.abspath('.env')
    if os.path.exists(dot_env_path):
        dotenv.read_dotenv()

    os.environ.setdefault('DJANGO_SETTINGS_MODULE',
                          'boilerplate_project.config.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?") from exc
    execute_from_command_line(sys.argv)
Exemplo n.º 8
0
def main(usda_directory):
    '''
    Generate soylent recipes. Output is written to recipes.txt
     
    E.g. soylent --usda-data data/usda_nutrient_db_sr28
    '''
    colored_traceback.add_hook()
    logging_.configure('soylent.log')
    logging.getLogger().setLevel(logging.DEBUG)
    nutrition_target = nutrition_target_.from_config()
    foods = foods_.import_usda(Path(usda_directory))
    foods = foods.set_index('description')
    foods = handle_nans(foods, nutrition_target, 10)
    foods = add_energy_components(foods)
    foods = foods[nutrition_target.index]  # ignore nutrients which do not appear in nutrition target
    foods = foods.astype(float)
    top_recipes = mine(nutrition_target, foods)
    output_result(foods, nutrition_target, top_recipes)
Exemplo n.º 9
0
Arquivo: main.py Projeto: nilium/tsrc
 def wrapped(args=None):
     colored_traceback.add_hook()
     try:
         main_func(args=args)
     except tsrc.Error as e:
         # "expected" failure, display it and exit
         ui.error(e)
         sys.exit(1)
     except SystemExit as e:
         # `ui.fatal()` or `sys.exit()` has been called,
         # assume message has already been displayed and
         # exit accordingly
         sys.exit(e.code)
     except KeyboardInterrupt:
         ui.warning("Interrupted by user, quitting")
         sys.exit(1)
     except Exception as e:
         # This is a bug: raise so that colored_traceback prints
         # an helpful backtrace
         raise
Exemplo n.º 10
0
    def __init__(self, args):
        # Plugin & Init Stuff
        # ===================
        self.PluginFolder = "./plugins"
        self.MainModule = "__init__"
        self.showBanner()
        self.plugins = []
        self.loadedPlugins = []
        self.args = args
        
        # Set hook to colored_traceback
        colored_traceback.add_hook()

        # MRU Stuff
        # =========
        # MRUDict: Key is plugin name
        #
        self.MRUDict = {}

        # Contains hardware, mem, proc, etc. info
        self.systemInfo = []

        # Go go go!
        self.go()
Exemplo n.º 11
0
    def __init__(self, args):
        # Plugin & Init Stuff
        # ===================
        self.PluginFolder = "./plugins"
        self.MainModule = "__init__"
        self.showBanner()
        self.plugins = []
        self.loadedPlugins = []
        self.args = args

        # Set hook to colored_traceback
        colored_traceback.add_hook()

        # MRU Stuff
        # =========
        # MRUDict: Key is plugin name
        #
        self.MRUDict = {}

        # Contains hardware, mem, proc, etc. info
        self.systemInfo = []

        # Go go go!
        self.go()
Exemplo n.º 12
0
#!/usr/bin/python

import argparse
import colored_traceback
import rospy

from robot_interface.moveit_interface import SawyerMoveitInterface
from cairo_lfd.core.lfd import LFD
from cairo_lfd.core.environment import Observation, Demonstration
from cairo_lfd.data.io import DataImporter, import_configuration

colored_traceback.add_hook()


def main():
    arg_fmt = argparse.RawDescriptionHelpFormatter
    parser = argparse.ArgumentParser(formatter_class=arg_fmt,
                                     description=main.__doc__)
    required = parser.add_argument_group('required arguments')

    required.add_argument(
        '-c', '--config', dest='config', required=True,
        help='the file path of configuration config.json file '
    )

    required.add_argument(
        '-d', '--directory', dest='directory', required=True,
        help='the directory from which to input labeled demonstration .json files'
    )

    parser.add_argument(
from ActionsBaseMgmt import ActionsBaseMgmt
from ActionMethodDecorator import ActionMethodDecorator

from AtYourServiceRepo import AtYourServiceRepo

from AtYourServiceTester import AtYourServiceTester

try:
    from AtYourServiceSandboxer import *
except:
    pass
import os


import colored_traceback
colored_traceback.add_hook(always=True)

class AtYourServiceFactory:

    def __init__(self):
        self.__jslocation__ = "j.atyourservice"

        self._init = False

        self._domains = []
        self._templates = {}

        # self.hrd = None

        self._type = None
Exemplo n.º 14
0
import io
import logging
import re
import traceback
from logging.handlers import RotatingFileHandler

try:
    import colored_traceback
    import colorlog
    from colored_traceback import Colorizer

    # color tracebacks in terminal - uncaught exceptions in scripts only, not logging
    colored_traceback.add_hook(style='jayme', always=True)
    Formatter = colorlog.ColoredFormatter
except ModuleNotFoundError:
    # running on azure
    Formatter = logging.Formatter

from smseventlog import config as cf
from smseventlog.config import AZURE_WEB

# simple colors
_palette = dict(black=30,
                red=31,
                green=32,
                yellow=33,
                blue=34,
                cyan=36,
                white=37,
                underline=4,
                reset=0)
Exemplo n.º 15
0
###########################################
import torch
from torch import optim
import torch.nn.functional as F
#from torch.autograd import Variable
import numpy as np
from time import time

###########################################
#from dataset_loader import dataset_class, data_loader  #TODO: Fix
from models import AECONV

###########################################
import pdb
import colored_traceback; colored_traceback.add_hook()

#%% Args setup
parser = argparse.ArgumentParser()

parser.add_argument('--n_times',  type=int, default=7)  #TODO: set
parser.add_argument('--n_feats',  type=int, default=600)  #TODO: set
parser.add_argument('--n_latent',  type=int, default=50)  #TODO: set
parser.add_argument('--n_classes',  type=int, default=2)  #TODO: set

################## Data
#parser.add_argument('--data', type=str, help='Path to the data directory',
#                    default=os.path.join(os.path.dirname(__file__), '../data/...')) #TODO: to be completed for data loading
#parser.add_argument('--log_dir', type=str, help='Directory relative which all output files are stored',
#                    default='/log/') 
#parser.add_argument('--small_part', dest='small_part', action='store_false')    
Exemplo n.º 16
0
from colored_traceback import add_hook
add_hook()
Exemplo n.º 17
0
import os
import sys
import colored_traceback

colored_traceback.add_hook()

# Check that a script was passed in.
if len(sys.argv) <= 1:
    raise SystemExit("Usage: python -m colored_traceback my_script.py")

# Check that the script exists.
script_path = sys.argv[1]
if not os.path.exists(script_path):
    raise SystemExit("Error: '%s' does not exist" % script_path)

# Replace colored_traceback's dir with script's dir in the module search path.
sys.path[0] = os.path.dirname(script_path)

# Remove colored_traceback from the arg list.
del sys.argv[0]

with open(script_path) as script_file:
    code = compile(script_file.read(), script_path, 'exec')
    variables = {}
    exec(code, variables, variables)
Exemplo n.º 18
0
import colored_traceback

# TODO: create a custom pygments style using: https://pygments.org/docs/styles/
colored_traceback.add_hook(always=True, style='solarized-dark')
Exemplo n.º 19
0
from colored_traceback import add_hook
add_hook(always=True)
Exemplo n.º 20
0
Contains the minimal necessary set of routines to run Ogma.
"""

# ---------------------------------------------------------------------------
# Standard imports:
import sys
import argparse
import os
import importlib
import importlib.util

# Third party imports
try:
    import colored_traceback

    colored_traceback.add_hook(style="native")
except ImportError:
    pass

import colorama
import argcomplete

# Local imports
from . import modelutils
from . import utils
from . import commands
from . import version

# ---------------------------------------------------------------------------

colorama.init()
Exemplo n.º 21
0
import numpy as np

try:
    import coloredlogs
except ImportError as e:
    coloredlogs = e

try:
    import requests
except ImportError as e:
    requests = e

try:
    import colored_traceback
    colored_traceback.add_hook(style="perldoc")
except ImportError as e:
    colored_traceback = e

_logger = lg.getLogger(__name__)
_timings = {}


class LogTime:
    """Log time of context.

    Args:
        name (str): name of context
    """
    def __init__(self, name):
        self.name = name
Exemplo n.º 22
0
def try_colored_traceback():
    try:
        import colored_traceback
        colored_traceback.add_hook()
    except ImportError:
        pass
Exemplo n.º 23
0
def colorize_error():
    import colored_traceback  # pip install colored_traceback
    colored_traceback.add_hook(always=True)
Exemplo n.º 24
0
try:
    import colored_traceback
    colored_traceback.add_hook(always=True)
except ModuleNotFoundError:
    pass

# required for plotting a large number of mesh-elements.
import matplotlib as mpl  # noqa: E402
mpl.rcParams['agg.path.chunksize'] = 10000

from AdcircPy import Model  # noqa: E402
from AdcircPy.AdcircPy import read_mesh, read_output  # noqa: E402

__author__ = "Jaime R. Calzada-Marrero"
__copyright__ = "Copyright 2019, Jaime R. Calzada-Marrero"
__credits__ = [
    "Saeed Moghimi", "Sergey Vinogradov", "Edward Myers", "Yuji Funakoshi",
    "NOAA/NOS/CSDL"
]
__license__ = "GPL"
__version__ = "0.0.9"
__maintainer__ = "Jaime R. Calzada"
__email__ = "*****@*****.**"
__status__ = "Development"

__all__ = ['read_mesh', 'read_output', 'Model']
Exemplo n.º 25
0
Arquivo: run.py Projeto: ifrpl/toddler
from .managers import crawlmanager, indexmanager
from .crawler import Crawler
from .analyser import Analyser
from .scheduler import Scheduler

from . import config
from . import setup
import argparse
import sys
import colorama
colorama.init(True)

try:
    import colored_traceback
    colored_traceback.add_hook(True)
except ImportError:
    pass

if __name__ == '__main__':

    parser = argparse.ArgumentParser()

    parser.add_argument("-p", "--process")
    parser.add_argument("-l", "--list", help="List processes",
                        action="store_true"),
    parser.add_argument("-c", "--config", help="Config file for process")

    processes = {
        "Crawler": Crawler,
        "Analyser": Analyser,
Exemplo n.º 26
0
import colored_traceback
colored_traceback.add_hook(always=True, style="light")
Exemplo n.º 27
0
from colored_traceback import add_hook
add_hook(colors=16)