pyappify 0.0.3__tar.gz → 0.0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyappify
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: My awesome Python application
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -13,23 +13,68 @@ pyappify_version = os.environ.get("PYAPPIFY_VERSION")
13
13
  pyappify_executable = os.environ.get("PYAPPIFY_EXECUTABLE")
14
14
 
15
15
  pyappify_upgradeable = os.environ.get("PYAPPIFY_UPGRADEABLE") == '1'
16
+ logger = None
16
17
 
17
18
  try:
18
19
  pid = int(os.environ.get("PYAPPIFY_PID"))
19
20
  except (ValueError, TypeError):
20
21
  pid = None
21
22
 
23
+ import sys
24
+
25
+ try:
26
+ import ctypes
27
+ except ImportError:
28
+ ctypes = None
29
+
30
+
31
+ def minimize_window_by_pid(pid):
32
+ if not ctypes or sys.platform != "win32":
33
+ return False
34
+
35
+ found_hwnd = []
36
+ EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
37
+
38
+ def enum_windows_callback(hwnd, lParam):
39
+ owner_pid = ctypes.c_ulong()
40
+ ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(owner_pid))
41
+ if owner_pid.value == pid and ctypes.windll.user32.IsWindowVisible(hwnd):
42
+ found_hwnd.append(hwnd)
43
+ return False
44
+ return True
45
+
46
+ ctypes.windll.user32.EnumWindows(EnumWindowsProc(enum_windows_callback), 0)
47
+
48
+ if found_hwnd:
49
+ ctypes.windll.user32.ShowWindow(found_hwnd[0], 6)
50
+ return True
51
+
52
+ return False
22
53
 
23
54
  def kill_pyappify():
24
55
  if pid:
56
+ if logger:
57
+ logger.info(f"Attempting to terminate process with PID: {pid}")
25
58
  try:
26
59
  os.kill(pid, signal.SIGTERM)
27
- except ProcessLookupError:
60
+ except Exception as e:
61
+ if logger:
62
+ logger.error(f"Failed to terminate process with PID {pid}: {e}")
28
63
  pass
29
64
 
65
+ def hide_pyappify():
66
+ if pid:
67
+ if logger:
68
+ logger.info(f"Attempting to minimize window for process with PID: {pid}")
69
+ try:
70
+ minimize_window_by_pid(pid)
71
+ except Exception as e:
72
+ if logger:
73
+ logger.error(f"Failed to minimize window for process with PID {pid}: {e}")
74
+ pass
30
75
 
31
- def upgrade(to_version, executable_sha256, executable_zip_urls, logger=None, stop_event=None):
32
- if not pyappify_upgradeable or to_version == pyappify_version:
76
+ def upgrade(to_version, executable_sha256, executable_zip_urls, stop_event=None):
77
+ if not pyappify_upgradeable or (to_version and to_version.lstrip('v') == pyappify_version.lstrip('v')):
33
78
  return
34
79
 
35
80
  def _do_upgrade():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyappify
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: My awesome Python application
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pyappify"
7
- version = "0.0.3"
7
+ version = "0.0.5"
8
8
  description = "My awesome Python application"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
File without changes
File without changes