mirror of
https://github.com/foxlet/macOS-Simple-KVM.git
synced 2024-11-26 21:19:41 +01:00
[TOOLS] Make FetchMacOS Python2/3 compatible.
This commit is contained in:
parent
5611154d8b
commit
02b3c12bb9
1 changed files with 11 additions and 4 deletions
|
@ -8,6 +8,7 @@ import os
|
|||
import errno
|
||||
import click
|
||||
import requests
|
||||
import sys
|
||||
|
||||
__author__ = "Foxlet"
|
||||
__copyright__ = "Copyright 2018, FurCode Project"
|
||||
|
@ -66,6 +67,9 @@ class SoftwareService:
|
|||
return catalog_raw.text.encode('UTF-8')
|
||||
|
||||
def getosinstall(self):
|
||||
if (sys.version_info > (3, 0)):
|
||||
root = plistlib.readPlistFromBytes(self.catalog_data)
|
||||
else:
|
||||
root = plistlib.readPlistFromString(self.catalog_data)
|
||||
products = root['Products']
|
||||
for product in products:
|
||||
|
@ -79,6 +83,9 @@ class SoftwareService:
|
|||
|
||||
class MacOSProduct:
|
||||
def __init__(self, catalog, product_id):
|
||||
if (sys.version_info > (3, 0)):
|
||||
root = plistlib.readPlistFromBytes(catalog)
|
||||
else:
|
||||
root = plistlib.readPlistFromString(catalog)
|
||||
products = root['Products']
|
||||
self.date = root['IndexDate']
|
||||
|
@ -107,13 +114,13 @@ def fetchmacos(output_dir="BaseSystem/", catalog_id="DeveloperSeed", product_id=
|
|||
product_id = remote.getosinstall()
|
||||
else:
|
||||
if product_id == "":
|
||||
print "You must provide a Product ID (or pass the -l flag) to continue."
|
||||
print("You must provide a Product ID (or pass the -l flag) to continue.")
|
||||
exit(1)
|
||||
product_id = product_id
|
||||
try:
|
||||
update = MacOSProduct(catalog, product_id)
|
||||
except KeyError:
|
||||
print "Product ID {} could not be found.".format(product_id)
|
||||
print("Product ID {} could not be found.".format(product_id))
|
||||
exit(1)
|
||||
logging.info("Selected macOS Product: {}".format(product_id))
|
||||
|
||||
|
|
Loading…
Reference in a new issue