最新消息:

nsPython是NSIS与Python脚本进行交互编程的插件

nsis 永恒心锁 2862浏览 0评论
/*
nsPython是NSIS与Python脚本进行交互编程的插件
nsPython支持命令eval,exec和execFile来与Python脚本进行交互.使用的时候要注意平台,如64位系统之类的差异.
*/
!AddPluginDir "../Plugins"
Name "Test-nspython"
OutFile "Test-nspython.exe"
ShowInstDetails show
ComponentText "select tests"
ReserveFile "python27.dll"
ReserveFile "test.py"
;Page components
;Page instfiles
Function .onInit
 ;Extract Install Options files
 ;$PLUGINSDIR will automatically be removed when the installer closes
 InitPluginsDir
 File "/oname=$PLUGINSDIRpython27.dll" "python27.dll"
 File "/oname=$PLUGINSDIRtest.py" "test.py"
FunctionEnd
Function .onGUIEnd
 nsPython::Finalize
FunctionEnd
Section "Test eval"
 nsPython::eval "3+2"
 Pop $0
 DetailPrint "Result: $0"
 nsPython::eval "make an error"
 Pop $0
 DetailPrint "Result: $0"
SectionEnd
Section "Test exec logprint"
 nsPython::exec "import nsis;a=3+2;nsis.log('embedded messy: a=%r' % a)"
 Pop $0
 DetailPrint "Result: $0"
 nsPython::exec "make an error"
 Pop $0
 DetailPrint "Result: $0"
SectionEnd
Section "Test exec msgbox"
 nsPython::exec "import nsis;a=3+2;nsis.messagebox('embedded messy: a=%r' % a);"
 Pop $0
 DetailPrint "Result: $0"
 nsPython::exec "import nsis;nsis.messagebox('with custom title', 'this was me');"
 Pop $0
 DetailPrint "Result: $0"
SectionEnd
Section "Test exec file"
 DetailPrint "nsPython::execFile $PLUGINSDIRtest.py"
 nsPython::execFile "$PLUGINSDIRtest.py"
 Pop $0
 DetailPrint "Result: $0"
SectionEnd
Section "Test exec help and vars"
 nsPython::exec "import nsis;[nsis.log(nsis.__dict__[x].__doc__) for x in ('log', 'messagebox', 'getvar', 'setvar')]"
 Pop $0
 ;indentation is a bit tricy, NSIS removes leading spaces from continued lines
 ;thus the indentation ha to be done through a variable substitution.
 ;also be careful as the maximum NSIS string length is 1024 bytes.
 StrCpy $1 " "
 nsPython::exec "import nsis$n
 for x in ('$$0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'R0', 'R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9', 'CMDLINE', 'INSTDIR', 'OUTDIR', 'EXEDIR', 'LANGUAGE'):$n
 $1 nsis.log('%s = %r' % (x, nsis.getvar(x)))$n"
 Pop $0
 StrCpy $0 "hello world"
 DetailPrint "value of $$1: $1"
 nsPython::exec "import nsis;nsis.setvar('1', 'yup')"
 Pop $0
 DetailPrint "new value of $$1: $1"
SectionEnd
Section "Test exec handles"
 nsPython::exec "import nsis;nsis.log('parent: %r' % nsis.getParent())"
 Pop $0
SectionEnd
免责声明:根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。”您需知晓本站所有内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任;如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。丨本站为个人博客非盈利性站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并不贩卖软件,不存在任何商业目的及用途。丨本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » nsPython是NSIS与Python脚本进行交互编程的插件

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址