diff --git a/scripts/compile_to_exe.py b/scripts/compile_to_exe.py new file mode 100644 index 0000000..15d5e74 --- /dev/null +++ b/scripts/compile_to_exe.py @@ -0,0 +1,39 @@ +import argparse +import os +import shutil +import subprocess +import sys + + +def compile_exe(script_file, config): + output_directory = os.path.join(".build", config) + os.makedirs(output_directory, exist_ok=True) + + # PyInstaller flags + pyinstaller_flags = ["--onefile", "--noconsole"] + + if config == "debug": + pyinstaller_flags.remove("--noconsole") + # Add debug flags specific to your project if needed + # Example: pyinstaller_flags.extend(["--debug"]) + + try: + subprocess.run(["pyinstaller", *pyinstaller_flags, script_file]) + except FileNotFoundError: + print("PyInstaller not found. Please install PyInstaller to proceed.") + sys.exit(1) + + # Move the compiled executable to the output directory + script_name = os.path.splitext(os.path.basename(script_file))[0] + exe_name = f"{script_name}.exe" + shutil.move(os.path.join("dist", exe_name), os.path.join(output_directory, exe_name)) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Compile and move executable based on configuration") + parser.add_argument("script_file", help="Python script file to compile") + parser.add_argument("--config", choices=["release", "debug"], default="debug", + help="Configuration type (release or debug, default is debug)") + args = parser.parse_args() + + compile_exe(args.script_file, args.config) diff --git a/scripts/convert_win1251_to_utf8.py b/scripts/convert_win1251_to_utf8.py index e94dc16..d400021 100644 --- a/scripts/convert_win1251_to_utf8.py +++ b/scripts/convert_win1251_to_utf8.py @@ -1,9 +1,9 @@ # Import the necessary modules -import os -import codecs +import argparse import chardet +import codecs import logging -import argparse +import os # Define the source and target encoding source_encoding = "windows-1251" diff --git a/scripts/replace_html_win1252_with_utf8.py b/scripts/replace_html_win1252_with_utf8.py index ecc5550..cc0ca7a 100644 --- a/scripts/replace_html_win1252_with_utf8.py +++ b/scripts/replace_html_win1252_with_utf8.py @@ -1,7 +1,7 @@ -import os -import fileinput import argparse +import fileinput import logging +import os def replace_charset_in_file(file_path): diff --git a/scripts/start_server_cli.py b/scripts/start_server_cli.py index 4b0090e..23d8aab 100644 --- a/scripts/start_server_cli.py +++ b/scripts/start_server_cli.py @@ -18,10 +18,10 @@ python3 script.py """ -import webbrowser +import logging import socket import subprocess -import logging +import webbrowser # Define the custom log level VERBOSE = 15 diff --git a/scripts/start_server_ui.py b/scripts/start_server_ui.py index 6967252..221a687 100644 --- a/scripts/start_server_ui.py +++ b/scripts/start_server_ui.py @@ -121,7 +121,7 @@ def run_server(directory, port, log_file): if __name__ == "__main__": parser = argparse.ArgumentParser(description="Java WebAssembly Translation Server with UI") - parser.add_argument("-dir", "--directory", type=str, default="", help="Directory to open") + parser.add_argument("-dir", "--directory", type=str, default="./", help="Directory to open") parser.add_argument("-p", "--port", type=int, default=8080, help="Port to run the server on") parser.add_argument("-log", "--logfile", type=str, default="log.txt", help="Log file name") args = parser.parse_args() diff --git a/src/Lab_5/_biasedPN.html b/src/Lab_5/_biasedPN.html index ba7e9e8..8e4cbdd 100644 --- a/src/Lab_5/_biasedPN.html +++ b/src/Lab_5/_biasedPN.html @@ -1,6 +1,6 @@ - + Токи через PN-переход diff --git a/src/Lab_5/_biasedPN2.html b/src/Lab_5/_biasedPN2.html index 1a76019..55c9516 100644 --- a/src/Lab_5/_biasedPN2.html +++ b/src/Lab_5/_biasedPN2.html @@ -1,6 +1,6 @@ - + Исследование ОПЗ