summaryrefslogtreecommitdiff
path: root/src/bin/exactness/exactness_record.in
blob: 377d46519947750c13053f9932667367907b688a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python3

import argparse
import subprocess
import os

parser = argparse.ArgumentParser(description='A scenario recorder for EFL-based applications.\n\n'
  'This records all actions the user performs on an EFL application (like keystrokes\n'
  'and mouse clicks) and stores them on a file.\n'
  'Later on, the `exactness` or `exactness_play` commands can be used to play\n'
  'back these actions and obtain screenshots.\n'
  '\n'
  'While running this application, use the following keys to control the process:\n'
  '\tF1 - Request stabilization.\n'
  '\tF2 - Request screenshot.\n'
  '\tF3 - Request to save the scenario.\n'
  '\n'
  'Note: If you don\'t press F3 at least once, no output file will be generated.',
  formatter_class=argparse.RawDescriptionHelpFormatter,
  epilog='Example:\n'
  'exactness_record -t my_app.exu -- my_app --app --arguments')
parser.add_argument('app', metavar='app', help='The app to run. You can also pass environment variables here. '
  'Use a -- if you need to provide arguments to the app.',
  type=str, nargs='*')
parser.add_argument('-t', '--tests', metavar='tests', help='Name of the file where to store the test. '
  'It is recommended to use the `.exu` extension.', type=str)
parser.add_argument('-f', '--fontsdir', metavar='fontsdir', help='Directory of the fonts that should be used.',
  type=str)
parser.add_argument('-L', '--license', help='Print license information and exit.', action='store_true')
parser.add_argument('-C', '--copyright', help='Print copyright information and exit.', action='store_true')
parser.add_argument('-V', '--version', help='Print version information and exit.', action='store_true')

G = parser.parse_args()

if G.license:
  print("BSD.")
  exit(0)

if G.copyright:
  print("(C) 2017-2020 Enlightenment.")
  exit(0)

if G.version:
  print(@VERSION@)
  exit(0)

spawn_env = os.environ.copy()
spawn_env["LD_PRELOAD"] = @EXACTNESS_RECORD_PRELOAD_PATH@

if G.tests != None:
  spawn_env["EXACTNESS_DEST"] = G.tests
else:
  print("Tests dir must be passed!")
  exit(-1)

if G.fontsdir != None:
  spawn_env["EXACTNESS_FONTS_DIR"] = G.fontsdir

passed_all_the_env_vars = False
app = []

for argument in G.app:
  if '=' not in argument:
    passed_all_the_env_vars = True
  else:
    if passed_all_the_env_vars:
      print("Error, env vars can only be specified at the beginning of the app call line")
      exit(-1)
    split_env_var = argument.split('=')
    spawn_env[split_env_var[0]] = split_env_var[1]

  if passed_all_the_env_vars:
    app.append(argument)

recorder = subprocess.Popen(app, env=spawn_env)
recorder.wait()