Created
August 14, 2013 14:17
-
-
Save chadcatlett/6231473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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