ADD: --force flag and managed it in the check diferences functions
This commit is contained in:
parent
395617fe40
commit
a85b324102
2 changed files with 12 additions and 2 deletions
|
@ -23,6 +23,7 @@ from .conf import (
|
||||||
NTFY_URL,
|
NTFY_URL,
|
||||||
NTFY_TOPIC,
|
NTFY_TOPIC,
|
||||||
NTFY_ACCESS_TOKEN,
|
NTFY_ACCESS_TOKEN,
|
||||||
|
FORCE_FLAG
|
||||||
)
|
)
|
||||||
from .exceptions import ScriptAlreadyRunningError
|
from .exceptions import ScriptAlreadyRunningError
|
||||||
from .logger import setup_logging
|
from .logger import setup_logging
|
||||||
|
@ -134,7 +135,7 @@ def find_changed(all_groups, level_dict, recent_run):
|
||||||
changed_users = set()
|
changed_users = set()
|
||||||
|
|
||||||
for group in level_dict.keys():
|
for group in level_dict.keys():
|
||||||
if check_group_changes(group, level_dict, recent_run, set()):
|
if (FORCE_FLAG or check_group_changes(group, level_dict, recent_run, set())):
|
||||||
changed_groups.add(group)
|
changed_groups.add(group)
|
||||||
logger.debug(f"Group '{group.name}' has changed", extra={
|
logger.debug(f"Group '{group.name}' has changed", extra={
|
||||||
'group': group.__dict__,
|
'group': group.__dict__,
|
||||||
|
@ -144,7 +145,7 @@ def find_changed(all_groups, level_dict, recent_run):
|
||||||
for group, members in all_groups.items():
|
for group, members in all_groups.items():
|
||||||
for user in members:
|
for user in members:
|
||||||
if isinstance(user, ADUser) and not is_user_disabled(
|
if isinstance(user, ADUser) and not is_user_disabled(
|
||||||
user) and has_changed(user, recent_run):
|
user) and (FORCE_FLAG or has_changed(user, recent_run)):
|
||||||
changed_users.add(user)
|
changed_users.add(user)
|
||||||
logger.debug(f"User '{user.name}' has changed", extra={
|
logger.debug(f"User '{user.name}' has changed", extra={
|
||||||
'user': user.__dict__,
|
'user': user.__dict__,
|
||||||
|
|
|
@ -165,6 +165,12 @@ try:
|
||||||
help="Create a cron job",
|
help="Create a cron job",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
argparser.add_argument(
|
||||||
|
"--force",
|
||||||
|
action="store_true",
|
||||||
|
help="Forces the script execution skipping recent run checking",
|
||||||
|
)
|
||||||
|
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
|
|
||||||
# If a path to a config file was provided
|
# If a path to a config file was provided
|
||||||
|
@ -188,6 +194,9 @@ try:
|
||||||
create_cron_job(cron_job, config_file)
|
create_cron_job(cron_job, config_file)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
# Saving the force flag
|
||||||
|
FORCE_FLAG=args.force
|
||||||
|
|
||||||
# Load configuration file
|
# Load configuration file
|
||||||
config = TOMLFile(config_file).read()
|
config = TOMLFile(config_file).read()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue