Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

406 encoding problems in wexpect for non cp1252 or utf 8 #409

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ __pycache__/
/DisplayCAL/lib64/RealDisplaySizeMM.cpython-311-darwin.so
/DisplayCAL/lib64/RealDisplaySizeMM.cpython-312-darwin.so
cacert.pem
*.code-workspace
*.code-workspace
main.py
2 changes: 1 addition & 1 deletion DisplayCAL/profile_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def setup_profile_loader_task(exe, exedir, pydir):
if sys.getwindowsversion() >= (6,):
from DisplayCAL import taskscheduler

taskname = appname + " Profile Loader Launcher"
taskname = f"{appname} Profile Loader Launcher"

try:
ts = taskscheduler.TaskScheduler()
Expand Down
29 changes: 19 additions & 10 deletions DisplayCAL/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def add_lib_excludes(key, excludebits):
config["excludes"][key].extend([f"{name}.lib{exclude}", f"lib{exclude}"])

for exclude in ("32", "64"):
for pycompat in ("38", "39", "310", "311"):
for pycompat in ("38", "39", "310", "311", "312"):
if key == "win32" and (
pycompat == str(sys.version_info[0]) + str(sys.version_info[1])
or exclude == excludebits[0]
Expand Down Expand Up @@ -370,12 +370,24 @@ def create_app_symlinks(dist_dir, scripts):


def get_data(tgt_dir, key, pkgname=None, subkey=None, excludes=None):
"""Return configured data files."""
"""Return configured data files.

Args:
tgt_dir (str): The target directory.
key (str): The config key.
pkgname (Union[None, str]): Name of the package. Default is None.
subkey (Union[None, str]): Name of the subkey. Default is None.
excludes (Union[None, List[str]]): List of files to exclude. Default is None.

Returns:
List[str]: List of strings showing the paths of the data files.
"""
files = config[key]
src_dir = source_dir
if pkgname:
files = files[pkgname]
src_dir = os.path.join(src_dir, pkgname)
# modifying the src_dir is not working with py2app, so disabling it.
# src_dir = os.path.join(src_dir, pkgname)
if subkey:
if subkey in files:
files = files[subkey]
Expand All @@ -386,6 +398,9 @@ def get_data(tgt_dir, key, pkgname=None, subkey=None, excludes=None):
if not [exclude for exclude in excludes or [] if fnmatch(pth, exclude)]:
normalized_path = os.path.normpath(os.path.join(tgt_dir, os.path.dirname(pth)))
safe_path = [relpath(p, src_dir) for p in safe_glob(os.path.join(src_dir, pth))]
if pkgname:
# try looking for the "{src_dir}/{pkgname}/{pth}" too
safe_path += [relpath(p, src_dir) for p in safe_glob(os.path.join(src_dir, pkgname, pth))]
data.append((normalized_path, safe_path))
return data

Expand Down Expand Up @@ -469,12 +484,6 @@ def setup():
if use_setuptools:
if "--use-setuptools" in sys.argv[1:] and not os.path.exists("use-setuptools"):
open("use-setuptools", "w").close()
# try:
# from ez_setup import use_setuptools as ez_use_setuptools
#
# ez_use_setuptools()
# except ImportError:
# pass
try:
import setuptools
from setuptools import setup, Extension, find_packages
Expand Down Expand Up @@ -1109,7 +1118,7 @@ def copy_package_data(self, package, target_dir):
py2app_cls.copy_package_data = copy_package_data
attrs["options"] = {
"py2app": {
"argv_emulation": True,
"argv_emulation": False,
"dist_dir": dist_dir,
"excludes": config["excludes"]["all"] + config["excludes"]["darwin"],
"iconfile": os.path.join(pydir, "theme", "icons", f"{name}.icns"),
Expand Down
24 changes: 11 additions & 13 deletions DisplayCAL/wexpect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ def spawn(self, command, args=None, env=None):
def startChild(self, args, env):
si = GetStartupInfo()
si.dwFlags = STARTF_USESHOWWINDOW
si.wShowWindow = SW_HIDE # SW_SHOW
si.wShowWindow = SW_HIDE
# Determine the directory of wexpect.py or, if we are running 'frozen'
# (eg. py2exe deployment), of the packed executable
dirname = os.path.dirname(
Expand Down Expand Up @@ -2984,20 +2984,18 @@ def log(e, suffix="", logdir=None):
except Exception:
pass
try:
fout = open(logfile, "a")
with open(logfile, "a", encoding="utf-8") as fout:
ts = time.time()
fout.write(
"%s,%s %s\n"
% (
time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts)),
("%3f" % (ts - int(ts)))[2:5],
e,
)
)
except Exception:
pass
else:
ts = time.time()
fout.write(
"%s,%s %s\n"
% (
time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts)),
("%3f" % (ts - int(ts)))[2:5],
e,
)
)
fout.close()


def excepthook(etype, value, tb):
Expand Down
4 changes: 1 addition & 3 deletions DisplayCAL/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7086,8 +7086,6 @@ def exec_cmd(
raise Error(lang.getstr("windows.version.unsupported"))

try:
# print(f"cmdline: {cmdline}")
# print(f"kwargs : {kwargs}")
self.subprocess = wexpect.spawn(
cmdline[0], cmdline[1:], **kwargs
)
Expand Down Expand Up @@ -13520,7 +13518,7 @@ def prepare_dispcal(self, calibrate=True, verify=False, dry_run=False):
luminance = getcfg("calibration.luminance", False)
self.log(f"{appname}: luminance: {luminance}")
if luminance is not None:
args.append("-b{luminance}")
args.append(f"-b{luminance}")
if getcfg("trc"):
args.append("-" + getcfg("trc.type") + str(getcfg("trc")))
args.append("-f%s" % getcfg("calibration.black_output_offset"))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Please install these from your package manager.
brew install glib gtk+3 [email protected]

# Debian installs
apt-get install build-essential dbus libglib2.0-dev pkg-config libgtk-3-dev libxxf86vm-dev
apt-get install build-essential dbus libglib2.0-dev pkg-config libgtk-3-dev libxxf86vm-dev python3-dev

# Fedora core installs
dnf install gcc glibc-devel dbus pkgconf gtk3-devel libXxf86vm-devel python3-devel
Expand Down