1#!/usr/local/bin/python3.8 2 3import argparse 4import subprocess 5import os 6 7parser = argparse.ArgumentParser(description='A scenario recorder for EFL-based applications.\n\n' 8 'This records all actions the user performs on an EFL application (like keystrokes\n' 9 'and mouse clicks) and stores them on a file.\n' 10 'Later on, the `exactness` or `exactness_play` commands can be used to play\n' 11 'back these actions and obtain screenshots.\n' 12 '\n' 13 'While running this application, use the following keys to control the process:\n' 14 '\tF1 - Request stabilization.\n' 15 '\tF2 - Request screenshot.\n' 16 '\tF3 - Request to save the scenario.\n' 17 '\n' 18 'Note: If you don\'t press F3 at least once, no output file will be generated.', 19 formatter_class=argparse.RawDescriptionHelpFormatter, 20 epilog='Example:\n' 21 'exactness_record -t my_app.exu -- my_app --app --arguments') 22parser.add_argument('app', metavar='app', help='The app to run. You can also pass environment variables here. ' 23 'Use a -- if you need to provide arguments to the app.', 24 type=str, nargs='*') 25parser.add_argument('-t', '--tests', metavar='tests', help='Name of the file where to store the test. ' 26 'It is recommended to use the `.exu` extension.', type=str) 27parser.add_argument('-f', '--fontsdir', metavar='fontsdir', help='Directory of the fonts that should be used.', 28 type=str) 29parser.add_argument('-L', '--license', help='Print license information and exit.', action='store_true') 30parser.add_argument('-C', '--copyright', help='Print copyright information and exit.', action='store_true') 31parser.add_argument('-V', '--version', help='Print version information and exit.', action='store_true') 32 33G = parser.parse_args() 34 35if G.license: 36 print("BSD.") 37 exit(0) 38 39if G.copyright: 40 print("(C) 2017-2020 Enlightenment.") 41 exit(0) 42 43if G.version: 44 print(@VERSION@) 45 exit(0) 46 47spawn_env = os.environ.copy() 48spawn_env["LD_PRELOAD"] = @EXACTNESS_RECORD_PRELOAD_PATH@ 49 50if G.tests != None: 51 spawn_env["EXACTNESS_DEST"] = G.tests 52else: 53 print("Tests dir must be passed!") 54 exit(-1) 55 56if G.fontsdir != None: 57 spawn_env["EXACTNESS_FONTS_DIR"] = G.fontsdir 58 59passed_all_the_env_vars = False 60app = [] 61 62for argument in G.app: 63 if '=' not in argument: 64 passed_all_the_env_vars = True 65 else: 66 if passed_all_the_env_vars: 67 print("Error, env vars can only be specified at the beginning of the app call line") 68 exit(-1) 69 split_env_var = argument.split('=') 70 spawn_env[split_env_var[0]] = split_env_var[1] 71 72 if passed_all_the_env_vars: 73 app.append(argument) 74 75recorder = subprocess.Popen(app, env=spawn_env) 76recorder.wait() 77