<s> from os . path import abspath , join as path_join <EOL> from random import choice <EOL> from string import ascii_lowercase <EOL> import pyautogui as ag <EOL> from robot . libraries . BuiltIn import BuiltIn , RobotNotRunningError <EOL> from robot . api import logger as LOGGER <EOL> from . . errors import ScreenshotFolderException <EOL> class _Screenshot ( object ) : <EOL> def _make_up_filename ( self ) : <EOL> try : <EOL> path = BuiltIn ( ) . get_variable_value ( '<STR_LIT>' ) <EOL> path = '<STR_LIT>' % path . replace ( '<STR_LIT:U+0020>' , '<STR_LIT>' ) <EOL> except RobotNotRunningError : <EOL> LOGGER . info ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> path = '<STR_LIT>' <EOL> path = '<STR_LIT>' % ( path , self . screenshot_counter ) <EOL> self . screenshot_counter += <NUM_LIT:1> <EOL> return path <EOL> def take_a_screenshot ( self ) : <EOL> '''<STR_LIT>''' <EOL> target_dir = self . screenshot_folder if self . screenshot_folder else '<STR_LIT>' <EOL> if not isinstance ( target_dir , basestring ) : <EOL> raise ScreenshotFolderException ( '<STR_LIT>' <EOL> '<STR_LIT>' % target_dir ) <EOL> path = self . _make_up_filename ( ) <EOL> path = abspath ( path_join ( target_dir , path ) ) <EOL> LOGGER . info ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( path ) , html = True ) <EOL> ag . screenshot ( path ) </s>
