def foxyproxy(ip, port): folder = podium.get_firefox_profile_folder() input = folder + '/' + XML if not os.path.exists(input): print >> sys.stderr, "Error: {file} doesn't exist".format(file=input) # else with open(input) as f: content = f.read() root = etree.fromstring(content) manualconf = root.xpath('/foxyproxy/proxies[1]/proxy[1]/manualconf[1]')[0] manualconf.attrib['host'] = ip manualconf.attrib['port'] = port # os.rename(input, folder + '/' + BAK) # tree = etree.ElementTree(root) if os.path.exists(folder + '/' + BAK): tree.write(input, pretty_print=True, xml_declaration=True) print '# written to', XML print '# please restart Firefox'
def foxyproxy(ip, port): folder = podium.get_firefox_profile_folder() input = folder + '/' + XML if not os.path.exists(input): print >>sys.stderr, "Error: {file} doesn't exist".format(file=input) # else with open(input) as f: content = f.read() root = etree.fromstring(content) manualconf = root.xpath('/foxyproxy/proxies[1]/proxy[1]/manualconf[1]')[0] manualconf.attrib['host'] = ip manualconf.attrib['port'] = port # os.rename(input, folder + '/' + BAK) # tree = etree.ElementTree(root) if os.path.exists(folder + '/' + BAK): tree.write(input, pretty_print=True, xml_declaration=True) print '# written to', XML print '# please restart Firefox'
def test_get_firefox_profile_folder(): result = podium.get_firefox_profile_folder() assert re.search('.*/.{8}\.default$', result)