def switchPlugin(pluginGroup, image): """Switches the plugin from its default to the specified one and returns plugin location on screen. pluginGroup -- The group to which the plugin belongs to ('editing', 'editorial', 'pdf' or 'export') image -- PNG image corresponding to the plugin """ pluginGroupImage = pluginGroup + '_default.png' # If the plugin isn't default any more, reload Flix to have all plugins reset to default. if not exists(pluginGroupImage, 3): if reloadFlix(pluginGroupImage) == 0: log('Could not find %s for the %s plugin group.' % (pluginGroupImage, pluginGroup), 'error') return 0 # hover(pluginGroupImage) # pluginLocation = sikuli.Env.getMouseLocation() # mouseDown(sikuli.Button.LEFT) # hover(image) # mouseUp(sikuli.Button.LEFT) hover(pluginGroupImage); wait(1) # wait for the tooltip to appear and go away pluginLocation = sikuli.Env.getMouseLocation() mouseDown(sikuli.Button.LEFT) # hover('projectBrowserBtn.PNG') # makes sure the tooltip isn't in the way click(image) return pluginLocation
def allExist(images): """Helper function to check if all the provided images in the list can be found images -- list of images (.png) to look for on the screen """ for i in images: if not exists(i, 10): return i log('Found panel %s.' % i, 'debug') return 0
def quitFlix(platform): if click('flixOptionsBtn.png'): wait(.5) type(sikuli.Key.UP); wait(.5) type(sikuli.Key.ENTER); wait(2) log('quitFlix: Flix has been killed.', 'debug') else: log('quitFlix: Flix could not be killed from Options menu; force killing it...') if platform == "mac": cmd = "ps -A | grep Applications/Flix | awk '{print $1}' | xargs kill -9" os.system(cmd)
def exitProc(IP, port): """Exits a Flix proc given its IP:port :param IP: IP address for the proc to be exited :param port: port for the proc to be exited :return: None """ try: urllib2.urlopen("http://%s:%s/exit" % (IP, port)) log('exitProc: %s:%s proc exited successfully.' % (IP, port)) except urllib2.URLError, e: log('exitProc: Could not exit %s:%s proc, probably already down.\n%s' % (IP, port, e), 'debug')
def waitForResync(): timeout = 120 startTime = time.time() while time.time() <= startTime + timeout: hover(sikuli.Pattern('flixSettings.png').targetOffset(25, 0)) if exists('doneSyncing.png', 5): return 1 log('waitForResync: There are still files syncing after %s seconds.' % timeout) return 0
def closeExplorerWindow(lastDir): if sikuli.App.focus(lastDir): wait(1) ctrlType('w'); wait(1) elif sikuli.App.focus('Documents'): wait(1) ctrlType('w'); wait(1) log('closeExplorerWindow: File Explorer revealed in Documents and not %s.' % lastDir, 'debug') else: wait(3) if sikuli.App.focus(lastDir): wait(1) ctrlType('w'); wait(1) else: log('Could not find %s explorer window, so did not close it.' % lastDir, 'debug')
def click(img, modifiers=None): if modifiers is None: try: sikuli.click(img) return 1 except FindFailed: log('FindFailed: Could not find %s.' % img, 'error') return 0 else: try: sikuli.click(img, modifiers) return 1 except FindFailed: log('FindFailed: Could not find %s.' % img, 'error') return 0
def openMayaFile(testInfo, mayaFile): path = '%sassets/fromMaya/%s' % (testInfo.testPath, mayaFile) if os.path.exists(path): pyUtils.revealFile(path); wait(2) sikuli.App.focus('fromMaya'); wait(.5) type(sikuli.Key.ENTER); wait(1) if not exists('mayaIcon.png', 30): log('openMayaFile: Could not find Maya open.', 'error') return closeExplorerWindow('fromMaya'); wait(1) sikuli.App.focus('Maya') wait(10) # make sure Maya's ready to do stuff # Make sure the Flix shelf is in focus if not exists('mayaFlixServer.png', 2): if click('mayaFlixShelf.png') == 0: log('openMayaFile: Could not find the Flix shelf in Maya; exiting.', 'error') return else: log('openMayaFile: %s does not exist, skipping.' % path, 'error')
def cleanup(testInfo, deleteSeq): # Close the Flix Chrome tab closeChromeTab(); wait(1) # Kill Flix quitFlix(testInfo.OS) # exitProc("127.0.0.1", "35980") # try: # urllib2.urlopen("http://127.0.0.1:35980/exit") # except urllib2.URLError, e: # log('cleanup: Could not exit Flix, probably already down.\n%s' % e, 'debug') # Close command prompt # if sikuli.App.focus('flix UI'): # wait(1) # type('exit'); wait(1) # type(sikuli.Key.ENTER); wait(1) # else: # log('cleanup: Could not focus on the Flix UI Command Prompt window.') if os.getenv('QA_FLIX_ZIPSEQ') == '1': log('cleanup: Zipping sequence...', 'debug') pyUtils.zipSequence(testInfo) # Delete the sequence if deleteSeq: pyUtils.deleteSequence(testInfo) if testInfo.episode: pyUtils.deleteEpisode(testInfo) # Copy Flix's local log to the logs directory try: shutil.copyfile(testInfo.flixLog, "%s/../flixLog_%s.log" % (testInfo.outDir, testInfo.testName)) except Exception, e: log("cleanup: failed to copy the Flix log file.\n%s" % e, "error")
def createShotgunSequence(testInfo): """Method to create a sequence in Shotgun from scratch, via their website""" if testInfo.show == 'qa_test': url = 'https://abo.shotgunstudio.com/page/1801' seqImage = 'sgFlx.png' elif testInfo.show == 'cl2': url = 'https://abo.shotgunstudio.com/page/1985' seqImage = 'sgEp001_flx.png' else: log('createShotgunSequence: Show %s not setup in Shotgun, plugin will probably fail.' % testInfo.show, 'error') return newChromeTab(url) # Log in if needed (assumes Chrome remembered credentials) if exists('sgLogin.png', 3): type(sikuli.Key.TAB); wait(.5) type(sikuli.Key.TAB); wait(.5) type(sikuli.Key.ENTER); wait(.5) if exists(seqImage): sikuli.rightClick(seqImage); wait(.5) click('sgDeleteSeq.png'); wait(1) type(sikuli.Key.ENTER); wait(1) else: log('createShotgunSequence: Could not find sequence %s in shotgun.' % testInfo.sequence) # Create the sequence from scratch click('sgCreateSeq.png'); wait(1) type(testInfo.sequence); wait(.5) type(sikuli.Key.TAB); wait(.5) type(sikuli.Key.TAB); wait(.5) type('basic_sequence'); wait(.5) type(sikuli.Key.ENTER); wait(.5) type(sikuli.Key.TAB); wait(.5) type(sikuli.Key.ENTER); wait(.5) if exists(seqImage): log('createShotgunSequence: Sequence %s successfully created in Shotgun.' % testInfo.sequence) else: log('createShotgunSequence: Sequence %s probably not created in Shotgun.' % testInfo.sequence) closeChromeTab()
# Close command prompt # if sikuli.App.focus('flix UI'): # wait(1) # type('exit'); wait(1) # type(sikuli.Key.ENTER); wait(1) # else: # log('cleanup: Could not focus on the Flix UI Command Prompt window.') if os.getenv('QA_FLIX_ZIPSEQ') == '1': log('cleanup: Zipping sequence...', 'debug') pyUtils.zipSequence(testInfo) # Delete the sequence if deleteSeq: pyUtils.deleteSequence(testInfo) if testInfo.episode: pyUtils.deleteEpisode(testInfo) # Copy Flix's local log to the logs directory try: shutil.copyfile(testInfo.flixLog, "%s/../flixLog_%s.log" % (testInfo.outDir, testInfo.testName)) except Exception, e: log("cleanup: failed to copy the Flix log file.\n%s" % e, "error") if len(testInfo.failures) != 0: log('END OF TEST. Summary of failures:') for failure in testInfo.failures: log('%s' % failure, 'error') else: log('No failures!')