prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Exit code 256 in networking.py
  While doing PR #562 I noticed that we check if exit code is 256. I thought for any process it was an 8 bit value and could be 0 through 255, so I'm not sure about this logic. I'd like to figure out why it was written in this manner and it probably should be fixed. Maybe drop the exit code check entirely? 
  
  </issue>
  <code>
  [start of archinstall/lib/networking.py]
  1 import fcntl
  2 import logging
  3 import os
  4 import socket
  5 import struct
  6 from collections import OrderedDict
  7 
  8 from .exceptions import *
  9 from .general import SysCommand
  10 from .output import log
  11 from .storage import storage
  12 
  13 
  14 def get_hw_addr(ifname):
  15 	s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  16 	info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', bytes(ifname, 'utf-8')[:15]))
  17 	return ':'.join('%02x' % b for b in info[18:24])
  18 
  19 
  20 def list_interfaces(skip_loopback=True):
  21 	interfaces = OrderedDict()
  22 	for index, iface in socket.if_nameindex():
  23 		if skip_loopback and iface == "lo":
  24 			continue
  25 
  26 		mac = get_hw_addr(iface).replace(':', '-').lower()
  27 		interfaces[mac] = iface
  28 	return interfaces
  29 
  30 
  31 def check_mirror_reachable():
  32 	if (exit_code := SysCommand("pacman -Sy").exit_code) == 0:
  33 		return True
  34 	elif exit_code == 256:
  35 		if os.geteuid() != 0:
  36 			log("check_mirror_reachable() uses 'pacman -Sy' which requires root.", level=logging.ERROR, fg="red")
  37 
  38 	return False
  39 
  40 
  41 def enrich_iface_types(interfaces: dict):
  42 	result = {}
  43 	for iface in interfaces:
  44 		if os.path.isdir(f"/sys/class/net/{iface}/bridge/"):
  45 			result[iface] = 'BRIDGE'
  46 		elif os.path.isfile(f"/sys/class/net/{iface}/tun_flags"):
  47 			# ethtool -i {iface}
  48 			result[iface] = 'TUN/TAP'
  49 		elif os.path.isdir(f"/sys/class/net/{iface}/device"):
  50 			if os.path.isdir(f"/sys/class/net/{iface}/wireless/"):
  51 				result[iface] = 'WIRELESS'
  52 			else:
  53 				result[iface] = 'PHYSICAL'
  54 		else:
  55 			result[iface] = 'UNKNOWN'
  56 	return result
  57 
  58 
  59 def get_interface_from_mac(mac):
  60 	return list_interfaces().get(mac.lower(), None)
  61 
  62 
  63 def wireless_scan(interface):
  64 	interfaces = enrich_iface_types(list_interfaces().values())
  65 	if interfaces[interface] != 'WIRELESS':
  66 		raise HardwareIncompatibilityError(f"Interface {interface} is not a wireless interface: {interfaces}")
  67 
  68 	SysCommand(f"iwctl station {interface} scan")
  69 
  70 	if '_WIFI' not in storage:
  71 		storage['_WIFI'] = {}
  72 	if interface not in storage['_WIFI']:
  73 		storage['_WIFI'][interface] = {}
  74 
  75 	storage['_WIFI'][interface]['scanning'] = True
  76 
  77 
  78 # TODO: Full WiFi experience might get evolved in the future, pausing for now 2021-01-25
  79 def get_wireless_networks(interface):
  80 	# TODO: Make this oneliner pritter to check if the interface is scanning or not.
  81 	if '_WIFI' not in storage or interface not in storage['_WIFI'] or storage['_WIFI'][interface].get('scanning', False) is False:
  82 		import time
  83 
  84 		wireless_scan(interface)
  85 		time.sleep(5)
  86 
  87 	for line in SysCommand(f"iwctl station {interface} get-networks"):
  88 		print(line)
  89
  [end of archinstall/lib/networking.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py
  --- a/archinstall/lib/networking.py
  +++ b/archinstall/lib/networking.py
  @@ -31,9 +31,8 @@
   def check_mirror_reachable():
   	if (exit_code := SysCommand("pacman -Sy").exit_code) == 0:
   		return True
  -	elif exit_code == 256:
  -		if os.geteuid() != 0:
  -			log("check_mirror_reachable() uses 'pacman -Sy' which requires root.", level=logging.ERROR, fg="red")
  +	elif os.geteuid() != 0:
  +		log("check_mirror_reachable() uses 'pacman -Sy' which requires root.", level=logging.ERROR, fg="red")
   
   	return False
  
verification_info: {"golden_diff": "diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py\n--- a/archinstall/lib/networking.py\n+++ b/archinstall/lib/networking.py\n@@ -31,9 +31,8 @@\n def check_mirror_reachable():\n \tif (exit_code := SysCommand(\"pacman -Sy\").exit_code) == 0:\n \t\treturn True\n-\telif exit_code == 256:\n-\t\tif os.geteuid() != 0:\n-\t\t\tlog(\"check_mirror_reachable() uses 'pacman -Sy' which requires root.\", level=logging.ERROR, fg=\"red\")\n+\telif os.geteuid() != 0:\n+\t\tlog(\"check_mirror_reachable() uses 'pacman -Sy' which requires root.\", level=logging.ERROR, fg=\"red\")\n \n \treturn False\n", "issue": "Exit code 256 in networking.py\nWhile doing PR #562 I noticed that we check if exit code is 256. I thought for any process it was an 8 bit value and could be 0 through 255, so I'm not sure about this logic. I'd like to figure out why it was written in this manner and it probably should be fixed. Maybe drop the exit code check entirely? \n", "before_files": [{"content": "import fcntl\nimport logging\nimport os\nimport socket\nimport struct\nfrom collections import OrderedDict\n\nfrom .exceptions import *\nfrom .general import SysCommand\nfrom .output import log\nfrom .storage import storage\n\n\ndef get_hw_addr(ifname):\n\ts = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n\tinfo = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', bytes(ifname, 'utf-8')[:15]))\n\treturn ':'.join('%02x' % b for b in info[18:24])\n\n\ndef list_interfaces(skip_loopback=True):\n\tinterfaces = OrderedDict()\n\tfor index, iface in socket.if_nameindex():\n\t\tif skip_loopback and iface == \"lo\":\n\t\t\tcontinue\n\n\t\tmac = get_hw_addr(iface).replace(':', '-').lower()\n\t\tinterfaces[mac] = iface\n\treturn interfaces\n\n\ndef check_mirror_reachable():\n\tif (exit_code := SysCommand(\"pacman -Sy\").exit_code) == 0:\n\t\treturn True\n\telif exit_code == 256:\n\t\tif os.geteuid() != 0:\n\t\t\tlog(\"check_mirror_reachable() uses 'pacman -Sy' which requires root.\", level=logging.ERROR, fg=\"red\")\n\n\treturn False\n\n\ndef enrich_iface_types(interfaces: dict):\n\tresult = {}\n\tfor iface in interfaces:\n\t\tif os.path.isdir(f\"/sys/class/net/{iface}/bridge/\"):\n\t\t\tresult[iface] = 'BRIDGE'\n\t\telif os.path.isfile(f\"/sys/class/net/{iface}/tun_flags\"):\n\t\t\t# ethtool -i {iface}\n\t\t\tresult[iface] = 'TUN/TAP'\n\t\telif os.path.isdir(f\"/sys/class/net/{iface}/device\"):\n\t\t\tif os.path.isdir(f\"/sys/class/net/{iface}/wireless/\"):\n\t\t\t\tresult[iface] = 'WIRELESS'\n\t\t\telse:\n\t\t\t\tresult[iface] = 'PHYSICAL'\n\t\telse:\n\t\t\tresult[iface] = 'UNKNOWN'\n\treturn result\n\n\ndef get_interface_from_mac(mac):\n\treturn list_interfaces().get(mac.lower(), None)\n\n\ndef wireless_scan(interface):\n\tinterfaces = enrich_iface_types(list_interfaces().values())\n\tif interfaces[interface] != 'WIRELESS':\n\t\traise HardwareIncompatibilityError(f\"Interface {interface} is not a wireless interface: {interfaces}\")\n\n\tSysCommand(f\"iwctl station {interface} scan\")\n\n\tif '_WIFI' not in storage:\n\t\tstorage['_WIFI'] = {}\n\tif interface not in storage['_WIFI']:\n\t\tstorage['_WIFI'][interface] = {}\n\n\tstorage['_WIFI'][interface]['scanning'] = True\n\n\n# TODO: Full WiFi experience might get evolved in the future, pausing for now 2021-01-25\ndef get_wireless_networks(interface):\n\t# TODO: Make this oneliner pritter to check if the interface is scanning or not.\n\tif '_WIFI' not in storage or interface not in storage['_WIFI'] or storage['_WIFI'][interface].get('scanning', False) is False:\n\t\timport time\n\n\t\twireless_scan(interface)\n\t\ttime.sleep(5)\n\n\tfor line in SysCommand(f\"iwctl station {interface} get-networks\"):\n\t\tprint(line)\n", "path": "archinstall/lib/networking.py"}]}