def write_hosts_file(config, device): new_hosts = make_hosts_file(config, moznetwork.get_ip()) current_hosts = device.get_file("/etc/hosts") if new_hosts == current_hosts: return hosts_fd, hosts_path = tempfile.mkstemp() try: with os.fdopen(hosts_fd, "w") as f: f.write(new_hosts) device.remount() device.push(hosts_path, "/etc/hosts") finally: os.remove(hosts_path)
def __init__(self, browser, server_config, binary=None, timeout_multiplier=1, screenshot_cache=None, debug_info=None, pause_after_test=False, **kwargs): ProcessTestExecutor.__init__(self, browser, server_config, timeout_multiplier=timeout_multiplier, debug_info=debug_info) self.protocol = Protocol(self, browser) self.screenshot_cache = screenshot_cache self.implementation = RefTestImplementation(self) self.tempdir = tempfile.mkdtemp() self.hosts_path = make_hosts_file()
def write_hosts_file(config): hosts_fd, hosts_path = tempfile.mkstemp() with os.fdopen(hosts_fd, "w") as f: f.write(make_hosts_file(config, "127.0.0.1")) return hosts_path