How to use findWestonScreenshotFilenames method in fMBT

Best Python code snippet using fMBT_python

fmbttizen-agent.py

Source:fmbttizen-agent.py Github

copy

Full Screen

...670 libX11.XDestroyImage(image_p)671 return True, compressed_image672def westonTakeScreenshotRoot(retry=2):673 if westonTakeScreenshotRoot.ssFilenames == None:674 westonTakeScreenshotRoot.ssFilenames = findWestonScreenshotFilenames()675 if not westonTakeScreenshotRoot.ssFilenames:676 return False, "cannot find weston screenshot directory"677 try:678 for ssFilename in westonTakeScreenshotRoot.ssFilenames:679 if os.access(ssFilename, os.R_OK):680 os.remove(ssFilename)681 keyboard_device.press("KEY_LEFTMETA")682 keyboard_device.tap("s")683 keyboard_device.release("KEY_LEFTMETA")684 time.sleep(0.5)685 # find which screenshot file got created?686 for ssFilename in westonTakeScreenshotRoot.ssFilenames:687 if os.access(ssFilename, os.R_OK):688 break689 else:690 if retry > 0:691 return westonTakeScreenshotRoot(retry-1)692 else:693 return False, "weston did not create any of files %s" % (694 westonTakeScreenshotRoot.ssFilenames,)695 # wait for the screenshot writer to finish696 writerPid = fuser(ssFilename)697 if writerPid != None:698 time.sleep(0.1)699 while fuser(ssFilename, [writerPid]) != None:700 time.sleep(0.1)701 shutil.move(ssFilename, "/tmp/screenshot.png")702 os.chmod("/tmp/screenshot.png", 0666)703 except Exception, e:704 return False, str(e)705 return True, None706westonTakeScreenshotRoot.ssFilenames = None707def takeScreenshotOnWeston():708 if iAmRoot:709 rv, status = westonTakeScreenshotRoot()710 else:711 rv, status = subAgentCommand("root", "tizen", "ss weston-root")712 if rv == False:713 return rv, status714 return True, file("/tmp/screenshot.png").read()715def fuser(filename, usualSuspects=None):716 """Returns the pid of a user of given file, or None"""717 filepath = os.path.realpath(filename)718 if not os.access(filepath, os.R_OK):719 raise ValueError('No such file: "%s"' % (filename,))720 if usualSuspects == None:721 procFds = glob.glob("/proc/[1-9][0-9][0-9]*/fd/*")722 else:723 procFds = []724 for pid in usualSuspects:725 procFds.extend(glob.glob("/proc/%s/fd/*" % (pid,)))726 for symlink in procFds:727 try:728 if os.path.realpath(symlink) == filepath:729 return int(symlink.split('/')[2])730 except OSError:731 pass732def findWestonScreenshotFilenames():733 # find weston cwd734 dirs = []735 for exe in glob.glob("/proc/[1-9][0-9][0-9]*/exe"):736 try:737 if os.path.realpath(exe) == "/usr/bin/weston":738 dirs.append(os.path.realpath(os.path.dirname(exe) + "/cwd"))739 except OSError:740 pass741 return [d + "/wayland-screenshot.png" for d in sorted(set(dirs))]742if g_Xavailable:743 takeScreenshot = takeScreenshotOnX744else:745 takeScreenshot = takeScreenshotOnWeston746def shellSOE(command, asyncStatus, asyncOut, asyncError, usePty):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful