Skip to content

Instantly share code, notes, and snippets.

@chadcatlett
Created August 14, 2013 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadcatlett/6231473 to your computer and use it in GitHub Desktop.
Save chadcatlett/6231473 to your computer and use it in GitHub Desktop.
def disable_proxy(kick_token):
path = '/etc/sysconfig/rhn/up2date'
mode = 0600
tempfd, temp_path = mkstemp()
try:
new_file = open(temp_path, 'w')
old_file = open(path)
except (IOError, OSError) as err:
klog(kick_token, 'Problem disabling proxy for RHN <%s>.' % str(err))
return False
for line in old_file.readlines():
if 'enableProxy=1' in line:
line = line.replace('1', '0')
if 'httpProxy=' in line:
if line.split('=')[1]:
line = line.replace(line.split('=')[1], '')
new_file.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment