Оператор функции CfgParserbreaking Python-скрипт NetBeans Sikuli - PullRequest
1 голос
/ 18 января 2011

По какой-то причине я не понимаю, что следующая строка приводит к сбою моего скрипта sikuli / python. Я подозреваю, что это потому, что мой код для чтения файла конфигурации глючит. Я не понимаю, почему, что я пропускаю.

enter code here

если существует (SignIn_EULA, 30): нажмите (Pattern (SignIn_EULA) Это нижняя часть серии определений и всегда ошибка в NetBeans и Sikuli. Этот конфигурационный парсер не читает значение (я думаю)

from sikuli.Sikuli import*
import glob
import os
import subprocess
import ConfigParser

#config.read('C:\\SikuliTest\\UserA.ini')
config = ConfigParser.ConfigParser()
#config.RawConfigParser.read('C:\\SikuliTest\\UserA.ini')
config.readfp(open('C:\\SikuliTest\\UserA.ini'))
#config = ConfigParser.RawConfigParser
#config.readfp(open('C:\\SikuliTest\\UserA.cfg'))

#config.RawConfigParser.read('C:\\SikuliTest\\UserA.ini')
#ConfigParser.RawConfigParser.read('C:\\SikuliTest\\UserA.ini')

dirname = config.get('Install', 'dirname')
filespec = config.get('Install', 'filespec')
BundlePathSignIn = config.get('SignIn','BundlePathSignIn')
LoginUser = config.get('SignIn','LoginUser')
Password = config.get('SignIn','Password')
PasswordInputField = config.get('SignIn','SignIn_PasswordInput')
Launch = config.get('SignIn','SignIn_Launch')
LoginPanel = config.get('SignIn','SignIn_BlankPanel')
FullLoginPanel = config.get('SignIn','SignIn_BlankPanel')
TOF1L = config.getint('SignIn','TOF1L')
TOF2L = config.getint('SignIn','TOF2L')
SignIn_Button = config.get('SignIn','SignIn_SignInButton')
TOF1LS = config.getint('SignIn','TOF1LS')
TOF2LS = config.getint('SignIn','TOF2LS')
SignIn_EULA = config.get('SignIn','SignIn_EULA')
TOF1E = config.getint('SignIn','TOF1E')
TOF2E = config.getint('SignIn','TOF2E')
TOF1S = config.getint('SignIn', 'TOF1S')
TOF2S = config.getint('SignIn','TOF2S')
SignIn_SignIn = config.get('SignIn','SignIn_SignIn')#not sure of the function
BundlePathEULA = config.get('EULA','BundlePathEULA')
SignIn_EULA = config.get('EULA','SignIn_EULA')
SignIn_MediaRouter = config.get('EULA','SignIn_MediaRouter')
BundlePathM = config.get('MediaRouter','BundlePathMediaRouter')
SignIn_MediaRouter = config.get('MediaRouter','SignIn_MediaRouter')
TOF1M = config.getint('MediaRouter','MediaRouter_TOF1M')
TOF2M = config.getint('MediaRouter','MediaRouter_TOF2M')
SignIn_OKButton = config.get('MediaRouter','SignIn_OKButton')
BundlePathCL = config.get('ContactList','BundlePathContactList')
ContactList_WelcomePanel = config.get('ContactList','ContactList_WelcomePanel')
ContactList_Add = config.get('ContactList','ContactList_AddContact')
ContactList_AddContact = config.get('ContactList','ContactList_AddContact')
ContactList_AddContactUser = config.get('ContactList', 'ContactList_AddContactUser')#Add a path to user B login ID
ContactList_GreenDot = config.get('ContactList','ContactList_GreenDot')
ContactList_TOF1CL = config.getint('ContactList','TOF1CL')
ContactList_TOF2CL = config.getint('ContactList','TOF2CL')
ContactList_AcceptAddToList = config.get('ContactList','ContactList_AcceptAddToList')
ContactList_TOF3CL = config.getint('ContactList','AcceptAddToList_TOF3CL')
ContactList_TOF4CL = config.getint('ContactList','AcceptAddToList_TOF4CL')
ContactList_TOF5CL = config.getint('ContactList','TOF5CL')
ContactList_TOF6CL = config.getint('ContactList','TOF6CL')
ContactList_TOF9CL = config.getint('ContactList','TOF9CL')
ContactList_TOF10CL = config.getint('ContactList','TOF10CL')
ContactList_MessageVerifyRemoval= config.get('ContactList','ContactList_MessageVerifyRemoval')
ContactList_SignOut = config.get('ContactList','ContactList_SignOut')
BundlePathCF = config.get('Conference','BundlePathConference')
Conference_GreenDot = config.get('Conference','Conference_GreenDot')
Conference_BlueLaunchWindow = config.get('Conference','Conference_BlueLaunchWindow')
Conference_Start = config.get('Conference','Conference_Start')
Conference_InConferenceSpeaker = config.get ('Conference', 'Conference_InConferenceSpeaker')
Conference_MeetingSetupTimeout = config.get ('Conference', 'Conference_MeetingSetupTimeout')
Conference_MeetingRequestDeclined = config.get ('Conference', 'Conference_MeetingRequestDeclined')
Conference_Close = config.get ('Conference', 'Conference_Close')
Conference_AcceptMeetingRequest = config.get('Conference','Conference_AcceptMeetingRequest')
Conference_InConferenceSpeaker = config.get ('Conference', 'Conference_InConferenceSpeaker')
TOF5CL = config.getint('Conference','TOF5CL')
TOF6CL = config.getint('Conference','TOF6CL')
Conference_ViewingLens = config.get ('Conference', 'Conference_ViewingLens')
Conference_EndedAllLeft = config.get ('Conference', 'Conference_EndedAllLeft')
TOF7CL = config.getint('Conference','TOF7CL')
TOF8CL = config.getint('Conference','TOF8CL')
BundlePathDK = config.get('Desktop','BundlePathDesktop')
Desktop_ExpandSysTray = config.get('Desktop','Desktop_ExpandSysTray')
Desktop_SysTrayClose = config.get('Desktop','Desktop_SysTrayClose')
Desktop_SysTraySkyRoomIcon = config.get('Desktop','Desktop_SysTrayIcon')
Desktop_SysTrayIcon = config.get ('Desktop', 'Desktop_SysTrayIcon_RTClickMenu')
Desktop_TOF1DK = config.getint('Desktop','TOF1DK')
Desktop_TOF2DK = config.getint('Desktop','TOF2DK')

setShowActions (True) # показывает всю активность в графическом интерфейсе

def ExitVCDKillProcess():
    setBundlePath (BundlePathDK)
    click(Pattern(Desktop_ExpandSysTray).targetOffset(0,0))#killing the skyroom process
    if exists(Desktop_SysTraySkyRoomIcon, 10):
        rightClick (Desktop_SysTraySkyRoomIcon)
        type(Key.DOWN + Key.DOWN + Key.DOWN + Key.ENTER )#keys down to the exit command of the Right Click menu
        rightClick (Desktop_SysTrayClose)#Right click called to close the systray menu via the escape key
        type(Key.ESC)#closes the systray window
        wait(10)
        Uninstall()
    else:
        Uninstall()

def AddContact_AtoB():
    setBundlePath(BundlePathCL)
    if exists(ContactList_WelcomePanel, 20):
        #popup("Begin add user")
        click(ContactList_Add)
        type(Key.DOWN)
        wait(1)
        type(Key.ENTER) #Launches the add contact dialog
        #type (Key.DOWN + Key.DOWN) Will launch the add via directory search.  Make new function or branch for this
        wait(1)# wait displays the add contact hover window
    if exists(ContactList_AddContact, 20):
        # popup("Add contact dialog displayed")
        type(ContactList_AddContactUser)
        wait(1)
        click(Pattern(ContactList_AddContact).targetOffset(ContactList_TOF1CL,ContactList_TOF2CL))
        #popup("verify userID exists")
        wait(1)
    if exists(ContactList_GreenDot, 10):
        #popup("Add contact successful")
        wait(2)
        ConferenceInviteAtoB()

def ConferenceInviteAtoB():
    setBundlePath(BundlePathCF)
    #click on the avaliable user green dot at top contact anonymous to sender
    if exists(Conference_GreenDot, FOREVER): # verifying confernce invite is sent only when recipient is ready
        click(Conference_GreenDot)
    if exists(Conference_BlueLaunchWindow, 20): # check for the color change
        click(Conference_Start)
    if exists(Pattern(Conference_InConferenceSpeaker).similar(0.83),FOREVER):
        UserADrawsLens()

def UserADrawsLens():
    setBundlePath(BundlePathCF)
    if exists(Conference_ControlPanel,FOREVER ):
        click(Conference_DrawLens)
        setShowActions(True)
        x1, y1, x2, y2 = (100, 100, 500, 600)
        start = Location(x1, y1)
        end = Location(x2, y2)
        stepX = 1 # adjust this as needed
        stepY = int((y2-y1)/((x2-x1)/stepX))
        run = start
        mouseMove(start); wait(1)
        mouseDown(Button.LEFT); wait(1)
        while run.getX() < end.getX():
            run = run.right(stepX).below(stepY) # use below instead of down a
        mouseMove(run)
        mouseMove(end)
        mouseUp()
        wait(5)
        wait (10)
        click (Conference_StopSharing)
        LeaveConference()



def SignOut():
    setBundlePath(BundlePathCL)
    wait(2)
    if exists(ContactList_DropList, 20):
        click (Pattern(ContactList_DropList).targetOffset(ContactList_TOF9CL,ContactList_TOF10CL))
        type (Key.DOWN + Key.DOWN + Key.DOWN + Key.DOWN + Key.DOWN + Key.ENTER)
        # signsout
    if exists(LoginPanel,FOREVER):
        wait(10)
    exit()

def RemoveContact():
    setBundlePath(BundlePathCL)
    rightClick(ContactList_GreenDot)
    type(Key.DOWN+KEY.ENTER)
    if exists(ContactList_MessageVerifyRemoval, 20):
        click(Pattern(ContactList_MessageVerifyRemoval).targetOffset(ContactList_TOF5CL,ContactList_TOF6CL))
        SignOut()


def MediaRouter():
    setBundlePath(BundlePathM)
    wait(1)
    if exists(LoginMediaRouterScreen, 30):
        click(Pattern(LoginMediaRouter).targetOffset(TOF1M, TOF2M))
        wait(1)#wait needed to support droplist navigation
        type(Key.DOWN + Key.DOWN + Key.DOWN + Key.ENTER)# selects Fort Collins
        wait(1)
        click(Pattern(OK_Button).targetOffset(0,0))
        wait(5)
        AddContact_AtoB()

def SignIn():
    setBundlePath(BundlePathSignIn)
    if exists (FullLoginPanel, 30):
        type(Pattern(SignIn_SignIn).targetOffset(TOF1S,TOF2S), LoginUser)
        wait(1)
        type(Pattern(PasswordInputField).targetOffset(TOF1L,TOF2L), Password)
        wait(1)
        click (Pattern(SignIn_Button).targetOffset(TOF1LS, TOF2LS))
        wait(5)
    if exists(SignIn_EULA,30):
        click(Pattern(SignIn_EULA)
        MediaRouter()

##The config file follows
ContactList]
bundlepathcontactlist = C:\SikuliTest\ImageLibrary\96dpi\ContactList
tof10cl = -1
tof2cl = 81
acceptaddtolist_tof3cl = 89
contactlist_addcontactuserb = michael.richardson02
contactlist_messageverifyremoval = ContactList_MessageVerifyRemoval.png
contactlist_addcontactuser = michael.richardson02
contactlist_signout = ContactList_SignOut.png
tof6cl = -1
contactlist_acceptaddtolist = ContactList_AcceptAddToList.png
acceptaddtolist_tof4cl = 40
contactlist_welcomepanel = ContactList_WelcomePanel.png
contactlist_greendot = ContactList_GreenDot.png
tof5cl = 17
contactlist_addcontact = ContactList_AddContact.png
tof9cl = 17
tof1cl = 135

[Desktop]
desktop_systrayclose = Desktop_SysTrayClose.png
tof2dk = 14
desktop_expandsystray = Desktop_ExpandSysTray.png
tof1dk = -3
desktop_systrayicon = Desktop_SysTrayIcon.png
bundlepathdesktop = C:\SikuliTest\ImageLibrary\96dpi\Desktop
desktop_systrayicon_rtclickmenu = Desktop_SysTrayIcon_RTClickMenu.png

[MediaRouter]
signin_okbutton = SignIn_OKButton.png
signin_mediarouter = SignIn_MediaRouter.png
mediarouter_tof1m = 147
mediarouter_tof2m = 7
bundlepathmediarouter = C:\SikuliTest\ImageLibrary\96dpi\SignIn

[EULA]
signin_mediarouter = SignIn_MediaRouter.png
signin_eula = SignIn_EULA.png
bundlepatheula = C:\SikuliTest\ImageLibrary\96dpi\SignIn

[Install]
dirname = Z:\BUILDS\Daily_BUILDS\QA_MainBranch_Install\*.install
filespec = setup.exe

[SignIn]
signin_blankpanel = SignIn_BlankPanel.png
signin_signin = SignIn_SignIn.png
tof1e = 506
tof2e = 444
signin_eula = SignIn_EULA.png
tof1ls = -63
tof1s = -84
tof2s = -58
tof2l = -11
tof2ls = 151
bundlepathsignin = C:\SikuliTest\ImageLibrary\96dpi\SignIn
signin_signinbutton = SignIn_SignInButton.png
tof1l = -92
signin_launch = SignIn_Launch.png
password = skyroom
signin_passwordinput = SignIn_PasswordInput.png
loginuser = michael.richardson01@X10.hphalo.net

[Conference]
conference_bluelaunchwindow = Conference_BlueLaunchWindow.png
tof10cl = 46
contactlist_droplist = ContactList_DropList
conference_greendot = Conference_GreenDot.png
conference_drawlens = Conference_DrawLens.png
conference_inconferencespeaker = Conference_InConferenceSpeaker.png
tof6cl = 57
conference_viewinglens = Conference_ViewingLens.png
conference_meetingsetuptimeout = Conference_MeetingSetupTimeout.png
bundlepathconference = C:\SikuliTest\ImageLibrary\96dpi\Conference
tof8cl = 46
tof7cl = 126
tof5cl = -76
conference_controlpanel = Conference_ControlPanel.png
conference_stopsharing = Conference_StopSharing.png
conference_endedallleft = Conference_EndedAllLeft.png
conference_leave = Conference_Leave.png
conference_start = Conference_Start.png
conference_acceptmeetingrequest = Conference_AcceptMeetingRequest.png
conference_meetingrequestdeclined = Conference_MeetingRequestDeclined.png
conference_close = Conference_Close.png
tof9cl = 126

#The create config script follows:
from sikuli.Sikuli import * #



import ConfigParser
config = ConfigParser.RawConfigParser()
#cfgfile = open("Z:\\ZZZautomation\\Sikuli\\Config\\UserA.ini",'w')
cfgfile = open("C:\\SikuliTest\\UserA.ini",'w')#local config file
#change path to desired location for the cfg file

#Install any user
config.add_section('Install')
#path requires mapping of share to z
config.set('Install', 'dirname',"Z:\\BUILDS\\Daily_BUILDS\\QA_MainBranch_Install\\*.install" )
config.set('Install', 'filespec',"setup.exe")
#EulaParamerters
config.add_section('EULA')
#config.set('EULA','BundlePathEULA',"Z:\\ZZZautomation\\Sikuli\\ImageLibrary\\96dpi\\SignIn") file location changed to local a
config.set('EULA','BundlePathEULA',"C:\\SikuliTest\\ImageLibrary\\96dpi\\SignIn")
config.set('EULA','SignIn_EULA',"SignIn_EULA.png")
#config.set('EULA','EULA_TOF1E',"497")
#config.set('EULA','EULA_TOF2E',"489")
config.set('EULA','SignIn_MediaRouter',"SignIn_MediaRouter.png")
#MediaRouterParameters any user
config.add_section('MediaRouter')
config.set('MediaRouter','BundlePathMediaRouter',"C:\\SikuliTest\\ImageLibrary\\96dpi\\SignIn")
config.set('MediaRouter','SignIn_MediaRouter',"SignIn_MediaRouter.png")
config.set('MediaRouter','MediaRouter_TOF1M',"147")
config.set('MediaRouter','MediaRouter_TOF2M',"7")
config.set('MediaRouter','SignIn_OKButton',"SignIn_OKButton.png")
#SignInParameters set for userA
config.add_section('SignIn')
config.set('SignIn','BundlePathSignIn',"C:\\SikuliTest\\ImageLibrary\\96dpi\\SignIn")
config.set('SignIn','SignIn_Launch',"SignIn_Launch.png")
config.set('SignIn','SignIn_SignIn',"SignIn_SignIn.png")#not sure of the function
config.set('SignIn','TOF1S',"-84",)
config.set('SignIn','TOF2S',"-58",)
config.set('SignIn','SignIn_BlankPanel',"SignIn_BlankPanel.png")
config.set('SignIn','SignIn_PasswordInput',"SignIn_PasswordInput.png")
config.set('SignIn','TOF1L',"-92",)
config.set('SignIn','TOF2L',"-11",)
config.set('SignIn','SignIn_SignInButton',"SignIn_SignInButton.png")
config.set('SignIn','TOF1LS',"-63",)
config.set('SignIn','TOF2LS',"151",)
config.set('SignIn','LoginUser',"michael.richardson01@X10.hphalo.net")#add ability to take users from a list
config.set('SignIn','Password',"skyroom")
config.set('SignIn','SignIn_EULA',"SignIn_EULA.png")
config.set('SignIn','TOF1E',"506")
config.set('SignIn','TOF2E',"444")
#ContactList UserA
config.add_section('ContactList')
config.set('ContactList','BundlePathContactList', "C:\\SikuliTest\\ImageLibrary\\96dpi\\ContactList")
config.set('ContactList','ContactList_WelcomePanel',"ContactList_WelcomePanel.png")
config.set('ContactList','ContactList_AddContact',"ContactList_AddContact.png")
config.set('ContactList','ContactList_AddContactUser',"michael.richardson02")#Add a path to user B login ID
config.set('ContactList','ContactList_GreenDot',"ContactList_GreenDot.png")
config.set('ContactList','TOF1CL',"135")
config.set('ContactList','TOF2CL',"81")
#ContactList accept add user userB
config.set('ContactList','ContactList_AcceptAddToList',"ContactList_AcceptAddToList.png")
config.set('ContactList','ContactList_AddContactUserB',"michael.richardson02")#Add a path to user B login ID
config.set('ContactList','ContactList_GreenDot',"ContactList_GreenDot.png")# this is a dupe
config.set('ContactList','AcceptAddToList_TOF3CL',"89")#target offset for ContactList_AcceptAddToList.png
config.set('ContactList','AcceptAddToList_TOF4CL',"40")
#contactList remove contact
config.set('ContactList','ContactList_MessageVerifyRemoval',"ContactList_MessageVerifyRemoval.png")
config.set('ContactList','TOF5CL',"86")
config.set('ContactList','TOF6CL',"38")
#config.set('ContactList','ContactList_SignOut',"ContactList_SignOut.png")
#contactList sign out
config.set('ContactList','ContactList_SignOut',"ContactList_SignOut.png")
config.set('ContactList','TOF5CL',"17")
config.set('ContactList','TOF6CL',"-1")
config.set('ContactList','TOF9CL',"17")
config.set('ContactList','TOF10CL',"-1")


#Conference A invites B
config.add_section('Conference')
config.set('Conference','BundlePathConference', "C:\\SikuliTest\\ImageLibrary\\96dpi\\Conference")
config.set('Conference','Conference_GreenDot',"Conference_GreenDot.png")
config.set('Conference','Conference_BlueLaunchWindow',"Conference_BlueLaunchWindow.png")
config.set('Conference','Conference_Start',"Conference_Start.png")
config.set('Conference','Conference_InConferenceSpeaker',"Conference_InConferenceSpeaker.png")
config.set('Conference','Conference_MeetingSetupTimeout',"Conference_MeetingSetupTimeout.png")
config.set('Conference','Conference_Close',"Conference_Close.png")
config.set('Conference','Conference_MeetingRequestDeclined',"Conference_MeetingRequestDeclined.png")
config.set('Conference','Conference_AcceptMeetingRequest',"Conference_AcceptMeetingRequest.png")
config.set('Conference','TOF5CL',"-76")
config.set('Conference','TOF6CL',"57")
config.set('Conference','Conference_ControlPanel',"Conference_ControlPanel.png")#Images used for the functiondrawlens
config.set('Conference','Conference_DrawLens',"Conference_DrawLens.png")
config.set('Conference','Conference_StopSharing',"Conference_StopSharing.png")
config.set('Conference','Conference_Leave',"Conference_Leave.png")
config.set('Conference','Conference_ViewingLens',"Conference_ViewingLens.png")
config.set('Conference','Conference_EndedAllLeft',"Conference_EndedAllLeft.png")
config.set('Conference','TOF7CL',"126")
config.set('Conference','TOF8CL',"46")
config.set('Conference','ContactList_DropList',"ContactList_DropList")
config.set('Conference','TOF9CL',"126")
config.set('Conference','TOF10CL',"46")



#ExitVCDKillProcess
config.add_section('Desktop')
config.set('Desktop','BundlePathDesktop', "C:\\SikuliTest\\ImageLibrary\\96dpi\\Desktop")
config.set('Desktop','Desktop_ExpandSysTray',"Desktop_ExpandSysTray.png")
config.set('Desktop','Desktop_SysTrayClose',"Desktop_SysTrayClose.png")
config.set('Desktop','Desktop_SysTrayIcon',"Desktop_SysTrayIcon.png")
config.set('Desktop','Desktop_SysTrayIcon_RTClickMenu',"Desktop_SysTrayIcon_RTClickMenu.png")
config.set('Desktop','TOF1DK',"-3")
config.set('Desktop','TOF2DK',"14")




config.write(cfgfile)

#f = open("Z:\\ZZZautomation\\Sikuli\\Web\\functionCreateConfigFileA.htm",'w')
popup("Configuration File Created Successfully")
#f.write ('Configuration File Created Successfully<br />')#
cfgfile.close()
#f.close()
exit()
...