Bug 636451 - devicemanager should have the ability to terminate when it can't launch a second process. r=mcote, a=NPOTB
authorJoel Maher <jmaher@mozilla.com>
Thu, 24 Feb 2011 14:45:39 -0500
changeset 63055 0c11cf1fe59491bc67760b9729d94a1a48e79694
parent 63054 5509926d2efd996422d70d950463e83d83425359
child 63056 6da15ed37f3788c0a60d3be96b14d9bf210dd8da
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersmcote, NPOTB
bugs636451
milestone2.0b13pre
Bug 636451 - devicemanager should have the ability to terminate when it can't launch a second process. r=mcote, a=NPOTB
build/mobile/devicemanager.py
--- a/build/mobile/devicemanager.py
+++ b/build/mobile/devicemanager.py
@@ -275,16 +275,19 @@ class DeviceManager:
     return '\n'.join(retVal)
   
 
   # external function
   # returns:
   #  success: True
   #  failure: False
   def pushFile(self, localname, destname):
+    if (os.name == "nt"):
+      destname = destname.replace('\\', '/')
+
     if (self.debug >= 3): print "in push file with: " + localname + ", and: " + destname
     if (self.validateFile(destname, localname) == True):
       if (self.debug >= 3): print "files are validated"
       return True
 
     if self.mkDirs(destname) == None:
       print "unable to make dirs: " + destname
       return False
@@ -481,25 +484,27 @@ class DeviceManager:
           #android returns <userID> <procID> <procName>
           files += [[pidproc[1], pidproc[2], pidproc[0]]]     
     return files
 
   # external function
   # returns:
   #  success: pid
   #  failure: None
-  def fireProcess(self, appname):
+  def fireProcess(self, appname, failIfRunning=False):
     if (not appname):
       if (self.debug >= 1): print "WARNING: fireProcess called with no command to run"
       return None
 
     if (self.debug >= 2): print "FIRE PROC: '" + appname + "'"
 
     if (self.processExist(appname) != None):
       print "WARNING: process %s appears to be running already\n" % appname
+      if (failIfRunning):
+        return None
     
     try:
       data = self.verifySendCMD(['exec ' + appname])
     except(DMError):
       return None
 
     # wait up to 30 seconds for process to start up
     timeslept = 0
@@ -512,33 +517,33 @@ class DeviceManager:
 
     if (self.debug >= 4): print "got pid: %s for process: %s" % (process, appname)
     return process
 
   # external function
   # returns:
   #  success: output filename
   #  failure: None
-  def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = ''):
+  def launchProcess(self, cmd, outputFile = "process.txt", cwd = '', env = '', failIfRunning=False):
     if not cmd:
       if (self.debug >= 1): print "WARNING: launchProcess called without command to run"
       return None
 
     cmdline = subprocess.list2cmdline(cmd)
     if (outputFile == "process.txt" or outputFile == None):
       outputFile = self.getDeviceRoot();
       if outputFile is None:
         return None
       outputFile += "/process.txt"
       cmdline += " > " + outputFile
     
     # Prepend our env to the command 
     cmdline = '%s %s' % (self.formatEnvString(env), cmdline)
 
-    if self.fireProcess(cmdline) is None:
+    if self.fireProcess(cmdline, failIfRunning) is None:
       return None
     return outputFile
   
   # loops until 'process' has exited or 'timeout' seconds is reached
   # loop sleeps for 'interval' seconds between iterations
   # external function
   # returns:
   #  success: [file contents, None]
@@ -1076,17 +1081,17 @@ class DeviceManager:
     # Format the process output
     if 'process' in result:
       proclist = []
       for l in result['process']:
         if l:
           proclist.append(l.split('\t'))
       result['process'] = proclist
 
-    print "results: " + str(result)
+    if (self.debug >= 3): print "results: " + str(result)
     return result
 
   """
   Installs the application onto the device
   Application bundle - path to the application bundle on the device
   Destination - destination directory of where application should be
                 installed to (optional)
   Returns None for success, or output if known failure
@@ -1219,17 +1224,16 @@ class DeviceManager:
     Output - a quoted string of the form: '"envvar1=val1,envvar2=val2..."'
     If env is None or '' return '' (empty quoted string)
   """
   def formatEnvString(self, env):
     if (env == None or env == ''):
       return ''
 
     retVal = '"%s"' % ','.join(map(lambda x: '%s=%s' % (x[0], x[1]), env.iteritems()))
-    print "got retval: '%s'" % retVal
     if (retVal == '""'):
       return ''
 
     return retVal
 
   """
     adjust the screen resolution on the device, REBOOT REQUIRED
     NOTE: this only works on a tegra ATM