Esempio n. 1
0
def main():
    # init the rtm client
    client = RTMClient(cfg.get('main', 'rtm_token'),
                       "https://rtm.bearychat.com")

    resp = client.start()  # get rtm user and ws_host
    user = resp["user"]
    ws_host = resp["ws_host"]

    loop = RTMLoop(ws_host)  # init the loop
    loop.start()
    time.sleep(2)

    def message_consumer(message):
        r = ''
        while True:
            text = yield r
            if not text:
                return
            reply = message.refer(text)
            try:
                loop.send(reply)
            except Exception:
                continue

    while True:
        error = loop.get_error()

        if error:
            print(error)
            continue

        message = loop.get_message(True, 5)

        try:
            print("rtm loop received {0} from {1}".format(
                message["text"], message["uid"]))
        except Exception:
            continue

        if message.is_mention_user(user):
            message_produce = handle_message(message)
            message_produce(message_consumer(message))
        elif shell_model.in_shell_model(message['uid']):
            shell_model.exec(message_consumer(message), message)
Esempio n. 2
0
def run(consumer):
    try:
        rebase_dev_cmd = "git reset --hard && git checkout dev && git pull --rebase origin dev"
        consumer.send(rebase_dev_cmd)
        consumer.send(exec_cmd(rebase_dev_cmd))

        update_local_pods = "make update-local-pods"
        consumer.send(update_local_pods)
        consumer.send(exec_cmd(update_local_pods))

        pod_install = "pod install"
        consumer.send(pod_install)
        consumer.send(exec_cmd(pod_install))

        beta_cmd = "UNLOCK_PWD={pwd} && fastlane beta".format(pwd=cfg.get('main', 'unlock_pwd'))
        consumer.send('fastlane beta')
        consumer.send(exec_cmd(beta_cmd, True))

    except SubprocessError as error:
        consumer.send(error.__str__())
Esempio n. 3
0
import json, tempfile, os
import pygeoip
from urlparse import urlparse

gi = pygeoip.GeoIP('GeoIPCity.dat')

# todo maybe there's a better way to do it
cache_persistence_period = 3  # save cache on every 3rd request
cache_persistence_counter = 0

torexits = []
with open('torexits.csv', 'r') as fp:
    torexits = [x.strip() for x in fp]

app = Flask(__name__)
app.secret_key = cfg.get('app', 'secret_key')

vendormap = {
    "windows": "Microsoft",
    "linux": "Linux",
}


@app.context_processor
def contex():
    global cfg, query
    return {'cfg': cfg, 'query': '', 'path': request.path}


def getISP(ip):
    tmp = gi.record_by_addr(ip)
Esempio n. 4
0
from flask_mail import Mail, Message
from common import cfg
from pygeoip import GeoIP
from lepl.apps.rfc3696 import Email
import os, random, itertools, hmac, hashlib

basepath=os.path.dirname(os.path.abspath(__file__))
geoipdb = GeoIP('%s/GeoIP.dat' % basepath)
geoipcdb = GeoIP('%s/GeoIPCity.dat' % basepath)

fp=open('%s/torexits.csv' % basepath,'r')
torexits=[x.strip() for x in fp]
fp.close()

app = Flask(__name__)
app.secret_key = cfg.get('app', 'secret_key')
app.config.update(
	DEBUG=True,
	MAIL_FAIL_SILENTLY = False,
	#EMAIL SETTINGS
	MAIL_SERVER='localhost',
	MAIL_PORT=8825,
	#MAIL_USE_SSL=True,
	#MAIL_USERNAME = '******',
	#MAIL_PASSWORD = '******'
	)
mail = Mail(app)

with open('%s/secret' % basepath,'r') as f:
    secret=f.read().strip()
Esempio n. 5
0
#
# (c) 2012- by adam tauber, <*****@*****.**>

if __name__ == '__main__':
    from sys import path
    from os.path import realpath, dirname
    path.append(realpath(dirname(realpath(__file__))+'/../../'))

from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, Text, DateTime, Boolean, PickleType
from sqlalchemy.orm import relationship, scoped_session, sessionmaker, backref
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime
from pickle import dumps, loads
from common import cfg

engine = create_engine(cfg.get('database', 'connection'))
db_session = scoped_session(sessionmaker(autocommit=False,
                                         autoflush=False,
                                         bind=engine))

Base = declarative_base()
Base.metadata.bind = engine
Base.query = db_session.query_property()

class User(Base):
    __tablename__ = 'users'
    user_id       = Column(Integer, primary_key=True)
    name          = Column(String(511))
    password      = Column(String(511))
    is_active     = Column(Boolean)