コード例 #1
0
ファイル: main.py プロジェクト: flyer103/douban_fang
"""
"""

import time
import json

import requests
from lxml import etree
from pymongo import MongoClient

from mylogger import Logger

log_main = Logger.get_logger(service=__name__)


class FangCrawler:

    URL_TPL = "https://www.douban.com/group/shanghaizufang/discussion?start="

    def __init__(self):
        self.configs = self._load_conf()

        self.headers = self.configs["http"]["headers"]

        mgo_config = self.configs["mongo"]
        if mgo_config.get("rs"):
            self.mgo = MongoClient(
                mgo_config["rs"]["url"],
                replicaSet=mgo_config["rs"]["name"],
                readPreference=mgo_config["rs"]["read_preference"],
            )
コード例 #2
0
ファイル: auto_deploy.py プロジェクト: flyer103/autodeploy
"""github 自动部署.
"""

import os
import sys
import subprocess

from flask import Flask, request

sys.path.append(os.path.join(os.path.abspath(__file__).rsplit('/', 1)[0], 'logger'))

from configs import get_configs
from mylogger import Logger

log_main = Logger.get_logger(__file__)


app = Flask(__name__)

configs_sys = get_configs()         # 系统配置


# Route
@app.route('/deploy/<project>', methods=['POST'])
def deploy(project=None):
    if project.upper() not in configs_sys['GIT']:
        log_main.critical('No such project: {0}'.format(project))
        sys.exit(-1)

    html_url = request.json['repository']['html_url']