def batch_generate():
    """生成当前学期所有学生的 ics 文件,每次更新当前学期数据后使用"""
    from everyclass.server import create_app
    from everyclass.server.db.dao import get_all_students, get_classes_for_student
    from everyclass.server.db.model import Semester

    config = get_config()
    now_semester = Semester(config.DEFAULT_SEMESTER)
    now_semester_str = str(now_semester)

    with create_app(offline=True).app_context():
        students = get_all_students()
        print("Total {} students".format(len(students)))
        for each in students:
            if now_semester_str in each[2]:
                print("Generate .ics for [{}]{}...".format(each[0], each[1]))
                student_classes = get_classes_for_student(
                    each[0], now_semester)
                generate(student_id=each[0],
                         student_name=each[1],
                         student_classes=student_classes,
                         semester_string=now_semester.to_str(simplify=True),
                         semester=now_semester.to_tuple())
        print("Done.")
Exemple #2
0
import gc
from ddtrace import patch_all, tracer

from everyclass.server import create_app

patch_all()
if os.environ.get("DD_AGENT_HOST", None) and os.environ.get(
        "DD_TRACE_AGENT_PORT", None):
    tracer.configure(hostname=os.environ['DD_AGENT_HOST'],
                     port=os.environ['DD_TRACE_AGENT_PORT'])
else:
    print(
        "WARNING: or DD_TRACE_AGENT_PORT not set, ignore configuring datadog tracer."
    )

app = create_app()

# disable gc and freeze
gc.set_threshold(0)  # 700, 10, 10 as default
gc.freeze()


@app.cli.command()
def test():
    """Run the unit tests."""
    import unittest
    tests = unittest.TestLoader().discover('tests')
    unittest.TextTestRunner(verbosity=2).run(tests)


if __name__ == '__main__':
Exemple #3
0
 def setUp(self):
     self.app = create_app()
     self.app_context = self.app.app_context()
     self.app_context.push()
import gc

from everyclass.server import create_app

app = create_app()

# disable gc and freeze
gc.set_threshold(0)  # 700, 10, 10 as default
gc.freeze()


@app.cli.command()
def test():
    """Run the unit tests."""
    import unittest
    tests = unittest.TestLoader().discover('tests')
    unittest.TextTestRunner(verbosity=2).run(tests)


if __name__ == '__main__':
    app = create_app(outside_container=True)
    app.run()