本文整理汇总了Python中mnemosyne.libmnemosyne.Mnemosyne.review_controller方法的典型用法代码示例。如果您正苦于以下问题:Python Mnemosyne.review_controller方法的具体用法?Python Mnemosyne.review_controller怎么用?Python Mnemosyne.review_controller使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mnemosyne.libmnemosyne.Mnemosyne
的用法示例。
在下文中一共展示了Mnemosyne.review_controller方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MyClient
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import review_controller [as 别名]
class MyClient(Client):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
def __init__(self):
os.system("rm -fr dot_benchmark")
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(("test_sync", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.initialise(os.path.abspath(os.path.join(os.getcwdu(),
"dot_benchmark")))
self.mnemosyne.review_controller().reset()
Client.__init__(self, "client_machine_id", self.mnemosyne.database(),
self.mnemosyne.main_widget())
def do_sync(self):
self.sync("127.0.0.1", 8190, "user", "pass")
self.mnemosyne.database().save()
示例2: startup
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import review_controller [as 别名]
def startup():
global mnemosyne
# Note that this also includes building the queue and getting the first card.
mnemosyne = Mnemosyne(resource_limited=True)
mnemosyne.components = [
("mnemosyne.libmnemosyne.translator",
"NoTranslation"),
("mnemosyne.libmnemosyne.ui_components.main_widget",
"MainWidget"),
("mnemosyne.libmnemosyne.ui_components.review_widget",
"ReviewWidget"),
("mnemosyne.libmnemosyne.databases.SQLite",
"SQLite"),
("mnemosyne.libmnemosyne.configuration",
"Configuration"),
("mnemosyne.libmnemosyne.loggers.sql_logger",
"SqlLogger"),
("mnemosyne.libmnemosyne.schedulers.SM2_mnemosyne",
"SM2Mnemosyne"),
("mnemosyne.libmnemosyne.stopwatch",
"Stopwatch"),
("mnemosyne.libmnemosyne.card_types.front_to_back",
"FrontToBack"),
("mnemosyne.libmnemosyne.card_types.both_ways",
"BothWays"),
("mnemosyne.libmnemosyne.card_types.three_sided",
"ThreeSided"),
("mnemosyne.libmnemosyne.renderers.html_css_old",
"HtmlCssOld"),
("mnemosyne.libmnemosyne.filters.escape_to_html",
"EscapeToHtml"),
("mnemosyne.libmnemosyne.filters.expand_paths",
"ExpandPaths"),
("mnemosyne.libmnemosyne.filters.latex",
"Latex"),
("mnemosyne.libmnemosyne.controllers.default_controller",
"DefaultController"),
("mnemosyne.libmnemosyne.review_controllers.SM2_controller",
"SM2Controller"),
("mnemosyne.libmnemosyne.card_types.map",
"MapPlugin"),
("mnemosyne.libmnemosyne.card_types.cloze",
"ClozePlugin"),
("mnemosyne.libmnemosyne.plugins.cramming_plugin",
"CrammingPlugin"),
("mnemosyne.libmnemosyne.file_formats.mnemosyne1_mem",
"Mnemosyne1Mem"),
("mnemosyne.libmnemosyne.ui_components.dialogs",
"ProgressDialog") ]
mnemosyne.initialise(basedir=os.path.abspath("dot_benchmark"))
#mnemosyne.initialise(basedir="\SDMMC\.mnemosyne")
mnemosyne.review_controller().reset()
示例3: test_setup
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import review_controller [as 别名]
def test_setup():
shutil.rmtree("dot_test", ignore_errors=True)
global mnemosyne
mnemosyne = Mnemosyne(upload_science_logs=False, interested_in_old_reps=True)
mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translators.gettext_translator",
"GetTextTranslator"))
mnemosyne.components.append(\
("test_add_cards", "Widget"))
mnemosyne.components.append(\
("mnemosyne_test", "TestReviewWidget"))
mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "EditCardDialog"))
mnemosyne.initialise(os.path.abspath("dot_test"), automatic_upgrades=False)
mnemosyne.review_controller().reset()
示例4: MyServer
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import review_controller [as 别名]
class MyServer(Server):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
def __init__(self):
shutil.rmtree(os.path.abspath("dot_sync_server"), ignore_errors=True)
self.mnemosyne = Mnemosyne(upload_science_logs=False, interested_in_old_reps=True)
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(("test_sync", "Widget"))
self.mnemosyne.components.append(("mnemosyne_test", "TestReviewWidget"))
self.mnemosyne.initialise(os.path.abspath("dot_sync_server"), automatic_upgrades=False)
self.mnemosyne.config().change_user_id("user_id")
self.mnemosyne.review_controller().reset()
self.supports_binary_transfer = lambda x : False
# Add 20 cards to database.
card_type = self.mnemosyne.card_type_with_id("1")
for i in range (20):
fact_data = {"f": "question %d" % (i,),
"b": "answer"}
self.mnemosyne.controller().create_new_cards(fact_data, card_type,
grade=-1, tag_names=["default"])[0]
self.mnemosyne.database().save()
self.mnemosyne.database().release_connection()
def authorise(self, login, password):
return login == "user" and password == "pass"
def load_database(self, database_name):
self.mnemosyne.database().load(database_name)
return self.mnemosyne.database()
def unload_database(self, database):
self.mnemosyne.database().release_connection()
# Dirty way to make sure we restart the server and create a new database
# (as opposed to keep sending old history back and forth)'
self.wsgi_server.stop()
def run(self):
Server.__init__(self, "client_machine_id", 8186,
self.mnemosyne.main_widget())
self.serve_until_stopped()
示例5: MyServer
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import review_controller [as 别名]
class MyServer(Server):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
stop_after_sync = True
def __init__(self):
os.system("rm -rf sync_from_here")
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(("test_sync", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.initialise(os.path.abspath("sync_from_here"))
self.mnemosyne.config().change_user_id("user_id")
self.mnemosyne.review_controller().reset()
# Add 20 cards to database.
card_type = self.mnemosyne.card_type_by_id("1")
for i in range (20):
fact_data = {"q": "question %d" % (i,),
"a": "answer"}
self.mnemosyne.controller().create_new_cards(fact_data, card_type,
grade=-1, tag_names=["default"])[0]
self.mnemosyne.database().save()
def authorise(self, login, password):
return login == "user" and password == "pass"
def open_database(self, database_name):
return self.mnemosyne.database()
def run(self):
Server.__init__(self, "client_machine_id", "192.168.2.54", 8186,
self.mnemosyne.main_widget())
# Because we stop_after_sync is True, serve_forever will actually stop
# after one sync.
self.serve_forever()
self.mnemosyne.finalise()
示例6: MyServer
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import review_controller [as 别名]
class MyServer(Server, Thread):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
stop_after_sync = True
def __init__(self):
Thread.__init__(self)
self.mnemosyne = Mnemosyne()
self.mnemosyne.components.insert(0, ("mnemosyne.libmnemosyne.translator",
"GetTextTranslator"))
self.mnemosyne.components.append(("test_sync", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
def authorise(self, login, password):
return login == "user" and password == "pass"
def open_database(self, database_name):
return self.mnemosyne.database()
def run(self):
# We only open the database connection inside the thread to prevent
# access problems, as a single connection can only be used inside a
# single thread.
self.mnemosyne.initialise(os.path.abspath("sync_from_here"))
self.mnemosyne.review_controller().reset()
Server.__init__(self, "server_machine_id", "127.0.0.1", 8190,
self.mnemosyne.main_widget())
# Because we stop_after_sync is True, serve_forever will actually stop
# after one sync.
self.serve_forever()
self.mnemosyne.finalise()
示例7: WebServer
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import review_controller [as 别名]
class WebServer(Component):
def __init__(self, component_manager, port, data_dir, config_dir,
filename, is_server_local=False):
Component.__init__(self, component_manager)
self.port = port
self.data_dir = data_dir
self.config_dir = config_dir
self.filename = filename
self.is_server_local = is_server_local
# When restarting the server, make sure we discard info from the
# browser resending the form from the previous session.
self.is_just_started = True
self.is_mnemosyne_loaded = False
self.is_shutting_down = False
self.wsgi_server = wsgiserver.CherryPyWSGIServer(\
("0.0.0.0", port), self.wsgi_app, server_name="localhost",
numthreads=1, timeout=5)
# We need to set the timeout relatively low, otherwise it will take
# too long for the server to process a 'stop' request.
def serve_until_stopped(self):
try:
self.wsgi_server.start() # Sets self.wsgi_server.ready
except KeyboardInterrupt:
self.wsgi_server.stop()
self.unload_mnemosyne()
def stop(self):
self.wsgi_server.stop()
self.unload_mnemosyne()
def load_mnemosyne(self):
self.mnemosyne = Mnemosyne(upload_science_logs=True,
interested_in_old_reps=True)
self.mnemosyne.components.insert(0, (
("mnemosyne.libmnemosyne.translators.gettext_translator",
"GetTextTranslator")))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.main_widget",
"MainWidget"))
self.mnemosyne.components.append(\
("mnemosyne.web_server.review_wdgt",
"ReviewWdgt"))
self.mnemosyne.components.append(\
("mnemosyne.web_server.web_server_render_chain",
"WebServerRenderChain"))
self.mnemosyne.initialise(self.data_dir, config_dir=self.config_dir,
filename=self.filename, automatic_upgrades=False)
self.mnemosyne.review_controller().set_render_chain("web_server")
self.save_after_n_reps = self.mnemosyne.config()["save_after_n_reps"]
self.mnemosyne.config()["save_after_n_reps"] = 1
self.mnemosyne.start_review()
self.mnemosyne.review_widget().set_is_server_local(\
self.is_server_local)
self.is_mnemosyne_loaded = True
self.release_database_after_timeout = \
ReleaseDatabaseAfterTimeout(self.port)
self.release_database_after_timeout.start()
def unload_mnemosyne(self):
if not self.is_mnemosyne_loaded:
return
self.mnemosyne.config()["save_after_n_reps"] = self.save_after_n_reps
self.mnemosyne.finalise()
self.is_mnemosyne_loaded = False
def wsgi_app(self, environ, start_response):
filename = environ["PATH_INFO"].decode("utf-8")
if filename == "/status":
response_headers = [("Content-type", "text/html")]
start_response("200 OK", response_headers)
return ["200 OK"]
# Sometimes, even after the user has clicked 'exit' in the page,
# a browser sends a request for e.g. an audio file.
if self.is_shutting_down and filename != "/release_database":
response_headers = [("Content-type", "text/html")]
start_response("503 Service Unavailable", response_headers)
return ["Server stopped"]
# Load database if needed.
if not self.is_mnemosyne_loaded and filename != "/release_database":
self.load_mnemosyne()
self.release_database_after_timeout.ping()
# All our request return to the root page, so if the path is '/',
# return the html of the review widget.
if filename == "/":
# Process clicked buttons in the form.
form = cgi.FieldStorage(fp=environ["wsgi.input"], environ=environ)
if "show_answer" in form and not self.is_just_started:
self.mnemosyne.review_widget().show_answer()
page = self.mnemosyne.review_widget().to_html()
elif "grade" in form and not self.is_just_started:
grade = int(form["grade"].value)
self.mnemosyne.review_widget().grade_answer(grade)
page = self.mnemosyne.review_widget().to_html()
elif "star" in form:
self.mnemosyne.controller().star_current_card()
page = self.mnemosyne.review_widget().to_html()
elif "exit" in form:
self.unload_mnemosyne()
#.........这里部分代码省略.........
示例8: MyClient
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import review_controller [as 别名]
class MyClient(Client):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
def __init__(self):
shutil.rmtree(os.path.abspath("dot_sync_client"), ignore_errors=True)
self.mnemosyne = Mnemosyne(upload_science_logs=False, interested_in_old_reps=True)
self.mnemosyne.components = [
("mnemosyne.libmnemosyne.translator",
"NoTranslation"),
("mnemosyne.libmnemosyne.databases.SQLite",
"SQLite"),
("mnemosyne.libmnemosyne.configuration",
"Configuration"),
("mnemosyne.libmnemosyne.loggers.database_logger",
"DatabaseLogger"),
("mnemosyne.libmnemosyne.schedulers.SM2_mnemosyne",
"SM2Mnemosyne"),
("mnemosyne.libmnemosyne.stopwatch",
"Stopwatch"),
("mnemosyne.libmnemosyne.card_types.front_to_back",
"FrontToBack"),
("mnemosyne.libmnemosyne.card_types.both_ways",
"BothWays"),
("mnemosyne.libmnemosyne.card_types.vocabulary",
"Vocabulary"),
("mnemosyne.libmnemosyne.renderers.html_css",
"HtmlCss"),
("mnemosyne.libmnemosyne.filters.escape_to_html",
"EscapeToHtml"),
("mnemosyne.libmnemosyne.filters.expand_paths",
"ExpandPaths"),
("mnemosyne.libmnemosyne.filters.latex",
"Latex"),
("mnemosyne.libmnemosyne.render_chains.default_render_chain",
"DefaultRenderChain"),
("mnemosyne.libmnemosyne.render_chains.plain_text_chain",
"PlainTextChain"),
("mnemosyne.libmnemosyne.controllers.default_controller",
"DefaultController"),
("mnemosyne.libmnemosyne.review_controllers.SM2_controller",
"SM2Controller"),
("mnemosyne.libmnemosyne.card_types.map",
"MapPlugin"),
("mnemosyne.libmnemosyne.card_types.cloze",
"ClozePlugin"),
("mnemosyne.libmnemosyne.criteria.default_criterion",
"DefaultCriterion"),
("mnemosyne.libmnemosyne.databases.SQLite_criterion_applier",
"DefaultCriterionApplier"),
("mnemosyne.libmnemosyne.plugins.cramming_plugin",
"CrammingPlugin") ]
self.mnemosyne.components.append(("benchmark_sync_client", "Widget"))
self.mnemosyne.components.append(("benchmark_sync_client", "MyReviewWidget"))
self.mnemosyne.initialise(os.path.abspath(os.path.join(os.getcwdu(),
"dot_sync_client")), automatic_upgrades=False)
self.mnemosyne.config().change_user_id("user_id")
self.check_for_edited_local_media_files = False
self.do_backup = False
self.mnemosyne.review_controller().reset()
# Do 200 reviews.
card_type = self.mnemosyne.card_type_with_id("1")
fact_data = {"f": "question",
"b": "answer"}
card = self.mnemosyne.controller().create_new_cards(fact_data, card_type,
grade=-1, tag_names=["default"])[0]
self.mnemosyne.database().save()
self.mnemosyne.review_controller().show_new_question()
for i in range(200):
self.mnemosyne.review_controller().show_answer()
self.mnemosyne.review_controller().grade_answer(0)
Client.__init__(self, "client_machine_id", self.mnemosyne.database(),
self.mnemosyne.main_widget())
def do_sync(self):
#self.BUFFER_SIZE = 10*8192
#self.behind_proxy = True
self.sync("localhost", 8186, "user", "pass")
self.mnemosyne.database().save()
示例9: MyClient
# 需要导入模块: from mnemosyne.libmnemosyne import Mnemosyne [as 别名]
# 或者: from mnemosyne.libmnemosyne.Mnemosyne import review_controller [as 别名]
class MyClient(Client):
program_name = "Mnemosyne"
program_version = "test"
capabilities = "TODO"
def __init__(self):
self.mnemosyne = Mnemosyne()
self.mnemosyne.components = [
("mnemosyne.libmnemosyne.translator",
"NoTranslation"),
("mnemosyne.libmnemosyne.databases.SQLite",
"SQLite"),
("mnemosyne.libmnemosyne.configuration",
"Configuration"),
("mnemosyne.libmnemosyne.loggers.database_logger",
"DatabaseLogger"),
("mnemosyne.libmnemosyne.schedulers.SM2_mnemosyne",
"SM2Mnemosyne"),
("mnemosyne.libmnemosyne.stopwatch",
"Stopwatch"),
("mnemosyne.libmnemosyne.card_types.front_to_back",
"FrontToBack"),
("mnemosyne.libmnemosyne.card_types.both_ways",
"BothWays"),
("mnemosyne.libmnemosyne.card_types.three_sided",
"ThreeSided"),
("mnemosyne.libmnemosyne.renderers.html_css_old",
"HtmlCssOld"),
("mnemosyne.libmnemosyne.filters.escape_to_html",
"EscapeToHtml"),
("mnemosyne.libmnemosyne.filters.expand_paths",
"ExpandPaths"),
("mnemosyne.libmnemosyne.filters.latex",
"Latex"),
("mnemosyne.libmnemosyne.controllers.default_controller",
"DefaultController"),
("mnemosyne.libmnemosyne.review_controllers.SM2_controller",
"SM2Controller"),
("mnemosyne.libmnemosyne.card_types.map",
"MapPlugin"),
("mnemosyne.libmnemosyne.card_types.cloze",
"ClozePlugin"),
("mnemosyne.libmnemosyne.activity_criteria.default_criterion",
"DefaultCriterion"),
("mnemosyne.libmnemosyne.databases.SQLite_criterion_applier",
"DefaultCriterionApplier"),
("mnemosyne.libmnemosyne.plugins.cramming_plugin",
"CrammingPlugin") ]
self.mnemosyne.components.append(("benchmark_sync_client", "Widget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.review_widget", "ReviewWidget"))
self.mnemosyne.components.append(\
("mnemosyne.libmnemosyne.ui_components.dialogs", "ProgressDialog"))
self.mnemosyne.initialise(os.path.abspath(os.path.join(os.getcwdu(),
"dot_benchmark")))
self.mnemosyne.config().change_user_id("user_id")
self.mnemosyne.review_controller().reset()
# Do 200 reviews.
card_type = self.mnemosyne.card_type_by_id("1")
fact_data = {"q": "question",
"a": "answer"}
card = self.mnemosyne.controller().create_new_cards(fact_data, card_type,
grade=-1, tag_names=["default"])[0]
self.mnemosyne.database().save()
self.mnemosyne.review_controller().new_question()
for i in range(200):
self.mnemosyne.review_controller().show_answer()
self.mnemosyne.review_controller().grade_answer(0)
Client.__init__(self, "client_machine_id", self.mnemosyne.database(),
self.mnemosyne.main_widget())
def do_sync(self):
self.sync("192.168.2.54", 8186, "user", "pass")
self.mnemosyne.database().save()