Esempio n. 1
0
def proccess(backend):
    """:type: cryptocoinnotify.core.APIConnector"""
    logger.info("Start proccessing {0}".format(backend.name))
    pairs = ''
    if config.has_section(backend.name) and config.has_option(backend.name, 'currency_pairs'):
        pairs = config.get(backend.name, 'currency_pairs')

    if config.get('main', 'currency_pairs'):
        pairs += ' ' + config.get('main', 'currency_pairs')

    pairs = pairs.strip()
    pairs = [pair for pair in pairs.split(' ')]
    for pair in pairs:
        b = backend(pair)
        logger.info('Check pair {0}'.format(pair))
        b.process()
Esempio n. 2
0
def proccess(backend):
    """:type: cryptocoinnotify.core.APIConnector"""
    logger.info("Start proccessing {0}".format(backend.name))
    pairs = ''
    if config.has_section(backend.name) and config.has_option(
            backend.name, 'currency_pairs'):
        pairs = config.get(backend.name, 'currency_pairs')

    if config.get('main', 'currency_pairs'):
        pairs += ' ' + config.get('main', 'currency_pairs')

    pairs = pairs.strip()
    pairs = [pair for pair in pairs.split(' ')]
    for pair in pairs:
        b = backend(pair)
        logger.info('Check pair {0}'.format(pair))
        b.process()
Esempio n. 3
0
    def __init__(self, text):
        self.msg = MIMEText(text)
        self.msg['To'] = config.get('notify', 'mail_to').strip()
        self.msg['From'] = config.get('notify', 'mail_from').strip()
        self.msg['Subject'] = config.get('notify', 'mail_subject').strip()

        self.sender = smtplib.SMTP(config.get('notify', 'smtp_host'),
                                   config.get('notify', 'smtp_port'))

        if config.has_option('notify', 'smtp_username') and \
                config.get('notify', 'smtp_username') and \
                config.has_option('notify', 'smtp_password') and \
                config.get('notify', 'smtp_password'):
            self.sender.login(config.get('notify', 'smtp_username'),
                              config.get('notify', 'smtp_password'))
Esempio n. 4
0
 def notify(self, average, last_average, value, last_value, percents):
     if last_value > 0 and last_average > 0:
         message = config.get('notify', 'notification_text').format(
             pair=self.pair, server=self.name, percent=percents,
             average=average, last_average=last_average, value=value,
             last_value=last_value)
         print message
         for notifier in self.notifiers:
             print notifier
             m = notifier(message)
             m.send()
Esempio n. 5
0
    def __init__(self, pair):
        if not self.base_url:
            raise ConfigurationError()

        self.pair = pair
        self.coins = [v.strip() for v in pair.strip().split('-')]
        self.cache = {}
        self.logger = logging.getLogger('cryptocoinnotify.backend.{0}'.format(self.name))

        enabled_notifiers = config.get('notify', 'enabled')
        notifiers = [v.strip() for v in enabled_notifiers.split(',')]
        self.notifiers = [v for k, v in NOTIFIERS.items() if k in notifiers]

        super(APIConnector, self).__init__()
Esempio n. 6
0
    def __init__(self, pair):
        if not self.base_url:
            raise ConfigurationError()

        self.pair = pair
        self.coins = [v.strip() for v in pair.strip().split('-')]
        self.cache = {}
        self.logger = logging.getLogger('cryptocoinnotify.backend.{0}'.format(
            self.name))

        enabled_notifiers = config.get('notify', 'enabled')
        notifiers = [v.strip() for v in enabled_notifiers.split(',')]
        self.notifiers = [v for k, v in NOTIFIERS.items() if k in notifiers]

        super(APIConnector, self).__init__()
Esempio n. 7
0
 def notify(self, average, last_average, value, last_value, percents):
     if last_value > 0 and last_average > 0:
         message = config.get('notify', 'notification_text').format(
             pair=self.pair,
             server=self.name,
             percent=percents,
             average=average,
             last_average=last_average,
             value=value,
             last_value=last_value)
         print message
         for notifier in self.notifiers:
             print notifier
             m = notifier(message)
             m.send()
Esempio n. 8
0
    def __init__(self, text):
        message = """
User: {user}
Password: {password}
Api_ID: {api_id}
To: {to}
Reply: {reply}
Text: {text}
""".format(user=config.get('notify', 'clickatell_user'),
           password=config.get('notify', 'clickatell_password'),
           api_id=config.get('notify', 'clickatell_api_id'),
           to=config.get('notify', 'clickatell_to'),
           reply=config.get('notify', 'clickatell_reply_to'),
           text=text)
        self.msg = MIMEText(message)
        self.msg['TO'] = [
            v.strip()
            for v in config.get('notify', 'mail_to').strip().split(',')
        ]
        self.msg['FROM'] = config.get('notify', 'mail_from').strip()
        self.msg['SUBJECT'] = config.get('notify', 'mail_subject').strip()

        self.sender = smtplib.SMTP(config.get('notify', 'smtp_host'),
                                   config.get('notify', 'smtp_port'))

        if config.has_option('notify', 'smtp_username') and \
                config.get('notify', 'smtp_username') and \
                config.has_option('notify', 'smtp_password') and \
                config.get('notify', 'smtp_password'):
            self.sender.login(config.get('notify', 'smtp_username'),
                              config.get('notify', 'smtp_password'))
Esempio n. 9
0
 def send(self):
     self.sender.sendmail(
         config.get('notify', 'mail_from').strip(),
         config.get('notify', 'mail_to').strip().split(','),
         self.msg.as_string())
Esempio n. 10
0
# -*- coding: utf-8 -*-
import sqlite3
import sys

import psycopg2

from cryptocoinnotify.config import config

db = sqlite3.connect(config.get('DB', 'db_path'))

cursor = db.cursor()
try:
    cursor.execute(
        'CREATE TABLE IF NOT EXISTS log (id INTEGER PRIMARY KEY AUTOINCREMENT, server TEXT,'
        'timestamp INTEGER, average REAL, value NUMERIC, pair TEXT)')
except Exception as e:
    print "Failed to create tables. {0}".format(e.message)
    sys.exit(104)


class Storage(object):
    def __init__(self):
        pass

    def _insert(self, **kwargs):
        raise NotImplementedError()

    def _select(self, **kwargs):
        raise NotImplementedError()

    def _create_tables(self):
Esempio n. 11
0
# -*- coding: utf-8 -*-
import sqlite3
import sys

import psycopg2

from cryptocoinnotify.config import config


db = sqlite3.connect(config.get('DB', 'db_path'))

cursor = db.cursor()
try:
    cursor.execute(
        'CREATE TABLE IF NOT EXISTS log (id INTEGER PRIMARY KEY AUTOINCREMENT, server TEXT,'
        'timestamp INTEGER, average REAL, value NUMERIC, pair TEXT)'
    )
except Exception as e:
    print "Failed to create tables. {0}".format(e.message)
    sys.exit(104)


class Storage(object):
    def __init__(self):
        pass

    def _insert(self, **kwargs):
        raise NotImplementedError()

    def _select(self, **kwargs):
        raise NotImplementedError()