Skip to content

Commit

Permalink
add arch
Browse files Browse the repository at this point in the history
  • Loading branch information
Debdut Karmakar authored and Debdut Karmakar committed Nov 16, 2021
1 parent 3564dcf commit 69b308a
Showing 1 changed file with 26 additions and 85 deletions.
111 changes: 26 additions & 85 deletions gettools.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import zipfile
import time

ARCH = 'x86'

try:
# For Python 3.0 and later
# noinspection PyCompatibility
Expand Down Expand Up @@ -125,101 +127,40 @@ def main():

lastVersion = parser.HTMLDATA[-1]

urlpost15 = url + lastVersion + '/packages/com.vmware.fusion.tools.darwin.zip.tar'
urlpre15 = url + lastVersion + '/packages/com.vmware.fusion.tools.darwinPre15.zip.tar'
parser.clean()

# Download the darwin.iso tgz file
print('Retrieving Darwin tools from: ' + urlpost15)
urlcoretar = url + lastVersion + '/' + ARCH + '/core/com.vmware.fusion.zip.tar'

# Get the main core file
try:
# Try to get tools from packages folder
urlretrieve(urlpost15, convertpath(dest + '/tools/com.vmware.fusion.tools.darwin.zip.tar'))

urlretrieve(urlcoretar, convertpath(dest + '/tools/com.vmware.fusion.zip.tar'), reporthook)
except:
# No tools found, get em from the core tar
print('Tools aren\'t here... Be patient while I download and' +
' give a look into the core.vmware.fusion.tar file')
urlcoretar = url + lastVersion + '/core/com.vmware.fusion.zip.tar'

# Get the main core file
try:
urlretrieve(urlcoretar, convertpath(dest + '/tools/com.vmware.fusion.zip.tar'), reporthook)
except:
print('Couldn\'t find tools')
return

print()

print('Extracting com.vmware.fusion.zip.tar...')
tar = tarfile.open(convertpath(dest + '/tools/com.vmware.fusion.zip.tar'), 'r')
tar.extract('com.vmware.fusion.zip', path=convertpath(dest + '/tools/'))
tar.close()

print('Extracting files from com.vmware.fusion.zip...')
cdszip = zipfile.ZipFile(convertpath(dest + '/tools/com.vmware.fusion.zip'), 'r')
cdszip.extract('payload/VMware Fusion.app/Contents/Library/isoimages/darwin.iso', path=convertpath(dest + '/tools/'))
cdszip.extract('payload/VMware Fusion.app/Contents/Library/isoimages/darwinPre15.iso', path=convertpath(dest + '/tools/'))
cdszip.close()

# Move the iso and sig files to tools folder
shutil.move(convertpath(dest + '/tools/payload/VMware Fusion.app/Contents/Library/isoimages/darwin.iso'), convertpath(dest + '/tools/darwin.iso'))
shutil.move(convertpath(dest + '/tools/payload/VMware Fusion.app/Contents/Library/isoimages/darwinPre15.iso'), convertpath(dest + '/tools/darwinPre15.iso'))

# Cleanup working files and folders
shutil.rmtree(convertpath(dest + '/tools/payload'), True)
os.remove(convertpath(dest + '/tools/com.vmware.fusion.zip.tar'))
os.remove(convertpath(dest + '/tools/com.vmware.fusion.zip'))

print('Tools retrieved successfully')
print('Couldn\'t find tools')
return

# Tools have been found, go with the normal way

# Extract the tar to zip
tar = tarfile.open(convertpath(dest + '/tools/com.vmware.fusion.tools.darwin.zip.tar'), 'r')
tar.extract('com.vmware.fusion.tools.darwin.zip', path=convertpath(dest + '/tools/'))
print('Extracting com.vmware.fusion.zip.tar...')
tar = tarfile.open(convertpath(dest + '/tools/com.vmware.fusion.zip.tar'), 'r')
tar.extract('com.vmware.fusion.zip', path=convertpath(dest + '/tools/'))
tar.close()

