Skip to content

Commit

Permalink
Merge branch 'python-starter-script'
Browse files Browse the repository at this point in the history
  • Loading branch information
geugenm committed Dec 2, 2023
2 parents 0c8acf0 + 7fb1a97 commit 04a02d7
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 10 deletions.
39 changes: 39 additions & 0 deletions scripts/compile_to_exe.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 3 additions & 3 deletions scripts/convert_win1251_to_utf8.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions scripts/replace_html_win1252_with_utf8.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import fileinput
import argparse
import fileinput
import logging
import os


def replace_charset_in_file(file_path):
Expand Down
4 changes: 2 additions & 2 deletions scripts/start_server_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/start_server_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/Lab_5/_biasedPN.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=win-1251">
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META NAME="TRANSLATOR" CONTENT="Andrei A">
<META NAME="GENERATOR" CONTENT="Alla A">
<TITLE>Токи через PN-переход</TITLE>
Expand Down
2 changes: 1 addition & 1 deletion src/Lab_5/_biasedPN2.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=win-1251">
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META NAME="TRANSLATOR" CONTENT="Andrei A">
<META NAME="GENERATOR" CONTENT="Alla A">
<TITLE>Исследование ОПЗ</TITLE>
Expand Down

0 comments on commit 04a02d7

Please sign in to comment.