Closed grahamgilbert closed 6 years ago
@clburlison
>>> import os
>>> ServerURL = 'http://localhost:8000'
>>> os.path.join(ServerURL, 'profiles/submit', '')
'http://localhost:8000/profiles/submit/'
>>> os.path.join(ServerURL, 'profiles/submit')
'http://localhost:8000/profiles/submit'
@clburlison Djangofy your URLs with a trailing ''!
Although I'm sure there is probably a better URL-specific library we could use, but meh, it works and is in stdlib.
This looks good, but I have one suggestion that I think is pretty slick:
Tempfile has a context manager... like so:
with tempfile.TemporaryDirectory() as temp_dir:
profile_out = os.path.join(temp_dir, 'profiles.plist')
cmd = ['/usr/bin/profiles', '-C', '-o', profile_out]
try:
subprocess.call(cmd, stdout=devnull)
except OSError:
munkicommon.display_debug2("Couldn't output profiles.")
return
profiles, _ = utils.get_file_and_hash(profile_out)
This way you don't have to worry about cleaning it up or anything
As per slack, looks like this isn't in Python 2. Gonna merge unless anyone has any objections?
Just send up the output of
profiles -C -o /sometemp.plist
. The real smarts will be in the server. PTAL @sheagcraig