<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals , absolute_import <EOL> from __future__ import print_function , division <EOL> import logging <EOL> from os import getuid , devnull , makedirs <EOL> from shlex import split as shsplit <EOL> from subprocess import call , check_call <EOL> log = logging . getLogger ( __name__ ) <EOL> def ensure_dir ( path ) : <EOL> """<STR_LIT>""" <EOL> import errno <EOL> EEXIST = getattr ( errno , '<STR_LIT>' , <NUM_LIT:0> ) <EOL> try : <EOL> makedirs ( path ) <EOL> except OSError as err : <EOL> if err . errno not in [ <NUM_LIT:0> , EEXIST ] : <EOL> raise <EOL> IFNAMSIZ = <NUM_LIT:15> <EOL> """<STR_LIT>""" <EOL> def tmp_iface ( ) : <EOL> """<STR_LIT>""" <EOL> import random <EOL> import string <EOL> return '<STR_LIT>' . join ( <EOL> random . choice ( string . ascii_lowercase ) <EOL> for _ in range ( IFNAMSIZ ) <EOL> ) <EOL> def cmd_prefix ( ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( cmd_prefix , '<STR_LIT>' ) : <EOL> return cmd_prefix . prefix <EOL> if getuid ( ) == <NUM_LIT:0> : <EOL> raise RuntimeError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> with open ( devnull , '<STR_LIT:w>' ) as f : <EOL> cmd = shsplit ( '<STR_LIT>' ) <EOL> if call ( cmd , stdout = f , stderr = f ) != <NUM_LIT:0> : <EOL> raise RuntimeError ( <EOL> '<STR_LIT>' <EOL> ) <EOL> cmd_prefix . prefix = '<STR_LIT>' <EOL> return cmd_prefix . prefix <EOL> def privileged_cmd ( commands_tpl , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> prefix = cmd_prefix ( ) <EOL> for command in commands_tpl . format ( ** kwargs ) . splitlines ( ) : <EOL> command = command . strip ( ) <EOL> if command : <EOL> check_call ( shsplit ( prefix + command ) ) <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] </s>
