Esempio n. 1
0
def init(config_path='production.ini'):
    global config, harold, zenoss
    config = load_config(path=config_path)
    if config.has_section('logging'):
        configure_logging(config)
    if config.has_section('graphite'):
        configure_graphite(config)
    if config.has_section('zenoss'):
        zenoss = get_zenoss(config)

    harold = wessex.connect_harold()
Esempio n. 2
0
def register(config, args, deployer, log):
    if not args.notify_irc:
        return

    harold = wessex.connect_harold()
    monitor = harold.get_deploy(args.push_id)

    def log_exception_and_continue(fn):
        def wrapper(*args, **kwargs):
            try:
                return fn(*args, **kwargs)
            except Exception, e:
                log.warning("Harold error: %s", e)
        return wrapper
Esempio n. 3
0
File: irc.py Progetto: spladug/push
def register(config, args, deployer, log):
    if not args.notify_irc:
        return

    harold = wessex.connect_harold()
    monitor = harold.get_deploy(args.push_id)

    def log_exception_and_continue(fn):
        def wrapper(*args, **kwargs):
            try:
                return fn(*args, **kwargs)
            except Exception, e:
                log.warning("Harold error: %s", e)

        return wrapper
# locations
location_db = {}
City = collections.namedtuple("City", ["name", "timezone", "code"])
for short, info in config.items("locations"):
    data = map(string.strip, info.split(","))
    data.append(short)
    location_db[short] = City(*data)

# https://github.com/spladug/wessex
irc_channel = None
message_format = None
try:
    import wessex
    if config.has_section("harold"):
        harold = wessex.connect_harold(["/etc/harold.ini", CONFIG_FILE])
        irc_channel = harold.get_irc_channel(config.get("harold", "channel"))
        message_format = config.get("harold", "message_format")
except ImportError:
    pass

def constant_time_compare(actual, expected):
    """
    Returns True if the two strings are equal, False otherwise

    The time taken is dependent on the number of characters provided
    instead of the number of characters that match.
    """
    actual_len   = len(actual)
    expected_len = len(expected)
    result = actual_len ^ expected_len