]> glassweightruler.freedombox.rocks Git - waydroid.git/blobdiff - tools/actions/initializer.py
Mount TUN device for use by Android VPNs.
[waydroid.git] / tools / actions / initializer.py
index 2173b459dd19a5223d8355e1f6d569b48b72f7b4..4a80bb998b4cca1802a54e637fec7fee50059517 100644 (file)
@@ -2,7 +2,6 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 import logging
 import os
-import requests
 from tools import helpers
 import tools.config
 
@@ -45,11 +44,11 @@ def setup_config(args):
 
     args.system_ota = args.system_channel + "/" + args.rom_type + \
         "/waydroid_" + args.arch + "/" + args.system_type + ".json"
-    system_request = requests.get(args.system_ota)
-    if system_request.status_code != 200:
+    system_request = helpers.http.retrieve(args.system_ota)
+    if system_request[0] != 200:
         if args.images_path != preinstalled_images:
             raise ValueError(
-                "Failed to get system OTA channel: {}".format(args.system_ota))
+                "Failed to get system OTA channel: {}, error: {}".format(args.system_ota, system_request[0]))
         else:
             args.system_ota = "None"
 
@@ -57,9 +56,9 @@ def setup_config(args):
     args.vendor_type = None
     for vendor in [device_codename, get_vendor_type(args)]:
         vendor_ota = args.vendor_channel + "/waydroid_" + \
-            args.arch + "/" + vendor + ".json"
-        vendor_request = requests.get(vendor_ota)
-        if vendor_request.status_code == 200:
+            args.arch + "/" + vendor.replace(" ", "_") + ".json"
+        vendor_request = helpers.http.retrieve(vendor_ota)
+        if vendor_request[0] == 200:
             args.vendor_type = vendor
             args.vendor_ota = vendor_ota
             break
@@ -82,7 +81,7 @@ def setup_config(args):
     tools.config.save(args, cfg)
 
 def init(args):
-    if not os.path.isfile(args.config) or args.force:
+    if not os.path.isfile(args.config) or not os.path.isdir(tools.config.defaults["rootfs"]) or args.force:
         setup_config(args)
         status = "STOPPED"
         if os.path.exists(tools.config.defaults["lxc"] + "/waydroid"):