| 27 | |
| 28 | |
| 29 | class Executor(BaseObject): |
| 30 | |
| 31 | schema = ExecutorSchema() |
| 32 | display_schema = ExecutorSchema() |
| 33 | |
| 34 | RESERVED = dict(payload='#{payload}') |
| 35 | |
| 36 | HOOKS = dict() |
| 37 | |
| 38 | @classmethod |
| 39 | def is_global_variable(cls, variable): |
| 40 | return variable in cls.RESERVED |
| 41 | |
| 42 | @property |
| 43 | def test(self): |
| 44 | """Get command with app property variables replaced""" |
| 45 | return self.decode_bytes(self.replace_app_props(self.encode_string(self.command))) |
| 46 | |
| 47 | def __init__(self, name, platform, command=None, code=None, language=None, build_target=None, |
| 48 | payloads=None, uploads=None, timeout=60, parsers=None, cleanup=None, variations=None, |
| 49 | additional_info=None, **kwargs): |
| 50 | super().__init__() |
| 51 | self.name = name |
| 52 | self.platform = platform.lower() |
| 53 | |
| 54 | self.command = command |
| 55 | self.code = code |
| 56 | self.language = language |
| 57 | self.build_target = build_target |
| 58 | |
| 59 | self.payloads = payloads if payloads else [] |
| 60 | self.uploads = uploads if uploads else [] |
| 61 | |
| 62 | self.timeout = timeout |
| 63 | self.parsers = parsers if parsers else [] |
| 64 | |
| 65 | if not cleanup: |
| 66 | self.cleanup = [] |
| 67 | elif isinstance(cleanup, str): |
| 68 | self.cleanup = [cleanup] |
| 69 | else: |
| 70 | self.cleanup = cleanup |
| 71 | |
| 72 | self.variations = get_variations(variations) |
| 73 | |
| 74 | self.additional_info = additional_info or dict() |
| 75 | self.additional_info.update(**kwargs) |
| 76 | |
| 77 | def __getattr__(self, item): |
| 78 | try: |
| 79 | return super().__getattribute__('additional_info')[item] |
| 80 | except KeyError: |
| 81 | raise AttributeError(item) |
| 82 | |
| 83 | def replace_cleanup(self, command, payload): |
| 84 | return command.replace(self.RESERVED['payload'], payload) |
| 85 | |
| 86 | |