All pastes #369145 Raw Edit

vam

public python v1 · immutable
#369145 ·published 2007-02-23 16:30 UTC
rendered paste body
from ldtp import *from ldtputils import *def deleteMailAccount (accountName):    try:        try:            selectmenuitem ('frm*Evolution', 'mnuEdit;mnuPreferences')            waittillguiexist ('dlgEvolutionPreferences')            if verifyAccountExist (accountName)== -1:                msg = 'Account Not Present'                raise LdtpExecutionError (msg)            selectrowpartialmatch ('dlgEvolutionPreferences', 'tblMailAccounts', accountName)        except:            msg = 'Account not present'            log (msg,'cause')            raise LdtpExecutionError (msg)        try:            click ('dlgEvolutionPreferences', 'btnRemove')            waittillguiexist ('dlgDeleteaccount?')            click ('dlgDeleteaccount?', 'btnDelete')        except:            msg = 'Unable to delete the account'            log (msg,  'cause')            raise LdtpExecutionError (msg)        if verifyAccountExist (accountName) == -1:            log ('Delete Account', 'pass')        else:            log ('Delete Account', 'fail')            raise LdtpExecutionError ('Delete Account Failed')        click ('dlgEvolutionPreferences', 'btnClose')    except:        msg = 'Unable to delete account'        log (msg, 'error')        raise LdtpExecutionError (msg)    def verifyAccountExist (accountName):    try:        print accountName        numOfChild = getrowcount ('dlgEvolutionPreferences', 'tblMailAccounts')        for num in range (numOfChild):            if getcellvalue ('dlgEvolutionPreferences', 'tblMailAccounts', num, 1).startswith (accountName):                return num        return -1    except:        msg = 'Unable to verify if account exists'        log (msg, 'error')        raise LdtpExecutionError (msg)def enableMailAccount (accountName):    try:        try:            selectmenuitem ('frm*Evolution', 'mnuEdit;mnuPreferences')            waittillguiexist ('dlgEvolutionPreferences')            index=verifyAccountExist (accountName)            if index==-1:                                   msg = 'Account Not Present'                raise LdtpExecutionError (msg)            selectrowpartialmatch ('dlgEvolutionPreferences', 'tblMailAccounts', accountName)        except:            msg = 'Account not present'            log (msg, 'cause')            raise LdtpExecutionError (msg)        try:            selectrowpartialmatch ('dlgEvolutionPreferences', 'tblMailAccounts', accountName)            checkrow ('dlgEvolutionPreferences', 'tblMailAccounts', index, 0)        except:            msg = 'Unable to enable Mail Account'            log (msg, 'cause')            raise LdtpExecutionError (msg)        try:            selectrowpartialmatch ('frm*Evolution', 'ttblMailFolderTree', accountName)        except:            msg = 'Account not available in Directory List'            log (msg, 'warning')        log ('Enable Account', 'pass')        click ('dlgEvolutionPreferences', 'btnClose')        waittillguinotexist ('dlgEvolutionPreferences')    except:        msg = 'Mail Account not enabled'        log (msg, 'error')        raise LdtpExecutionError (msg)def disableMailAccount (accountName):    try:        try:            selectmenuitem ('frm*Evolution', 'mnuEdit;mnuPreferences')            waittillguiexist ('dlgEvolutionPreferences')            index=verifyAccountExist (accountName)            if index==-1:                                                 msg = 'Account Not Present'                raise LdtpExecutionError (msg)            selectrowpartialmatch ('dlgEvolutionPreferences', 'tblMailAccounts', accountName)        except:            msg = 'Account not present'            log (msg, 'cause')            raise LdtpExecutionError (msg)        try:            uncheckrow ('dlgEvolutionPreferences', 'tblMailAccounts', index, 0)        except:            msg = 'Unable to disable Mail Account'            log (msg,'cause')            raise LdtpExecutionError (msg)        try:           selectrowpartialmatch ('frm*Evolution',  'ttblMailFolderTree',  accountName)        except:            log ('Disable Account', 'pass')            click ('dlgEvolutionPreferences', 'btnClose')            waittillguinotexist ('dlgEvolutionPreferences')            msg = 'Disable Account Failed'            log (msg, 'fail')            raise LdtpExecutionError (msg)    except:        msg = 'Mail Account not Disabled'        log (msg, 'error')        raise LdtpExecutionError (msg)def makeDefault (accountName):    try:        try:            selectmenuitem ('frm*Evolution', 'mnuEdit;mnuPreferences')            waittillguiexist ('dlgEvolutionPreferences')            index=verifyAccountExist (accountName)            if index==-1:                                                 msg = 'Account Not Present'                raise LdtpExecutionError (msg)            selectrowpartialmatch ('dlgEvolutionPreferences', 'tblMailAccounts', accountName)        except:            msg = 'Account not present'            log (msg,'cause')            raise LdtpExecutionError (msg)        try:            try:                click ('dlgEvolutionPreferences', 'btnDefault')            except:                log ('Already Default', 'info')            name=getcellvalue ('dlgEvolutionPreferences', 'tblMailAccounts', index, 1)            desired_name=accountName+' '+'[Default]'            if name == desired_name:                log ('Set Default', 'pass')            else:                log ('Set Default', 'fail')        except:            msg = 'Unable to make account as default'            log (msg, 'error')            raise LdtpExecutionError (msg)    except:        msg = 'Make Account default failed'         log (msg, 'error')        raise LdtpExecutionError (msg)    click ('dlgEvolutionPreferences', 'btnClose')