我可以在程序执行期间在 python 32 位和 python 64 位之间切换吗?



要求:

从添加删除程序卸载应用程序。这方面的代码需要 python 64 位。我想从中执行卸载操作的 python 脚本需要 python 32 位,因为有些 DLL 是使用 32 位 python 编译的。

无论如何,我能做到这一点吗?是否有可能在python的两个架构之间切换?我想知道我可以将卸载脚本保留为单独的 python 模块,并以某种方式强制它使用 python 64 位运行。可能?

Python专家请帮忙。

蟒蛇版本:2.7.12

结构:

My python application (require 32 bit python)
Uninstall() (require 64 bit python)
My script continues (require 32 bit python)

卸载代码((

import pywinauto
pywinauto.Application().Start(r'explorer.exe')
explorer = pywinauto.Application().Connect(path='explorer.exe')
# Go to "Control Panel -> Programs and Features"
NewWindow = explorer.Window_(top_level_only=True, active_only=True,     class_name='CabinetWClass')
try:
print "hello"
NewWindow.AddressBandRoot.ClickInput()
NewWindow.TypeKeys(r'Control PanelProgramsPrograms and Features{ENTER}', with_spaces=True, set_foreground=False)
ProgramsAndFeatures = explorer.Window_(top_level_only=True, active_only=True, title='Programs and Features', class_name='CabinetWClass')
# Wait while list of programs is loading
explorer.WaitCPUUsageLower(threshold=5)
item_7z = ProgramsAndFeatures.FolderView.GetItem('7-Zip 9.20 (x64 edition)')
item_7z.EnsureVisible()
item_7z.ClickInput(button='right', where='icon')
explorer.PopupMenu.MenuItem('Uninstall').Click()
Confirmation = explorer.Window_(title='Programs and Features', class_name='#32770', active_only=True)
if Confirmation.Exists():
Confirmation.Yes.ClickInput()
Confirmation.WaitNot('visible')
WindowsInstaller = explorer.Window_(title='Windows Installer', class_name='#32770', active_only=True)
if WindowsInstaller.Exists():
WindowsInstaller.WaitNot('visible', timeout=20)
SevenZipInstaller = explorer.Window_(title='7-Zip 9.20 (x64 edition)', class_name='#32770', active_only=True)
if SevenZipInstaller.Exists():
SevenZipInstaller.WaitNot('visible', timeout=20)
if '7-Zip 9.20 (x64 edition)' not in     ProgramsAndFeatures.FolderView.Texts():
print "OK"
finally:
NewWindow.Close()

您是否考虑过使用 2 种不同的流程?

  1. 为您的应用程序启动 32 位 python 进程。
  2. 您的应用程序请求执行单独的 64 位 python 进程来运行您的Uninstall函数。
  3. 应用程序会等到 64 位 python 进程终止。
  4. 应用程序将继续运行。

最新更新