Exemple #1
0
def uninstall_app(app_package):
    """
    This function is used for uninstall any app

    Function Owner : Nithya_V

    Date created : 3/05/2016

    @return True/False : (string) status of exeuction
    """
    try:
        # running android adb command to un install omm package
        if get_android_installed_packages().__contains__(app_package):

            # changing device id runtime
            uninstall_cmd = global_vars.android_app_uninstall_cmd.replace(
                'device_id', global_vars.android_device_id) + app_package
            print "Uninstall command is %s" % uninstall_cmd

            print "\n#### Executing command to uninstall OMM android app #### \n %s" % uninstall_cmd

            result, error = util.runCommand(uninstall_cmd)
            if error == "" and str(result).strip() == "Success":
                return True
            else:
                print "Cannot uninstall the package"
        else:
            print "Package is not installed"
            return True
    except:
        traceback.print_exc()
    return False
Exemple #2
0
def step_reset_ios_app():
    """
    This function is used for reset ios OMM app

    Function Owner : Ramanuja_das_pvk

    Date created : 3/09/2016

    @return True/False : (string) status of exeuction
    """
    try:
        # running android adb command to un install omm package
        if get_android_installed_packages().__contains__(g.app_package):

            # changing device id runtime
            uninstall_cmd = g.android_uninstall_cmd.replace(
                'device_id', g.android_device_id)

            print "\n#### Executing command to uninstall OMM android app #### \n %s" % uninstall_cmd

            result, error = util.runCommand(uninstall_cmd)
            if error == "" and str(result).strip() == "Success":
                return True
            else:
                print "Cannot uninstall the package"
        else:
            print "Package is not installed"
            return True
    except:
        traceback.print_exc()
    return False
Exemple #3
0
def get_android_installed_packages():
    """
    This function is used for getting installed packages in a devices

    Function Owner : Nithya_V

    Date created : 20/04/2016

    @return installed_packages : (string) all the packages installed in device
    """
    installed_packages = ""
    try:
        if global_vars.android_device_id == None:
            global_varsandroid_device_id = get_android_device_id()
        print "device id is %s" % global_vars.android_device_id
        print "command for installed packages %s" % global_vars.and_get_installed_packs_cmd
        # changing device id runtime
        cmd_packages = global_vars.and_get_installed_packs_cmd.replace(
            'device_id', str(global_vars.android_device_id))

        print "Command packages %s" % cmd_packages

        # running android adb command to retrieve installed packages
        result, error = util.runCommand(cmd_packages)
        if error == "":
            installed_packages = str(result).strip()
        else:
            print "Cannot retrieve installed packages"
    except:
        traceback.print_exc()
        return None
    return installed_packages
Exemple #4
0
def get_android_version():
    """
    This function is used for getting device id

    Function Owner : Nithya_V

    Date created : 20/04/2016

    @return android_version : (string) android version of the device
    """
    android_version = ""
    try:
        if global_vars.android_device_id == None:
            global_vars.android_device_id = get_android_device_id()
        print "and version command is %s" % global_vars.android_version_cmd
        and_ver_cmd = str(global_vars.android_version_cmd).replace(
            'device_id', str(global_vars.android_device_id))
        print "Android version command is %s" % and_ver_cmd

        # running android adb command to retrieve device version
        result, error = util.runCommand(and_ver_cmd)
        if error == "":
            android_version = str(result).strip()
        else:
            print "Cannot retrieve android version"
    except:
        traceback.print_exc()
        return None
    return android_version
Exemple #5
0
def get_android_device_dict():
    """
    This function is used for getting device dictionary

    Function Owner : Nithya_V

    Date created : 20/05/2016

    @return device_id : (string) Device dictionary of the android device
    """
    device_dict = {}
    try:
        # running android adb command to retrieve device id
        result, error = util.runCommand(global_vars.android_deviceID_cmd)
        device_dict = {}
        if error == "":
            device_lines = result.split('\n')
            for line in device_lines:
                if not (line.__contains__('List of devices attached')
                        ) and line.__contains__('device'):

                    device = line.split('  device')
                    deviced_id = device[0].strip()
                    if line.__contains__('model:'):
                        device_model = device[1].split('model:')[1].strip()
                    else:
                        device_model = None
                    device_dict[deviced_id] = device_model
            print "ADB device dict is %s" % device_dict
        else:
            print "Cannot retrieve device dictionary"
    except:
        traceback.print_exc()
        return ""
    return device_dict
Exemple #6
0
def uninstall_ios_omm_app():
    """
    This function is used for uninstall IOS OMM app

    Function Owner : Nithya_V

    Date created : 17/05/2016

    @return True/False : (string) status of execution
    """
    try:
        uninstall_cmd = str(global_vars.ios_uninstall_cmd).replace(
            'udid', global_vars.udid)
        print "\n#### Executing command to uninstall OMM IOS app #### \n %s" % uninstall_cmd
        result, error = util.runCommand(uninstall_cmd)
        if error == "" and str(result).__contains__('Complete'):
            return True
    except:
        traceback.print_exc()
    return False
Exemple #7
0
def get_gennymotion_devices():
    """
    This function is used for getting available gennymotion emulators
    with Status ON

    Function Owner : Nithya_V

    Date created : 24/05/2016

    @return devices : (dictionary) Dictionary of genny motion devices with its
                    id, status, type, name
    """
    gm_device_dict = {}

    try:
        # running android adb command to retrieve device id
        print "OS type is %s" % os_type
        if os_type == 'Windows':
            gennymotion_cmd = global_vars.gennymotion_cmd
        else:
            gennymotion_cmd = global_vars.mac_gennymotion_cmd

        result, error = util.runCommand(gennymotion_cmd, shell=True)
        print "result is %s" % result
        if error == "":
            lines = result.split('\n')
            for line in lines:
                if line.__contains__('|  virtual |'):
                    deviceline = line.split('|')
                    if deviceline[2].strip() == 'On':
                        gm_device_dict[
                            deviceline[4].strip()] = deviceline[5].strip()
            print "Genny motion Device dictionary is %s" % gm_device_dict
        else:
            print "Cannot retrieve genny motion device details"
    except:
        traceback.print_exc()
        return {}
    return gm_device_dict
Exemple #8
0
def get_ios_udid():
    """
    This function is used for getting udid in an ios device

    Function Owner : Nithya_V

    Date created : 13/05/2016

    @return udid : (string) UDID of the ios device
    """
    udid = ""
    try:
        # running android adb command to retrieve device id
        result, error = util.runCommand(global_vars.ios_udid_cmd, shell=True)
        print "Command is %s" % global_vars.ios_udid_cmd
        if error == "":
            udid = result.strip()
            print "UDID is %s" % udid
        else:
            print "Cannot retrieve udid"
    except:
        traceback.print_exc()
        return ""
    return udid