connectToDeviceOrExit should take serialno as a parameter #16

Closed
durairaj77 opened this Issue Nov 27, 2012 · 1 comment

Projects

None yet

2 participants

@durairaj77

In my case, I am running monkeyrunner scripts through another program, hence I will not be passing the serialno as a commandline parameter, instead I will be passing it as an arguement to function. If you consider adding it as a parameter to connectToDeviceOrExit() function, it would be great.

github completely reformatted by patch.

--- /tmp/8sTxDd_viewclient.py
+++ /home/durai/automation/AndroidViewClient/AndroidViewClient/src/com/dtmilano/android/viewclient.py
@@ -1015,7 +1015,7 @@
return serialno

 @staticmethod
  • def connectToDeviceOrExit(timeout=60, verbose=False, ignoresecuredevice=False):
  • def connectToDeviceOrExit(serialno='None', timeout=60, verbose=False, ignoresecuredevice=False):
    '''
    Connects to a device which serial number is obtained from the script arguments if available
    or using the default regex C{.*}.
    @@ -1037,11 +1037,12 @@
 progname = os.path.basename(sys.argv[0])
 # eat all the extra options the invoking script may have added
  •    while len(sys.argv) > 1 and sys.argv[1][0] == '-':
    
  •        sys.argv.pop(1)
    
  •    serialno = sys.argv[1] if len(sys.argv) > 1 else \
    
  •            os.environ['ANDROID_SERIAL'] if os.environ.has_key('ANDROID_SERIAL') \
    
  •            else '.*'
    
  •    if serialno is None:
    
  •        while len(sys.argv) > 1 and sys.argv[1][0] == '-':
    
  •            sys.argv.pop(1)
    
  •        serialno = sys.argv[1] if len(sys.argv) > 1 else \
    
  •                os.environ['ANDROID_SERIAL'] if os.environ.has_key('ANDROID_SERIAL') \
    
  •                else '.*'
     if verbose:
         print 'Connecting to a device with serialno=%s with a timeout of %d secs...' % (serialno, timeout)
     # Sometimes MonkeyRunner doesn't even timeout (i.e. two connections from same process), so let's
    
@dtmilano dtmilano was assigned Nov 28, 2012
@dtmilano dtmilano added a commit that referenced this issue Nov 28, 2012
@dtmilano Issue #16: connectToDeviceOrExit should take serialno as a parameter
- Added serialno parameter to connectToDeviceOrExit as last parameter
  to be backward compatible
3ff051c
@dtmilano
Owner

Should be completely fixed by fbcf3f0.
Please retest and close the issue if fixed.

@durairaj77 durairaj77 closed this Dec 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment