def download(filename: str) -> None: """ Downloads a file from the git repo and saves it to the local directory. :param filename: The filename to download from the repo. :type filename: `str` """ url = 'https://raw.githubusercontent.com/threadreaper/autodomme/master/' r = PoolManager().request('GET', url + filename, preload_content=False) with open(filename, 'wb') as out: while True: data = r.read(512) if not data: break out.write(data) r.release_conn()
def generate(salt): if not salt: return None render(config_file, 'salt-minion/minion.tmpl', salt, user=salt['user'], group=salt['group']) if not os.path.exists(master_keyfile): if salt['master_key']: req = PoolManager().request('GET', salt['master_key'], preload_content=False) with open(master_keyfile, 'wb') as f: while True: data = req.read(1024) if not data: break f.write(data) req.release_conn() chown(master_keyfile, salt['user'], salt['group']) return None