From 868f7e21897ee78335f6f3475c72349efd643ecf Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 13 Dec 2020 11:40:15 +0100 Subject: [PATCH] Delete KaptsjaHTMLpages.py wrong dir uploaded --- KaptsjaHTMLpages.py | 324 -------------------------------------------- 1 file changed, 324 deletions(-) delete mode 100644 KaptsjaHTMLpages.py diff --git a/KaptsjaHTMLpages.py b/KaptsjaHTMLpages.py deleted file mode 100644 index 2fd2a5c..0000000 --- a/KaptsjaHTMLpages.py +++ /dev/null @@ -1,324 +0,0 @@ -################################################################################################### -# KaptsjaHTMLpages creates the KaptsjaHome page, KaptsjaSuccess page and KaptsjaFilure page -# Kaptsja is the Dutch phonetic pronunciation of the English word Captcha. -# -# WARNING: BEFORE CHANGING ANYTHING IN THIS FILE MAKE A BACKUP SO YOU CAN RESTORE ! -# Read the comments in this file as they contain valuable information to understand the effects -################################################################################################### - -import sys -# sys.path.append("/path/to/your/package_or_module") -sys.path.append(r"./scripts") -import os -import time -import logging -# import the configuration -from KaptsjaConfiguration import * -############################################################################################################################################################ -# SETTINGS (start) See /Kaptsja/scripts/KaptsjaConfiguration.py -############################################################################################################################################################ -# When needed change level level=logging.INFO or level=logging.DEBUG) -# get the directory in which the script was started. -serve_path = os.getcwd() -try: - logging.basicConfig(filename=log_file, level=logging.ERROR) -except PermissionError as e: - print("Check permissions for Kaptsja and its subdirectories.\n\n%s\n\n" % e) - sys.exit() -except Exception as e: - print("Start this program from Kaptsja home directory. It was started in %s.\n\n%s\n\n" %(serve_path, e) ) - sys.exit() -############################################################################################################################################################ -# SETTINGS (End) -############################################################################################################################################################ - -########################################## -# START of validation of the configuration -########################################## - -if 360 <= int(input_picture_rescale_width) <= 598: - modal_content_width = input_picture_rescale_width + 2 -if int(input_picture_rescale_width) == 0: # - modal_content_width = 600 # this is the default value -text = "Home" -if not "home_page_tab1" in globals(): - home_page_tab1 = text -if home_page_tab1 == "": - home_page_tab1 = text -if home_page_tab1 is None: - home_page_tab1 = "" - -text = "1. Kaptsja Page" -if not "home_page_tab2" in globals(): - home_page_tab2 = text -if home_page_tab2 == "": - home_page_tab2 = text -if home_page_tab2 is None: - home_page_tab2 = "" - -text = "2. Kaptsja Modal Page" -if not "home_page_tab3" in globals(): - home_page_tab3 = text -if home_page_tab3 == "": - home_page_tab3 = text -if home_page_tab3 is None: - home_page_tab3 = "" - -text = "3. Kaptsja inside page element <div> ... </div>" -if not "home_page_tab4" in globals(): - home_page_tab4 = text -if home_page_tab4 == "": - home_page_tab4 = text -if home_page_tab4 is None: - home_page_tab4 = "" - -text = "To select the activated Kaptsja model click on tab " -if not "home_page_click_tab_text" in globals(): - home_page_click_tab_text = text -if home_page_click_tab_text == "": - home_page_click_tab_text = text -if home_page_click_tab_text is None: - home_page_click_tab_text = "" - -text = "Only one model can be active at a time. To activate another model, " -if not "home_page_one_model_active_text" in globals(): - home_page_one_model_active_text = text -if home_page_one_model_active_text == "": - home_page_one_model_active_text = text -if home_page_one_model_active_text is None: - home_page_one_model_active_text = "" - -text = "change setting 'active_captcha_model' in configuration file KaptsjaConfiguration.py." -if not "home_page_change_setting_text" in globals(): - home_page_change_setting_text = text -if home_page_change_setting_text == "": - home_page_change_setting_text = text -if home_page_change_setting_text is None: - home_page_change_setting_text = "" - -########################################## -# END of validation of the configuration -########################################## - -def create_KaptsjaHome_html_file(): - # All braces for css and javascript itself MUST be double notation like {{ // some css or javascript code }} to escape the first. - # Only ony brace will be generated in the output. All formatting keys like .format(key= ) MUST have a single brace {key} notation. - captcha_page_url_active = "#" - modal_page_url_active = "#" - div_page_url_active = "#" - if active_captcha_model == 1: - captcha_page_url_active = captcha_page_url - elif active_captcha_model == 2: - modal_page_url_active = modal_page_url - elif active_captcha_model == 3: - div_page_url_active = div_page_url - - html_1 = ''' - - - - - - - - -
- -
-

