Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jamftf/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def HCLs(self):
"""generates hcl as a string"""
out = ""
hcld = self.HCLd()
for i in hcld.items():
for i in hcld.values():
out += i + "\n"

return out
Expand Down
16 changes: 9 additions & 7 deletions jamftf/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ def options(self):
"""returns options from self"""
return self.out


def add(self, key, value):
"""allows method bound addition of options"""
if key not in VALID_RESOURCE_CONFIG_KEYS:
raise DataError(f"attemped to add invalid config key: {key}")

self.out[key] = value


def from_json(self, data: dict):
"""generates options from dict"""
self.out = data
Expand All @@ -42,7 +44,7 @@ def __init__(
opts: dict,
validate: bool,
logger: Logger,
exclude_ids: list[int] = []
exclude_ids: list[int] | None = None
):

self.opts = opts
Expand Down Expand Up @@ -72,7 +74,7 @@ def apply(self, data: dict):

data = options_master[o](data)

self.lg.info(f"{o} set for {self.resource_type}")
self.lg.debug(f"{o} set for {self.resource_type}")

if self.exclude_ids:
data = self._exclude_ids(data)
Expand All @@ -86,15 +88,15 @@ def apply(self, data: dict):
def _validation(self, data):
"""_validation is a parent func for running data validation functions"""

self.lg.debug("validating data...")
self.lg.info("validating data...")

self._check_illegal_chars(data)
self._check_duplicates(data)


def _exclude_ids(self, data: dict) -> dict:
"""removes any IDs from the data which have been specifid to be excluded"""
self.lg.debug("excluding ids... %s", self.exclude_ids)
self.lg.info("excluding ids... %s", self.exclude_ids)

to_delete = []
for i in data:
Expand All @@ -119,7 +121,7 @@ def _exclude_ids(self, data: dict) -> dict:

def _use_resource_type_as_name(self, data: dict) -> dict:
"""change the names of all resources held in data to resource_name.XX"""
self.lg.debug("amending resource names...")
self.lg.info("amending resource names...")

counter = 0
for i in data:
Expand All @@ -131,7 +133,7 @@ def _use_resource_type_as_name(self, data: dict) -> dict:

def _check_illegal_chars(self, data: dict):
"""sweeps resource names for chars invalid in HCL"""
self.lg.debug(f"checking for illegal chars: {ILLEGAL_NAME_CHARS}")
self.lg.info(f"checking for illegal chars: {ILLEGAL_NAME_CHARS}")

for i in data.values():
for c in i["name"]:
Expand All @@ -141,7 +143,7 @@ def _check_illegal_chars(self, data: dict):

def _check_duplicates(self, data: dict):
"""iterates through all resource names ensuring no duplicates"""
self.lg.debug("checking for duplicates")
self.lg.info("checking for duplicates")


keys = {}
Expand Down
8 changes: 6 additions & 2 deletions jamftf/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(
validate: bool = True,
client: jamfpy.JamfTenant = None,
debug: bool = False,
exclude: list[int] = list
exclude: list[int] = None
):

self._validate_resource_type()
Expand Down Expand Up @@ -116,13 +116,17 @@ def _get(self):
# Public

def set_debug(self, debug: bool):
"""overrides log level to debug for all handlers"""
"""overrides log level to debug for all handlers, including the applicator"""
level = self._init_log_level(debug)

self.lg.setLevel(level)
for i in self.lg.handlers:
i.setLevel(level)

self.applicator.lg.setLevel(level)
for i in self.applicator.lg.handlers:
i.setLevel(level)

self.lg.info("log level has been overridden to: %s", self.lg.level)


Expand Down
11 changes: 11 additions & 0 deletions modupdate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
jamfpy_target_version=dev

########
jamfpy_url="https://github.com/thejoeker12/jamfpy"

jamfpy_pip_target="git+$jamfpy_url@$jamfpy_target_version"

# pip uninstall jamfpy --no-input

# JAMF PY
pip install --no-cache-dir --upgrade --force-reinstall $jamfpy_pip_target
Loading