# Extract the iso and sig files from zip
cdszip = zipfile.ZipFile(convertpath(dest + '/tools/com.vmware.fusion.tools.darwin.zip'), 'r')
cdszip.extract('payload/darwin.iso', path=convertpath(dest + '/tools/'))
cdszip.extract('payload/darwin.iso.sig', path=convertpath(dest + '/tools/'))
cdszip.close()

# Move the iso and sig files to tools folder
shutil.move(convertpath(dest + '/tools/payload/darwin.iso'), convertpath(dest + '/tools/darwin.iso'))
shutil.move(convertpath(dest + '/tools/payload/darwin.iso.sig'), convertpath(dest + '/tools/darwin.iso.sig'))

# Cleanup working files and folders
shutil.rmtree(convertpath(dest + '/tools/payload'), True)
os.remove(convertpath(dest + '/tools/com.vmware.fusion.tools.darwin.zip.tar'))
os.remove(convertpath(dest + '/tools/com.vmware.fusion.tools.darwin.zip'))

# Download the darwinPre15.iso tgz file
print('Retrieving DarwinPre15 tools from: ' + urlpre15)
urlretrieve(urlpre15, convertpath(dest + '/tools/com.vmware.fusion.tools.darwinPre15.zip.tar'))

# Extract the tar to zip
tar = tarfile.open(convertpath(dest + '/tools/com.vmware.fusion.tools.darwinPre15.zip.tar'), 'r')
tar.extract('com.vmware.fusion.tools.darwinPre15.zip', path=convertpath(dest + '/tools/'))
tar.close()

# Extract the iso and sig files from zip
cdszip = zipfile.ZipFile(convertpath(dest + '/tools/com.vmware.fusion.tools.darwinPre15.zip'), 'r')
cdszip.extract('payload/darwinPre15.iso', path=convertpath(dest + '/tools/'))
cdszip.extract('payload/darwinPre15.iso.sig', path=convertpath(dest + '/tools/'))

print('Extracting files from com.vmware.fusion.zip...')
cdszip = zipfile.ZipFile(convertpath(dest + '/tools/com.vmware.fusion.zip'), 'r')
cdszip.extract('payload/VMware Fusion.app/Contents/Library/isoimages/darwin.iso', path=convertpath(dest + '/tools/'))
cdszip.extract('payload/VMware Fusion.app/Contents/Library/isoimages/darwinPre15.iso', path=convertpath(dest + '/tools/'))
cdszip.close()

# Move the iso and sig files to tools folder
shutil.move(convertpath(dest + '/tools/payload/darwinPre15.iso'),
convertpath(dest + '/tools/darwinPre15.iso'))
shutil.move(convertpath(dest + '/tools/payload/darwinPre15.iso.sig'),
convertpath(dest + '/tools/darwinPre15.iso.sig'))

shutil.move(convertpath(dest + '/tools/payload/VMware Fusion.app/Contents/Library/isoimages/darwin.iso'), convertpath(dest + '/tools/darwin.iso'))
shutil.move(convertpath(dest + '/tools/payload/VMware Fusion.app/Contents/Library/isoimages/darwinPre15.iso'), convertpath(dest + '/tools/darwinPre15.iso'))

# Cleanup working files and folders
shutil.rmtree(convertpath(dest + '/tools/payload'), True)
os.remove(convertpath(dest + '/tools/com.vmware.fusion.tools.darwinPre15.zip.tar'))
os.remove(convertpath(dest + '/tools/com.vmware.fusion.tools.darwinPre15.zip'))

os.remove(convertpath(dest + '/tools/com.vmware.fusion.zip.tar'))
os.remove(convertpath(dest + '/tools/com.vmware.fusion.zip'))

print('Tools retrieved successfully')
return


if __name__ == '__main__':
main()

0 comments on commit 69b308a

Please sign in to comment.