Trying to automate and return android version using python returns two values

here is my code:

def subprocess_cmd(command):
    process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
    proc_stdout = process.communicate()[0].decode('utf-8').strip()
    print proc_stdout

def getVersion():
    subprocess_cmd('adb shell getprop ro.build.version.release')

print getVersion()

When I run this in my ide it returns the android version and ‘None’. Running the command directly from terminal results in just the version number. When i call the method from my desired_caps the platformVersion returns ‘none’ if I print out my desired_caps. What do I need to do to remove the ‘None’? I feel like I am missing something simple. Here is my desired capabilities:

class DriverBuilderAndroid(object):
    _multiprocess_can_split_ = True

        def __init__(self):
            self.setUp()

    def setUp(self):
        getDevice = GetDeviceID()
         
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = GetAndroidVersion.getVersion()
        print GetAndroidVersion.getVersion() 
        desired_caps['port'] = os.environ['PORT'] if "PORT" in os.environ else 4723
        desired_caps['deviceName'] = os.environ['UDID'] if "UDID" in os.environ else 
            getDevice.getDeviceID()

        desired_caps['app'] = APKInstall.installAPK()
        desired_caps['appPackage'] = 'com.jsdev.instasize'
        desired_caps['appActivity'] = '.activities.MainActivity'
        port = os.environ['PORT'] if "PORT" in os.environ else 4723
        url = "http://localhost:%s/wd/hub" % port
       print desired_caps
       self.driver = webdriver.Remote(url, desired_caps)

and this is what happens when I print(desired_caps):

{'deviceName': u'\n8802edf5\t\n\n', 'app': 
 '/Users/tyler/Desktop/InstasizeInstallAPK/Instasize_20172012_release_4.0.6_124_google.a
pk', 'appActivity': '.activities.MainActivity', 'platformVersion': None, 'appPackage': 
'com.jsdev.instasize', 'platformName': 'Android', 'port': 4723}

Hi @tyler_hackett

The function subprocess_cmd prints the output but never passes the value on. the function getVersion makes use of subprocess_cmd but also never returns the value.

So when you call GetAndroidVersion.getVersion(), no value is returned. Try to add the return statement in both functions to see if that solves the issue.

thank you, I will try it later today when I get time.

it worked, thank you for your help