Skip to content

Instantly share code, notes, and snippets.

@rmanly
rmanly / download_file_via_munkilib.py
Last active August 29, 2015 14:15
uses munkilib's fetch to dl a file via gurl via NSURL
import sys
sys.path.append('/usr/local/munki/munkilib')
import fetch
fetch.get_url('http://www.irs.gov/pub/irs-prior/f1040ez--2014.pdf', '/Users/ryan/Desktop/1040ez.pdf')
fetch.get_url('https://www.gnu.org/software/wget/index.html', '/Users/ryan/Desktop/index.html')
from munkilib import gurl
def run_connection(options):
connection = gurl.Gurl.alloc().initWithOptions_(options)
percent_complete = -1
bytes_received = 0
connection.start()
try:
while not connection.isDone():
if connection.destination_path:
@pudquick
pudquick / lockscreen.py
Created December 23, 2015 19:12
Programmatically immediately lock the screen of a Mac running OS X, regardless of security settings, screensaver settings, or Fast User Switch settings
from ctypes import CDLL
loginPF = CDLL('/System/Library/PrivateFrameworks/login.framework/Versions/Current/login')
result = loginPF.SACLockScreenImmediate()
@gregneagle
gregneagle / munki_do.py
Created September 4, 2016 05:51
munki_do.py
#!/usr/bin/python
# encoding: utf-8
#
# Copyright 2009-2016 Greg Neagle.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0