From 8b64b396080da4f1d08010ede9b8910275a6adbc Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Mon, 12 Oct 2015 21:18:37 +0200 Subject: [PATCH] Remove regressions from bad rebase --- .../features/steps/content_rating.py | 11 +++++---- .../static/js/distributed/rating/views.js | 16 +++++++------ .../commands/languagepackdownload.py | 23 ++++++++----------- kalitectl.py | 5 +++- 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/kalite/distributed/features/steps/content_rating.py b/kalite/distributed/features/steps/content_rating.py index 44c0236b3c..16e4a62b03 100644 --- a/kalite/distributed/features/steps/content_rating.py +++ b/kalite/distributed/features/steps/content_rating.py @@ -11,6 +11,8 @@ from securesync.models import Device from selenium.webdriver.support.select import Select +from selenium.webdriver.support.ui import WebDriverWait + RATING_CONTAINER_ID = "rating-container" TEXT_CONTAINER_ID = "text-container" @@ -167,16 +169,17 @@ def rate_id(context, id_, val=3): :return: nothing """ - def get_rating_el(driver): + def rate_element(driver): try: container = find_id_with_wait(context, id_) els = container.find_elements_by_class_name(STAR_RATING_OPTION_CLASS) - return [el for el in els if int(el.get_attribute("data-val")) == val].pop() + rating_el = [el for el in els if int(el.get_attribute("data-val")) == val].pop() + rating_el.click() + return True except (NoSuchElementException, StaleElementReferenceException): return False - rating_el = WebDriverWait(context.browser, 10).until(get_rating_el) - rating_el.click() + WebDriverWait(context.browser, 10).until(rate_element) def enter_text_feedback(context, text_feedback): diff --git a/kalite/distributed/static/js/distributed/rating/views.js b/kalite/distributed/static/js/distributed/rating/views.js index 1c4dbe0adf..4021ed25ad 100644 --- a/kalite/distributed/static/js/distributed/rating/views.js +++ b/kalite/distributed/static/js/distributed/rating/views.js @@ -56,18 +56,20 @@ module.exports = BaseView.extend({ Then once the user has filled out the rating completely, call renderAll to allow review/editing. */ this.$el.html(this.template()); + this.$(".rating-delete").hide(); this.star_view_quality = this.add_subview(StarView, {title: gettext("Quality"), el: this.$("#star-container-quality"), model: this.model, rating_attr: "quality", label_values: this.quality_label_values}); var self = this; - + var callback = function() { + self.star_view_difficulty = self.add_subview(StarView, {title: gettext("Difficulty"), el: self.$("#star-container-difficulty"), model: self.model, rating_attr: "difficulty", label_values: this.difficulty_label_values}); + self.$(".rating-delete").show(); + }; // If the "quality" is already set, display "difficulty" immediately. Otherwise wait. - if (parseInt(this.model.get("quality")) === 0) { - this.listenToOnce(this.model, "change:quality", function(){ - self.star_view_difficulty = self.add_subview(StarView, {title: gettext("Difficulty"), el: self.$("#star-container-difficulty"), model: self.model, rating_attr: "difficulty", label_values: this.difficulty_label_values}); - }); + if (!this.model.get("quality") || parseInt(this.model.get("quality")) === 0) { + this.listenToOnce(this.model, "change:quality", callback); } else { - self.star_view_difficulty = self.add_subview(StarView, {title: gettext("Difficulty"), el: self.$("#star-container-difficulty"), model: self.model, rating_attr: "difficulty", label_values: this.difficulty_label_values}); + callback(); } this.listenToOnce(this.model, "change:difficulty", this.renderAll); @@ -165,7 +167,7 @@ var StarView = BaseView.extend({ var val = $(target).attr("data-val"); this.model.set(this.rating_attr, val); this.model.debounced_save(); - }, 500, true), + }, 100, true), mouse_enter_callback: function(ev) { // The target event could be either the .star-rating-option or a child element, so whatever the case get the diff --git a/kalite/updates/management/commands/languagepackdownload.py b/kalite/updates/management/commands/languagepackdownload.py index e2f89eb723..aed4d79ba1 100644 --- a/kalite/updates/management/commands/languagepackdownload.py +++ b/kalite/updates/management/commands/languagepackdownload.py @@ -107,7 +107,7 @@ def handle(self, *args, **options): raise def cb(self, percent): - self.update_stage(stage_percent=percent/100.) + self.update_stage(stage_percent=percent / 100.) def get_language_pack(lang_code, software_version, callback): """Download language pack for specified language""" @@ -133,13 +133,14 @@ def unpack_language(lang_code, zip_filepath=None, zip_fp=None, zip_data=None): logging.info("Unpacking new translations") ensure_dir(get_po_filepath(lang_code=lang_code)) - ## Unpack into temp dir + # # Unpack into temp dir try: z = zipfile.ZipFile(zip_fp or (zip_data and StringIO(zip_data)) or open(zip_filepath, "rb")) except zipfile.BadZipfile as e: - # Need to add more information on the error message. + # Need to add more information on the errror message. # See http://stackoverflow.com/questions/6062576/adding-information-to-a-python-exception raise type(e), type(e)(e.message + _("Language pack corrupted. Please try downloading the language pack again in a few minutes.")) + z.extractall(os.path.join(settings.USER_WRITABLE_LOCALE_DIR, lang_code)) def move_dubbed_video_map(lang_code): lang_pack_location = os.path.join(settings.USER_WRITABLE_LOCALE_DIR, lang_code) @@ -159,17 +160,11 @@ def move_dubbed_video_map(lang_code): logging.error("Error removing dubbed video directory (%s): %s" % (dubbed_video_dir, e)) def move_video_sizes_file(lang_code): - lang_pack_location = os.path.join(settings.USER_WRITABLE_LOCALE_DIR, lang_code) - filename = os.path.basename(REMOTE_VIDEO_SIZE_FILEPATH) - src_path = os.path.join(lang_pack_location, filename) - dest_path = REMOTE_VIDEO_SIZE_FILEPATH - - # replace the old remote_video_size json - if not os.path.exists(src_path): - logging.error("Could not find videos sizes file (%s)" % src_path) - else: - logging.debug('Moving %s to %s' % (src_path, dest_path)) - shutil.move(src_path, dest_path) + """ + This is no longer needed. See: + https://github.com/learningequality/ka-lite/issues/4538#issuecomment-144560505 + """ + return def move_exercises(lang_code): lang_pack_location = os.path.join(settings.USER_WRITABLE_LOCALE_DIR, lang_code) diff --git a/kalitectl.py b/kalitectl.py index 871c054124..98904f9d9e 100644 --- a/kalitectl.py +++ b/kalitectl.py @@ -97,7 +97,7 @@ # Match all patterns of "--option value" and fail if they exist __validate_cmd_options = re.compile(r"--?[^\s]+\s+(?:(?!--|-[\w]))") if __validate_cmd_options.search(" ".join(sys.argv[1:])): - sys.stderr.write("Please only use --option=value or -x123 patterns. No spaces allowed between option and value. The option parser gets confused if you do otherwise.\n\nWill be fixed for next version 0.16") + sys.stderr.write("Please only use --option=value or -x123 patterns. No spaces allowed between option and value. The option parser gets confused if you do otherwise.\n\nWill be fixed for next version 0.15") sys.exit(1) from threading import Thread @@ -569,6 +569,8 @@ def start(debug=False, watch=False, daemonize=True, args=[], skip_job_scheduler= except KeyboardInterrupt: # Handled in cherrypy by waiting for all threads to join pass + except SystemExit: + print("KA Lite caught system exit signal, quitting.") print("FINISHED serving HTTP") @@ -579,6 +581,7 @@ def start(debug=False, watch=False, daemonize=True, args=[], skip_job_scheduler= from fle_utils.chronograph.management.commands import cronserver_blocking cronserver_blocking.shutdown = True cron_thread.join() + print("Job scheduler terminated.") def stop(args=[], sys_exit=True):