8000 Merge pull request #1365 from stonebig/master · Nizhal/winpython@3ffc444 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3ffc444

Browse files
authored
Merge pull request winpython#1365 from stonebig/master
remove unused utils.py functions, compat with Python-3.14
2 parents 40540bc + dbc75a8 commit 3ffc444

File tree

4 files changed

+9
-68
lines changed

4 files changed

+9
-68
lines changed

make.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ def make(
16701670
) # Create/re-create the WinPython base directory
16711671
self._print(f"Creating WinPython {my_winpydir} base directory")
16721672
if Path(self.winpydir).is_dir() and remove_existing and not self.simulation:
1673-
shutil.rmtree(self.winpydir, onerror=utils.onerror)
1673+
shutil.rmtree(self.winpydir, onexc=utils.onerror)
16741674
if not Path(self.winpydir).is_dir():
16751675
os.mkdir(self.winpydir)
16761676
if remove_existing and not self.simulation:

winpython/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-----------------------------------------
55
66
Copyright (c) 2012-2013 Pierre Raybaut
7-
Copyright (c) 2014-2023+ The Winpython development team https://github.com/winpython/
7+
Copyright (c) 2014-2024+ The Winpython development team https://github.com/winpython/
88
99
Permission is hereby granted, free of charge, to any person
1010
obtaining a copy of this software and associated documentation
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

31-
__version__ = '9.0.20240623'
31+
__version__ = '9.0.20240629'
3232
__license__ = __doc__
3333
__project_url__ = 'http://winpython.github.io/'

winpython/utils.py

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def onerror(function, path, excinfo):
5454
attempts to add write permission and then retries.
5555
If the error is for another reason, it re-raises the error.
5656
57-
Usage: `shutil.rmtree(path, onerror=onerror)"""
57+
Usage: `shutil.rmtree(path, onexc=onerror)"""
5858
if not os.access(path, os.W_OK):
5959
# Is the error an access error?
6060
os.chmod(path, stat.S_IWUSR)
@@ -63,65 +63,6 @@ def onerror(function, path, excinfo):
6363
raise
6464

6565

66-
67-
# =============================================================================
68-
# Environment variables
69-
# =============================================================================
70-
def get_env(name, current=True):
71-
"""Return HKCU/HKLM environment variable name and value
72-
73-
For example, get_user_env('PATH') may returns:
74-
('Path', u'C:\\Program Files\\Intel\\WiFi\\bin\\')"""
75-
root = (
76-
winreg.HKEY_CURRENT_USER
77-
if current
78-
else winreg.HKEY_LOCAL_MACHINE
79-
)
80-
key = winreg.OpenKey(root, "Environment")
81-
for index in range(0, winreg.QueryInfoKey(key)[1]):
82-
try:
83-
value = winreg.EnumValue(key, index)
84-
if value[0].lower() == name.lower():
85-
# Return both value[0] and value[1] because value[0] could be
86-
# different from name (lowercase/uppercase)
87-
return value[0], value[1]
88-
except:
89-
break
90-
91-
92-
def set_env(name, value, current=True):
93-
"""Set HKCU/HKLM environment variables"""
94-
root = (
95-
winreg.HKEY_CURRENT_USER
96-
if current
97-
else winreg.HKEY_LOCAL_MACHINE
98-
)
99-
key = winreg.OpenKey(root, "Environment")
100-
try:
101-
_x, key_type = winreg.QueryValueEx(key, name)
102-
except WindowsError:
103-
key_type = winreg.REG_EXPAND_SZ
104-
key = winreg.OpenKey(
105-
root, "Environment", 0, winreg.KEY_SET_VALUE
106-
)
107-
winreg.SetValueEx(key, name, 0, key_type, value)
108-
from win32gui import SendMessageTimeout
109-
from win32con import (
110-
HWND_BROADCAST,
111-
WM_SETTINGCHANGE,
112-
SMTO_ABORTIFHUNG,
113-
)
114-
115-
SendMessageTimeout(
116-
HWND_BROADCAST,
117-
WM_SETTINGCHANGE,
118-
0,
119-
"Environment",
120-
SMTO_ABORTIFHUNG,
121-
5000,
122-
)
123-
124-
12566
#==============================================================================
12667
# https://stackoverflow.com/questions/580924/how-to-access-a-files-properties-on-windows
12768
def getFileProperties(fname):
@@ -210,7 +151,7 @@ def remove_winpython_start_menu_folder(current=True):
210151
path = get_winpython_start_menu_folder(current=current)
211152
if Path(path).is_dir():
212153
try:
213-
shutil.rmtree(path, onerror=onerror)
154+
shutil.rmtree(path, onexc=onerror)
214155
except WindowsError:
215156
print(
216157
f"Directory {path} could not be removed",
@@ -222,7 +163,7 @@ def create_winpython_start_menu_folder(current=True):
222163
path = get_winpython_start_menu_folder(current=current)
223164
if Path(path).is_dir():
224165
try:
225-
shutil.rmtree(path, onerror=onerror)
166+
shutil.rmtree(path, onexc=onerror)
226167
except WindowsError:
227168
print(
228169
f"Directory {path} could not be removed",
@@ -629,7 +570,7 @@ def _create_temp_dir():
629570
"""Create a temporary directory and remove it at exit"""
630571
tmpdir = tempfile.mkdtemp(prefix='wppm_')
631572
atexit.register(
632-
lambda path: shutil.rmtree(path, onerror=onerror),
573+
lambda path: shutil.rmtree(path, onexc=onerror),
633574
tmpdir,
634575
)
635576
return tmpdir
@@ -744,7 +685,7 @@ def buildflit_wininst(
744685
)
745686
)
746687
# remove tempo dir 'root' no more needed
747-
shutil.rmtree(root, onerror=onerror)
688+
shutil.rmtree(root, onexc=onerror)
748689
return dst_fname
749690

750691

winpython/wppm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def clean_up(self):
111111
"""Remove directories which couldn't be removed when building"""
112112
for path in self.to_be_removed:
113113
try:
114-
shutil.rmtree(path, onerror=utils.onerror)
114+
shutil.rmtree(path, onexc=utils.onerror)
115115
except WindowsError:
116116
print(
117117
f"Directory {path} could not be removed",

0 commit comments

Comments
 (0)
0