{home_page_click_tab_text} {active_captcha_model}.

-
{home_page_one_model_active_text}
-
change setting 'active_captcha_model' in configuration file KaptsjaConfiguration.py.
- - - - - - '''.format(captcha_page_url=captcha_page_url_active, \ - modal_page_url=modal_page_url_active, \ - div_page_url=div_page_url_active, \ - active_captcha_model=active_captcha_model, \ - home_page_click_tab_text=home_page_click_tab_text, \ - home_page_one_model_active_text=home_page_one_model_active_text, \ - home_page_change_setting_text=home_page_change_setting_text, \ - home_page_tab1=home_page_tab1, \ - home_page_tab2=home_page_tab2, \ - home_page_tab3=home_page_tab3, \ - home_page_tab4=home_page_tab4 - ) - - try: - htmlfile = open(gen_home_page_file,"w", encoding="utf-8") - htmlfile.write(html_1) - htmlfile.close() - logging.info(r"Generation Kaptsja Home HTML page file success: %s" % gen_home_page_file) - return True - except: - logging.error(r"Generation Kaptsja Home HTML page file failure: %s" % gen_home_page_file) - return False - -def create_KaptsjaSuccess_html_file(): - # All braces for css and javascript itself MUST be double notation like {{ // some css or javascript code }} to escape the first. - # Only ony brace will be generated in the output. All formatting keys like .format(key= ) MUST have a single brace {key} notation. - html=''' - - - - - - -
-
- -
-

Success

-

You solved the CaptCha successfully;
You may now continue. Click here.

-
- - - '''.format(success_cont_url=success_cont_url) - - try: - htmlfile = open(gen_success_page_file,"w", encoding="utf-8") - htmlfile.write(html) - htmlfile.close() - logging.info(r"Generation Kaptsja Success HTML page file success: %s" % gen_success_page_file) - return True - except: - logging.error(r"Generation Kaptsja Success HTML page file failure: %s" % gen_success_page_file) - return False - -def create_KaptsjaFailure_html_file(): - # All braces for css and javascript itself MUST be double notation like {{ // some css or javascript code }} to escape the first. - # Only ony brace will be generated in the output. All formatting keys like .format(key= ) MUST have a single brace {key} notation. - if max_captcha_sets > 0: - time_message = ";" - else: - time_message = " within {max_time_to_solve} seconds;".format(max_time_to_solve=max_time_to_solve) - html=''' - - - - - - -
-
- X -
-

Failure

-

You did not solve the CaptCha successfully{time_message}
You may now retry. Click here.

-
- - - '''.format(failure_cont_url=failure_cont_url, time_message=time_message) - - try: - htmlfile = open(gen_failure_page_file,"w", encoding="utf-8") - htmlfile.write(html) - htmlfile.close() - logging.info(r"Generation Kaptsja Failure HTML page file success: %s" % gen_failure_page_file) - return True - except: - logging.error(r"Generation Kaptsja Failure HTML page file failure: %s" % gen_failure_page_file) - return False - -if __name__ == '__main__': - retcode = create_KaptsjaHome_html_file() - if retcode == True: - print(r"Generation of Kaptsja Home HTML page file succeeded.") - else: - print(r"Generation of Kaptsja Home HTML page file failed.") - - retcode = create_KaptsjaSuccess_html_file() - if retcode == True: - print(r"Generation of Kaptsja Success HTML page file succeeded.") - else: - print(r"Generation of Kaptsja Success HTML page file failed.") - - retcode = create_KaptsjaFailure_html_file() - if retcode == True: - print(r"Generation of Kaptsja Failure HTML page file succeeded.") - else: - print(r"Generation of Kaptsja Failure HTML page file failed.")