Example #1
0
def main():
    app = QtWidgets.QApplication([])
    app.Config = LocalConfig('config.json')
    app.DataLoader = InvestopediaDotComWebDataLoader()

    window = UIScene('UI')
    window.resize(1258, 680)
    window.setWindowTitle('Market Observer')
    window.show()
    sys.exit(app.exec())
Example #2
0
# coding:utf-8
import random
import time
import os

from PIL import Image

from utils import *
from data_type import *
from spider.base_spider import WebdirverSpider
from config import LocalConfig

cf = LocalConfig()

PIC_DIR = cf.get_value("CAPTCHA", "JWC_PATH")


class JWCSpider(WebdirverSpider):
    """
    教务处爬虫
    """
    def __init__(self):
        super(JWCSpider, self).__init__()
        self._index_url = "http://jxgl.cuit.edu.cn/JXGL/xs/MainMenu.asp"
        self._login_url = "http://210.41.224.117/Login/xLogin/Login.asp"
        self._query_url = "http://jxgl.cuit.edu.cn/JXGL/Pub/InputXh.asp"
        self.code_file = ''
        self.__query_txt = cf.get_value("JWC_SPIDER", "QUERY_TXT") + '%'
        self.total_page = int(cf.get_value("JWC_SPIDER", "QUERY_PAGE"))

    @handle_exception()
Example #3
0
    @staticmethod
    def auth(auth_request):
        return auth_request.token == os.getenv('TOKEN')

    @entry
    def get(self):
        return app.blueprints['mail'].post_send(
            subject='test get entry',
            body='Manual test',
            from_addr='*****@*****.**',
            to_addrs='*****@*****.**')


app = MailMicroService(name="sample-mail-microservice",
                       debug=True,
                       configs=[LocalConfig(), DevConfig()])
app.register_blueprint(Admin(), url_prefix='admin')
app.register_blueprint(Mail('SMTP_SERVER', 'SMTP_LOGIN', 'SMTP_PASSWD'))
XRayContextManager(app, xray_recorder)


@app.schedule('rate(1 hour)',
              name='hourly',
              description="Mail sent every hour for testing.")
@app.schedule('cron(00 15 * * ? *)',
              name="daily",
              description="Mail sent at 3pm for testing.")
def every_sample(name):
    """This doc string will serve as schedule event description if not defined."""
    app.blueprints['mail'].post_send(subject='test event bridge',
                                     body=f"Made by {name}",
Example #4
0
# coding:utf-8
import redis
import pymongo
from pymongo.errors import ConnectionFailure
from utils import log

from config import LocalConfig

cf = LocalConfig()


def catch_mongo_except(func):
    """
    mongo错误处理装饰器
    :param func:
    :return:
    """
    def decorator(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except ConnectionFailure:
            return func(*args, **kwargs)
        except Exception as e:
            print(e)

    return decorator


class MongoDB(object):
    """
    mongodb数据库管理
Example #5
0
        headers = {'Content-Type': 'text/html; charset=utf-8'}
        root = self.config.root
        return template.render(assets_url=assets_url, root=root,
                               **data), 200, headers

    @staticmethod
    def get_file_content(file: Path):
        mt = mimetypes.guess_type(file)
        content = file.read_bytes()
        try:
            return content.decode('utf-8'), 200, {'Content-Type': mt[0]}
        except:
            return content, 200, {'Content-Type': mt[0]}


app = WebsiteMicroService(configs=[LocalConfig(), DevConfig()])
app.register_blueprint(Admin(), url_prefix='admin')

if __name__ == '__main__':
    import sys

    if len(sys.argv) < 2:
        print("Command arg missing")
    elif sys.argv[1] == "run":
        app.execute("run",
                    project_dir='.',
                    module='website',
                    workspace='local',
                    service='app',
                    auto_reload=True)
    elif sys.argv[1] == "deploy":
Example #6
0
def get_config(env="local"):
    if env == "local":
        config = LocalConfig()
    else:
        config = BaseConfig()
    return config
Example #7
0
from config import LocalConfig
config = LocalConfig()