Skip to content

Commit

Permalink
add sleep processor
Browse files Browse the repository at this point in the history
  • Loading branch information
jgstew committed Nov 29, 2023
1 parent c34f10c commit 0eb07f4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
48 changes: 48 additions & 0 deletions SharedProcessors/Sleep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/local/autopkg/python
#
# James Stewart @JGStew - 2021
#
# Related:
# - https://github.com/jgstew/bigfix_prefetch/blob/master/prefetch_from_dictionary.py
#
"""See docstring for Sleep class"""

import time

from autopkglib import ( # pylint: disable=import-error,wrong-import-position,unused-import
Processor,
ProcessorError,
)

__all__ = ["Sleep"]


class Sleep(Processor): # pylint: disable=invalid-name
"""Does nothing but delay autopkg for x seconds"""

description = __doc__
input_variables = {
"sleep_seconds": {
"required": False,
"default": 2,
"description": "seconds to sleep",
},
}
output_variables = {}
__doc__ = description

def main(self):
"""Execution starts here"""

sleep_seconds = int(self.env.get("sleep_seconds", 2))

self.output(f"Pausing Execution for {sleep_seconds} seconds")

time.sleep(sleep_seconds)

self.output(f"Resuming Execution after {sleep_seconds} seconds")


if __name__ == "__main__":
PROCESSOR = Sleep()
PROCESSOR.execute_shell()
10 changes: 10 additions & 0 deletions Test-Recipes/Sleep.test.recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
Description: Test Sleep Processor
Identifier: com.github.jgstew.test.Sleep
Input:
NAME: SleepTest
MinimumVersion: "2.3"
Process:
- Processor: com.github.jgstew.SharedProcessors/Sleep
Arguments:
sleep_seconds: "5"

0 comments on commit 0eb07f4

Please sign in to comment.