kkpyutil 1.33.0__tar.gz → 1.33.3__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.1
2
2
  Name: kkpyutil
3
- Version: 1.33.0
3
+ Version: 1.33.3
4
4
  Summary: Building blocks for sysadmin and DevOps
5
5
  Home-page: https://github.com/kakyoism/kkpyutil/
6
6
  License: MIT
@@ -584,9 +584,25 @@ def get_clipboard_content():
584
584
 
585
585
 
586
586
  def alert(content, title='Debug', action='Close'):
587
+ """
588
+ - on Windows, mshta msgbox does not support custom button text
589
+ - so "action" is ignored on windows
590
+ - multiline message uses \n as line separator
591
+ - mshta (ms html application host) tend to open vbs using text editor; so we use dedicated vbscript cli instead
592
+ """
587
593
  if PLATFORM == 'Windows':
588
- cmd = ['mshta', f'vbscript:Execute("msgbox ""{content}"", 0,""{title}"":{action}")']
589
- os.system(' '.join(cmd))
594
+ # Escape double quotes inside content and title for VBScript
595
+ # vbs uses its own line-end
596
+ content = content.replace('\n', '" & vbCrLf & "').replace('"', '""')
597
+ title = title.replace('"', '""')
598
+ # Construct the VBScript command for the message box
599
+ vbs_content = f'MsgBox "{content}", 0, "{title}"'
600
+ vbs = osp.join(get_platform_tmp_dir(), 'msg.vbs')
601
+ save_text(vbs, vbs_content)
602
+ cmd = ['cscript', '//Nologo', vbs]
603
+ subprocess.run(cmd, shell=True)
604
+ # Clean up the temporary file
605
+ os.remove(vbs)
590
606
  return cmd
591
607
  if PLATFORM == 'Darwin':
592
608
  cmd = ['osascript', '-e', f'display alert "{title}" message "{content}"']
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "kkpyutil"
3
- version = "1.33.0"
3
+ version = "1.33.3"
4
4
  description = "Building blocks for sysadmin and DevOps"
5
5
  authors = ["Beinan Li <li.beinan@gmail.com>"]
6
6
  maintainers = ["Beinan Li <li.beinan@gmail.com>"]
File without changes
File without changes