Skip to content

Commit

Permalink
Fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Garrett Heel committed Dec 20, 2016
1 parent 1050547 commit 865f813
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 72 deletions.
19 changes: 7 additions & 12 deletions graphite_beacon/alerts.py
@@ -1,22 +1,17 @@
"""Implement alerts."""

import math

from collections import deque, defaultdict
from collections import defaultdict, deque
from itertools import islice

from tornado import ioloop, httpclient as hc, gen, log, escape
from tornado import httpclient as hc
from tornado import escape, gen, ioloop, log

from . import _compat as _, units
from . import _compat as _
from . import units
from .graphite import GraphiteRecord
from .units import MILLISECOND, TimeUnit
from .utils import (
HISTORICAL,
LOGICAL_OPERATORS,
convert_to_format,
parse_rule,
)

from .utils import HISTORICAL, LOGICAL_OPERATORS, convert_to_format, parse_rule

LOGGER = log.gen_log
METHODS = "average", "last_value", "sum", "minimum", "maximum"
Expand Down Expand Up @@ -275,7 +270,7 @@ def load(self):
connect_timeout=self.connect_timeout,
validate_cert=self.validate_cert)
records = (
GraphiteRecord(line.decode('utf-8'), self.default_nan_value, self.ignore_nan)
GraphiteRecord(line, self.default_nan_value, self.ignore_nan)
for line in response.buffer)
data = [
(None if record.empty else getattr(record, self.method), record.target)
Expand Down
1 change: 0 additions & 1 deletion graphite_beacon/app.py
Expand Up @@ -7,7 +7,6 @@

from .core import Reactor


LOGGER = log.gen_log
DEFAULT_CONFIG_PATH = 'config.json'

Expand Down
13 changes: 6 additions & 7 deletions graphite_beacon/core.py
@@ -1,17 +1,16 @@
import sys
import os
from re import compile as re, M

import json
import logging
import os
import sys
from re import compile as re
from re import M

from tornado import ioloop, log
import yaml
from tornado import ioloop, log

from .alerts import BaseAlert
from .units import MILLISECOND, TimeUnit
from .handlers import registry

from .units import MILLISECOND, TimeUnit

LOGGER = log.gen_log

Expand Down
2 changes: 1 addition & 1 deletion graphite_beacon/handlers/cli.py
@@ -1,6 +1,6 @@
import subprocess

from graphite_beacon.handlers import AbstractHandler, LOGGER
from graphite_beacon.handlers import LOGGER, AbstractHandler


class CliHandler(AbstractHandler):
Expand Down
5 changes: 3 additions & 2 deletions graphite_beacon/handlers/hipchat.py
@@ -1,8 +1,9 @@
import json

from tornado import gen, httpclient as hc
from tornado import httpclient as hc
from tornado import gen

from graphite_beacon.handlers import AbstractHandler, LOGGER
from graphite_beacon.handlers import LOGGER, AbstractHandler


class HipChatHandler(AbstractHandler):
Expand Down
5 changes: 3 additions & 2 deletions graphite_beacon/handlers/http.py
@@ -1,8 +1,9 @@
import urllib

from tornado import gen, httpclient as hc
from tornado import httpclient as hc
from tornado import gen

from graphite_beacon.handlers import AbstractHandler, LOGGER
from graphite_beacon.handlers import LOGGER, AbstractHandler


class HttpHandler(AbstractHandler):
Expand Down
2 changes: 1 addition & 1 deletion graphite_beacon/handlers/log.py
@@ -1,4 +1,4 @@
from graphite_beacon.handlers import AbstractHandler, LOGGER
from graphite_beacon.handlers import LOGGER, AbstractHandler


class LogHandler(AbstractHandler):
Expand Down
5 changes: 3 additions & 2 deletions graphite_beacon/handlers/pagerduty.py
@@ -1,8 +1,9 @@
import json

from tornado import gen, httpclient as hc
from tornado import httpclient as hc
from tornado import gen

from graphite_beacon.handlers import AbstractHandler, LOGGER
from graphite_beacon.handlers import LOGGER, AbstractHandler


class PagerdutyHandler(AbstractHandler):
Expand Down
5 changes: 3 additions & 2 deletions graphite_beacon/handlers/slack.py
@@ -1,8 +1,9 @@
import json

from tornado import gen, httpclient as hc
from tornado import httpclient as hc
from tornado import gen

from graphite_beacon.handlers import AbstractHandler, LOGGER
from graphite_beacon.handlers import LOGGER, AbstractHandler
from graphite_beacon.template import TEMPLATES


Expand Down
4 changes: 2 additions & 2 deletions graphite_beacon/handlers/smtp.py
Expand Up @@ -3,9 +3,9 @@
from email.mime.text import MIMEText
from smtplib import SMTP

from tornado import gen, concurrent
from tornado import concurrent, gen

from graphite_beacon.handlers import AbstractHandler, TEMPLATES, LOGGER
from graphite_beacon.handlers import LOGGER, TEMPLATES, AbstractHandler


class SMTPHandler(AbstractHandler):
Expand Down
4 changes: 3 additions & 1 deletion graphite_beacon/handlers/telegram.py
Expand Up @@ -2,11 +2,13 @@

import json
from os.path import exists

from tornado import gen, httpclient

from graphite_beacon.handlers import AbstractHandler, LOGGER
from graphite_beacon.handlers import LOGGER, AbstractHandler
from graphite_beacon.template import TEMPLATES


HELP_MESSAGE = """Telegram handler for graphite-beacon
*usage* /command [parameters]
*examples*
Expand Down
10 changes: 6 additions & 4 deletions graphite_beacon/handlers/victorops.py
@@ -1,13 +1,15 @@
import json

from tornado import httpclient as hc
from tornado import gen

from graphite_beacon.handlers import LOGGER, AbstractHandler

try:
from urlparse import urljoin
except ImportError:
from urllib.parse import urljoin

from tornado import gen, httpclient as hc

from graphite_beacon.handlers import AbstractHandler, LOGGER


class VictorOpsHandler(AbstractHandler):

Expand Down
1 change: 0 additions & 1 deletion graphite_beacon/template.py
Expand Up @@ -2,7 +2,6 @@

from tornado import template


LOADER = template.Loader(op.join(op.dirname(op.abspath(__file__)), 'templates'), autoescape=None)
TEMPLATES = {
'graphite': {
Expand Down
1 change: 0 additions & 1 deletion graphite_beacon/units.py
Expand Up @@ -2,7 +2,6 @@

import re


NUMBER_RE = re.compile(r'(?P<value>\-?\d*\.?\d*)(?P<unit>\w+)')

# Time units
Expand Down
7 changes: 3 additions & 4 deletions graphite_beacon/utils.py
@@ -1,9 +1,8 @@
from re import compile as re
import operator as op
from re import compile as re

from funcparserlib.lexer import make_tokenizer, Token
from funcparserlib.parser import (some, a, maybe, finished, skip, many)

from funcparserlib.lexer import Token, make_tokenizer
from funcparserlib.parser import a, finished, many, maybe, skip, some

# NOTE: the unit conversions below should be considered deprecated and migrated
# over to `unit.py` instead.
Expand Down
12 changes: 3 additions & 9 deletions tests/integration/graphite_test.py
@@ -1,21 +1,15 @@
import mock

from mock import ANY

from itertools import cycle, imap

import tornado.gen

from mock import ANY
from tornado import ioloop
from tornado.httpclient import HTTPResponse, HTTPRequest
from tornado.httpclient import HTTPRequest, HTTPResponse
from tornado.testing import AsyncTestCase, gen_test

from graphite_beacon.alerts import GraphiteAlert
from graphite_beacon.core import Reactor

from ..util import build_graphite_response


fetch_mock_url = lambda m: m.call_args_list[0][0][0]


Expand Down Expand Up @@ -56,7 +50,7 @@ def test_graphite(self, mock_smpt_notify, mock_fetch):
buffer=build_graphite_response(data=metric_data))

mock_fetch.side_effect = iter(tornado.gen.maybe_future(build_resp())
for _ in xrange(100))
for _ in range(100))

rr.start(start_loop=False)
yield tornado.gen.sleep(0.5)
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/alerts_test.py
@@ -1,11 +1,10 @@
import mock

from graphite_beacon import units
from graphite_beacon._compat import urlparse
from graphite_beacon.alerts import BaseAlert, GraphiteAlert, URLAlert
from graphite_beacon.core import Reactor
from graphite_beacon.units import SECOND
from graphite_beacon._compat import urlparse


BASIC_ALERT_OPTS = {
'name': 'GraphiteTest',
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/handlers/smtp_test.py
@@ -1,5 +1,5 @@
from graphite_beacon.handlers.smtp import SMTPHandler
from graphite_beacon.alerts import BaseAlert
from graphite_beacon.handlers.smtp import SMTPHandler


def test_html_template(reactor):
Expand Down
13 changes: 3 additions & 10 deletions tests/unit/units_test.py
@@ -1,15 +1,8 @@
import pytest

from graphite_beacon.units import (
DAY,
HOUR,
MILLISECOND,
MINUTE,
MONTH,
SECOND,
TimeUnit,
YEAR,
)
from graphite_beacon.units import (DAY, HOUR, MILLISECOND, MINUTE, MONTH,
SECOND, YEAR, TimeUnit)


class TestTimeUnit(object):
def test_from_interval(self):
Expand Down
10 changes: 3 additions & 7 deletions tests/unit/utils_test.py
@@ -1,15 +1,11 @@
import operator as op

import pytest

from funcparserlib.lexer import LexerError

from graphite_beacon.utils import (
convert_to_format,
convert_from_format,
parse_rule as parse_rule,
IDENTITY
)
from graphite_beacon.utils import parse_rule as parse_rule
from graphite_beacon.utils import (IDENTITY, convert_from_format,
convert_to_format)


def test_convert():
Expand Down

0 comments on commit 865f813

Please sign in to comment.