Beispiel #1
0
def fetch_uids():
    BaseModel.install()
    f = open("/data/uids/201706012213.txt")
    for uid in f:
        if uid.strip():
            yield stats_friends(uid.strip())
            yield gen.sleep(0.01)
    f.close()
Beispiel #2
0
def fetch_uids():
    BaseModel.install()
    msg_type1 = ["cat_cos_icon188"]
    msg_type2 = ["cat_cos_icon191_1", "cat_cos_icon191_2", "cat_cos_icon191_3"]
    msg_type3 = ["cat_coa_icon_192_1", "cat_coa_icon_192_2"]
    f = open("/data/uids/uids.txt")
    for uid in f:
        if uid.strip():
            yield msg_send(msg_type1, uid.strip())
            yield gen.sleep(0.01)
    f.close()
Beispiel #3
0
    def __init__(self, wrk_num):
        self.worker_mum = wrk_num
        # Initialize a zeromq context
        self.context = zmq.Context()
        loop = ioloop.IOLoop.instance()

        self.pull = self.context.socket(zmq.PULL)
        for host in options.push_host.split(";"):
            self.pull.connect(host)

        self.stream = zmqstream.ZMQStream(self.pull, loop)
        self.stream.on_recv(self.on_message)

        BaseModel.install()
        logging.info("start process : %d", self.worker_mum)
        logging.info("remote push host : %s", options.push_host)
Beispiel #4
0
def main():
    BaseModel.install()
    try:
        f = open("/home/sumikko/pitayaserver/config/activity.json")
        f.seek(0)
        data = f.read(1024 * 64)
        f.close()
        configs = tornado.escape.json_decode(data)
        today = datetime.date.today()
        tomorrow = datetime.date.today() + datetime.timedelta(days=1)
        content = ""
        for config in configs:
            start_date = datetime.datetime.strptime(config["start_time"],
                                                    "%Y/%m/%d %H:%M").date()
            over_date = datetime.datetime.strptime(config["over_time"],
                                                   "%Y/%m/%d %H:%M").date()
            event = config.get("activity_id")
            if tomorrow == start_date:
                content += ("活动配置[%(activity_id)s - " +
                            events.get(event, event) +
                            "]将在明天[%(start_time)s]自动启用,请注意检查配置\r\n") % config
            if today == start_date:
                content += ("活动配置[%(activity_id)s - " +
                            events.get(event, event) +
                            "]将在今天[%(start_time)s]自动启用,请注意检查配置\r\n") % config
        content += "\r\n"
        for config in configs:
            start_date = datetime.datetime.strptime(config["start_time"],
                                                    "%Y/%m/%d %H:%M").date()
            over_date = datetime.datetime.strptime(config["over_time"],
                                                   "%Y/%m/%d %H:%M").date()
            event = config.get("activity_id")
            if tomorrow == over_date:
                content += ("活动配置[%(activity_id)s - " +
                            events.get(event, event) +
                            "]将在明天[%(over_time)s]自动停用,请注意检查配置\r\n") % config
            if today == over_date:
                content += ("活动配置[%(activity_id)s - " +
                            events.get(event, event) +
                            "]将在今天[%(over_time)s]自动停用,请注意检查配置\r\n") % config
        if content and content != "\r\n":
            send_mail(content.split("\r\n")[0], content)

    except Exception, e:
        logging.info(str(e))
Beispiel #5
0
def shell():
    BaseModel.install()
    db = Connection("172.31.15.206:3306", "admin", "pitayagames", "cUycN6&$")
    msgs = db.query(
        "SELECT * FROM adm_message where status = 1 and intask = 0 limit 1")
    for msg in msgs:
        db.execute("update adm_message set intask = 1 where msgid = %d" %
                   (msg.get("msgid")))
        if msg.get("send_all", 0) == 1:
            if msg.get("self_invoke", 0) == 1:
                yield msg_send(msg.get("msgtype", ""), "ALL_INVOKE")
            else:
                yield fetch_uids(msg.get("msgtype", ""))
        else:
            user_id = msg.get("target", "")
            userids = user_id.split(",")
            for uid in userids:
                yield msg_send(msg.get("msgtype", ""), uid)
        db.execute("update adm_message set status = 2 where msgid = %d" %
                   (msg.get("msgid")))
    db.close()
Beispiel #6
0
        self.db = Connection(host=options.mysql_host,
                             database=options.mysql_database,
                             user=options.mysql_user,
                             password=options.mysql_password)

        self.maybe_create_tables()

    def maybe_create_tables(self):
        try:
            sql = "SELECT * FROM adm_users LIMIT 1"
            conn.get(sql)
        except Exception, e:
            subprocess.check_call([
                'mysql', '--host=' + options.mysql_host.split(":")[0],
                '--port=' + options.mysql_host.split(":")[1], '--database=' +
                options.mysql_database, '--user='******'--password='******'schema.sql'))


if __name__ == "__main__":
    parse_command_line()

    BaseModel.install()
    signal.signal(signal.SIGTERM, sig_handler)
    signal.signal(signal.SIGINT, sig_handler)
    http_server = tornado.httpserver.HTTPServer(Application())
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.current().start()
Beispiel #7
0
def shell():
    BaseModel.install()
    request = XRequest()
    yield watchdog()
    code.interact(local=locals())