Hey All, I have a few questions. Heres a brief overview to get some context. I had some problems with ProEngineer producing an exit code too soon. Setup.exe spawns a child process that actually does the entire install, then quits. Upon the Setup.exe quit, it returns a successful exit code to WPKG causing WPKG to move on before the install is finished, creating multiple simultaneous installs. I found the process and thought I would be slick by writing a python script that I call in WPKG. It starts the install ProEngineer install and then does a check loop for the child process. The python script quits when the install is finished. I hoped once the python script quits, it would return that exit code to WPKG, causing it to move on when I wanted (at the end of the install). So after that (not so)brief summary, here are my questions:
Does WPKG actually recognize python? - I dont think it does, So i tried to call this whole thing against python.exe. How does WPKG use double quoting? Is there an escape character for quoting? Anyone know of a better way to do this? Really, its all PTC's fault for making the ProE installer so stupid. I'll include the python script and my ProE package below: Python: Too Long, See attached. WPKG Package Entry: <package id="proengineer2" name="Pro/ENGINEER Wildfire 2.0" revision="2.0" reboot="false" priority="4"> <check type="uninstall" condition="exists" path="Pro/ENGINEER Release Wildfire 2.0 Datecode M280" /> <install cmd='%WPKGROOT%\tools\python26\python.exe %Software%\ProE\Watchdog.py y "\software\wpkg\software\ProE\WildFire2\Disk1of3\setup.exe -uitrail" "\software\wpkg\software\ProE\WildFire2\Disk1of3\WF2TrailFile.txt"' /> </package> Brian Reese IT Desktop Support Boston Engineering 411 Waverly Oaks Rd. Suite 114 Waltham, MA, 02452 Phone: (781) 314-0753 www.Boston-Engineering.com
#!c:/Python26/python.exe -u ####################################################################### # $Id: defaultTemplate.py,v 1.1.1.1 2005/07/22 13:35:49 slothrop Exp $ ####################################################################### # # File: proe-installer.py # Description: This script is used to install Pro/E from inside WPKG. # The initial process used to install Pro/E, setup.exe, # sponses a secondary process and exits. The exit of setup.exe # cuases WPKG to think the install is over and the next package # is installed. This script starts setup.exe and monitors the # active process list for the secondary Pro/E install process. # Once the secondary Pro/E install process has completed this # script will exit. The script has a timeout to prevent # an infinate loop. # # Return Values: # 0 = Success # # Changelog: # * 2008/12/12 breese <[email protected]> # - Intial script ####################################################################### from win32com.client import GetObject import sys import re import time import os #************************************************# # Local Vars #************************************************# SLEEP_TIME=20 # Time to sleep on each loop. PROCESS_REGEX="^ptc.*_tmp\.exe$" # regex string to match Pro/E install process MAX_LOOPS=50 # Maxium number of wait loops REMOTE_DATA_PATH="\\\\samba2\\data"# Remote drive share that contains install data #************************************************# # Inputs #************************************************# TRAIL_PATH="" INSTALL_CMD="" MOUNT_DRIVE="" if len(sys.argv) >= 4: MOUNT_DRIVE=sys.argv[1] INSTALL_CMD=sys.argv[2] TRAIL_PATH=sys.argv[3] #************************************************# # Local Functions #************************************************# def foundProcess(processes, processNamePattern): """ Search for a process name pattern in set of processes. @type processes: Win32_Process @param processes: A group of system processes @type processNamePattern: string @param processNamePattern: A regex pattern """ regex = re.compile(processNamePattern) for process in processes: processName = process.Properties_('Name').Value if regex.match(processName) is not None: print "Found process %s." % (processName) return True return False def mountDrive(drive, systemToMount): """ Mount the given drive. ***WINDOWS ONLY*** @type drive: string @param drive: The drive to mount @type systemToMount: string @param systemToMount: The system to mount """ unmountDrive(drive) os.system("c:\\windows\\system32\\net.exe use %s: %s" % (drive, systemToMount)) def unmountDrive(drive): """ Unmount the given drive. ***WINDOWS ONLY*** @type drive: string @param drive: The drive to unmount """ os.system("c:\\windows\\system32\\net.exe use %s: /DELETE /YES" % (drive)) #************************************************# #Main script start #************************************************# print "Preping system for install..." mountDrive(MOUNT_DRIVE, REMOTE_DATA_PATH) print "Installing Pro/E..." print "%s:\%s %s:\%s" % (MOUNT_DRIVE, INSTALL_CMD, MOUNT_DRIVE, TRAIL_PATH) os.system("%s:\%s %s:\%s" % (MOUNT_DRIVE, INSTALL_CMD, MOUNT_DRIVE, TRAIL_PATH)) # Setup windows system objects wmi = GetObject('winmgmts:') # Wait for Pro/E to complete install before exiting. This loop will # sleep for SLEEP_TIME if the Pro/E install process is found. The loop will # exit once the process is complete or if MAC_LOOP is reached. loopCounter=1 while loopCounter < MAX_LOOPS: print "Loop %s of %s. Waiting %s secs..." % (loopCounter, MAX_LOOPS, SLEEP_TIME) time.sleep(SLEEP_TIME) processes = wmi.InstancesOf('Win32_Process') if not foundProcess(processes, PROCESS_REGEX): print "Install complete. Cleaning up system..." unmountDrive(MOUNT_DRIVE) sys.exit(0) loopCounter = loopCounter + 1
------------------------------------------------------------------------- wpkg-users mailing list archives >> http://lists.wpkg.org/pipermail/wpkg-users/ _______________________________________________ wpkg-users mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/wpkg-users
