![](https://raw.githubusercontent.com/moorejacob2017/Stricture/master/logos/stricture_logo_white_long.png)
Stricture is a python package that provides classes and a CLI tool for easy scheduling, automating, and managing of specific operations.
Currently, Stricture provides 5 classes:
- `Schedule` - Used to determine if the current date and time falls within a user defined schedule. Provides a variety of functionality that promotes human readable schedules, ranging from broad week-to-week bases, to granular date and time ranges.
- `Stricture` - A class used to abstract the idea of starting and stopping a specified operation or process based on a `Schedule` or other condition. User supplied functions are orchestrated by a templated function to launch, pause, resume, and check conditions for an operation.
- `ProcessStricture` - A differentiated `Stricture` used to start and stop local system processes given a `Schedule` or other condition.
- `Command` - A basic utility for easily running terminal commands and collecting their output.
- `CommandStricture` - A differentiated `Stricture` used to start and stop terminal commands (using the `Command` Class) given a `Schedule` or other condition.
Please review the [Stricture Documentation](https://github.com/moorejacob2017/Stricture/#documentation) for more information.
## Stricture CLI Tool
The Stricture Python Package ships with a CLI tool for starting and stopping a process or command given a schedule. This is done by sending a `SIGSTOP` to the process when the date and time are outside the schedule and a `SIGCONT` when the date and time are in the schedule.
```
usage: stricture [-h] -s SCHEDULE [-q] [-o] [-e] (-p PID | -c COMMAND)
Apply a stricture to a command or process to execute based on a given schedule.
options:
-h, --help show this help message and exit
-s SCHEDULE, --schedule SCHEDULE
Schedule file in JSON or YAML format.
-q, --quiet Quiet mode. No stricture logging output.
-o, --stdout Print STDOUT of command (--command only).
-e, --stderr Print STDERR of command (--command only).
-p PID, --pid PID Process ID. Required if no command is provided.
-c COMMAND, --command COMMAND
Command to execute. Required if no PID is provided.
Examples:
stricture -s my_schedule.yml -c "ping -c 1000 192.168.1.1"
stricture -s my_schedule.yml -qoe -c "./my_script.sh"
stricture -s my_schedule.json -p 13019
```
## Making a schedule in YAML
`Schedules` have many different ways to be instantiated and initialized. One of the easiest ways to create a schedule is to import it from a yaml file with `from_yaml_file`. Below is an explaination of how to format a schedule with yaml.
```yaml
# Days are classified into 1 of 3 modes: restricted, unrestricted, and prohibited.
# restricted - Days are considered in schedule, but only for the
# time range defined by start_time and stop_time.
# unrestricted - All 24 hours of the day are considered in the schedule.
# prohibited - All 24 hours of the day are considered out of schedule.
# assume:
# The mode to use for days of the week that are not listed in the schedule.
# Can either be unrestricted, restricted, or prohibited.
# Defaults to restricted when not set.
assume: "restricted"
# timezone:
# The timezone to use when checking the schedule.
# Uses pytz timezones (Olson Timezone IDs).
# Defaults to the system timezone when not set.
timezone: "US/Central"
# start_time:
# Defines what time the schedule range starts for every restricted day.
# Uses 24-Hour Format.
# Defaults to 00:00 when not set.
start_time: "09:30"
# stop_time:
# Defines what time the schedule range stops for every restricted day.
# Uses 24-Hour Format.
# Defaults to 00:00 when not set.
stop_time: "17:00"
# restricted_days:
# A list of days of the week that should
# have the start_time and stop_time applied to.
restricted_days:
- "Monday"
- "Tuesday"
- "Wednesday"
- "Thursday"
- "Friday"
# unrestricted_days:
# A list of days of the week that should
# have all 24 hours considered as in the schedule.
unrestricted_days:
- "Saturday"
# prohibited_days:
# A list of days of the week that should
# have all 24 hours considered as out of the schedule.
prohibited_days:
- "Sunday"
# specific_dates:
# A list of specific date ranges that overides the main
# start_time, stop_time, and mode.
# Useful for special occasions or for more granular
# control.
# mode - The mode to use for the range.
# start_date - The start of the date range (YYYY-MM-DD format).
# stop_date - The end of the date range (inclusively) (YYYY-MM-DD format).
# start_time - The start_time to use when the mode for the range is restricted.
# stop_time - The stop_time to use when the mode for the range is restricted.
specific_dates:
- mode: "unrestricted"
start_date: "2024-12-12"
stop_date: "2024-12-23"
- mode: "prohibited"
start_date: "2024-12-24"
stop_date: "2024-12-26"
- mode: "restricted"
start_date: "2024-12-27"
stop_date: "2024-12-31"
start_time: "18:00"
stop_time: "08:30"
```
Raw data
{
"_id": null,
"home_page": "https://github.com/moorejacob2017/Stricture/",
"name": "Stricture",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "automation task job management date time cron schedule scheduling bash process pid command bash week month",
"author": "Jacob Moore",
"author_email": "moorejacob2017@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6d/fb/96686e7c61bdd567a4ecd38a3e57dd47dfad23058728981ffb8135265aae/Stricture-1.0.8.tar.gz",
"platform": null,
"description": "![](https://raw.githubusercontent.com/moorejacob2017/Stricture/master/logos/stricture_logo_white_long.png)\n\nStricture is a python package that provides classes and a CLI tool for easy scheduling, automating, and managing of specific operations.\n\nCurrently, Stricture provides 5 classes:\n- `Schedule` - Used to determine if the current date and time falls within a user defined schedule. Provides a variety of functionality that promotes human readable schedules, ranging from broad week-to-week bases, to granular date and time ranges.\n- `Stricture` - A class used to abstract the idea of starting and stopping a specified operation or process based on a `Schedule` or other condition. User supplied functions are orchestrated by a templated function to launch, pause, resume, and check conditions for an operation.\n- `ProcessStricture` - A differentiated `Stricture` used to start and stop local system processes given a `Schedule` or other condition.\n- `Command` - A basic utility for easily running terminal commands and collecting their output.\n- `CommandStricture` - A differentiated `Stricture` used to start and stop terminal commands (using the `Command` Class) given a `Schedule` or other condition.\n\nPlease review the [Stricture Documentation](https://github.com/moorejacob2017/Stricture/#documentation) for more information.\n\n\n## Stricture CLI Tool\n\nThe Stricture Python Package ships with a CLI tool for starting and stopping a process or command given a schedule. This is done by sending a `SIGSTOP` to the process when the date and time are outside the schedule and a `SIGCONT` when the date and time are in the schedule.\n\n```\nusage: stricture [-h] -s SCHEDULE [-q] [-o] [-e] (-p PID | -c COMMAND)\n\nApply a stricture to a command or process to execute based on a given schedule.\n\noptions:\n -h, --help show this help message and exit\n -s SCHEDULE, --schedule SCHEDULE\n Schedule file in JSON or YAML format.\n -q, --quiet Quiet mode. No stricture logging output.\n -o, --stdout Print STDOUT of command (--command only).\n -e, --stderr Print STDERR of command (--command only).\n -p PID, --pid PID Process ID. Required if no command is provided.\n -c COMMAND, --command COMMAND\n Command to execute. Required if no PID is provided.\n\nExamples:\n stricture -s my_schedule.yml -c \"ping -c 1000 192.168.1.1\"\n stricture -s my_schedule.yml -qoe -c \"./my_script.sh\"\n stricture -s my_schedule.json -p 13019\n```\n\n\n## Making a schedule in YAML\n`Schedules` have many different ways to be instantiated and initialized. One of the easiest ways to create a schedule is to import it from a yaml file with `from_yaml_file`. Below is an explaination of how to format a schedule with yaml.\n```yaml\n# Days are classified into 1 of 3 modes: restricted, unrestricted, and prohibited.\n# restricted - Days are considered in schedule, but only for the\n# time range defined by start_time and stop_time.\n# unrestricted - All 24 hours of the day are considered in the schedule.\n# prohibited - All 24 hours of the day are considered out of schedule.\n\n# assume:\n# The mode to use for days of the week that are not listed in the schedule.\n# Can either be unrestricted, restricted, or prohibited.\n# Defaults to restricted when not set.\nassume: \"restricted\"\n\n# timezone:\n# The timezone to use when checking the schedule.\n# Uses pytz timezones (Olson Timezone IDs).\n# Defaults to the system timezone when not set.\ntimezone: \"US/Central\"\n\n# start_time:\n# Defines what time the schedule range starts for every restricted day.\n# Uses 24-Hour Format.\n# Defaults to 00:00 when not set.\nstart_time: \"09:30\"\n\n# stop_time:\n# Defines what time the schedule range stops for every restricted day.\n# Uses 24-Hour Format.\n# Defaults to 00:00 when not set.\nstop_time: \"17:00\"\n\n# restricted_days:\n# A list of days of the week that should\n# have the start_time and stop_time applied to.\nrestricted_days:\n - \"Monday\"\n - \"Tuesday\"\n - \"Wednesday\"\n - \"Thursday\"\n - \"Friday\"\n\n# unrestricted_days:\n# A list of days of the week that should \n# have all 24 hours considered as in the schedule.\nunrestricted_days:\n - \"Saturday\"\n\n# prohibited_days:\n# A list of days of the week that should \n# have all 24 hours considered as out of the schedule.\nprohibited_days:\n - \"Sunday\"\n\n# specific_dates:\n# A list of specific date ranges that overides the main\n# start_time, stop_time, and mode.\n# Useful for special occasions or for more granular\n# control.\n# mode - The mode to use for the range.\n# start_date - The start of the date range (YYYY-MM-DD format).\n# stop_date - The end of the date range (inclusively) (YYYY-MM-DD format).\n# start_time - The start_time to use when the mode for the range is restricted.\n# stop_time - The stop_time to use when the mode for the range is restricted.\nspecific_dates:\n - mode: \"unrestricted\"\n start_date: \"2024-12-12\"\n stop_date: \"2024-12-23\"\n - mode: \"prohibited\"\n start_date: \"2024-12-24\"\n stop_date: \"2024-12-26\"\n - mode: \"restricted\"\n start_date: \"2024-12-27\"\n stop_date: \"2024-12-31\"\n start_time: \"18:00\"\n stop_time: \"08:30\"\n```\n\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Stricture is a python package that provides classes and a CLI tool for easy scheduling, automating, and managing of specific operations.",
"version": "1.0.8",
"project_urls": {
"Homepage": "https://github.com/moorejacob2017/Stricture/"
},
"split_keywords": [
"automation",
"task",
"job",
"management",
"date",
"time",
"cron",
"schedule",
"scheduling",
"bash",
"process",
"pid",
"command",
"bash",
"week",
"month"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "789f3f1934f5c8d6e6fc775a4bc54aa36334de3c3565501e9ff5033a10d513dc",
"md5": "fa20a3137d580d99168ccbcdadbbb24f",
"sha256": "64df819487776bd5d05005327e4a53d7af818cb65a8069fd5a95cca221bab28c"
},
"downloads": -1,
"filename": "Stricture-1.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fa20a3137d580d99168ccbcdadbbb24f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 15546,
"upload_time": "2024-05-09T04:01:14",
"upload_time_iso_8601": "2024-05-09T04:01:14.522325Z",
"url": "https://files.pythonhosted.org/packages/78/9f/3f1934f5c8d6e6fc775a4bc54aa36334de3c3565501e9ff5033a10d513dc/Stricture-1.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6dfb96686e7c61bdd567a4ecd38a3e57dd47dfad23058728981ffb8135265aae",
"md5": "40d90394a77a94cee8d77fc07e41a0ae",
"sha256": "1f070e54a5691fd0f2e45ec0555ad9f378fc03adb86563b24ab787b5f7caf164"
},
"downloads": -1,
"filename": "Stricture-1.0.8.tar.gz",
"has_sig": false,
"md5_digest": "40d90394a77a94cee8d77fc07e41a0ae",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 13221,
"upload_time": "2024-05-09T04:01:16",
"upload_time_iso_8601": "2024-05-09T04:01:16.164479Z",
"url": "https://files.pythonhosted.org/packages/6d/fb/96686e7c61bdd567a4ecd38a3e57dd47dfad23058728981ffb8135265aae/Stricture-1.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-09 04:01:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "moorejacob2017",
"github_project": "Stricture",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "stricture"
}