mirror of
https://github.com/Melon-Bread/RetroUFO
synced 2024-11-25 00:38:33 -05:00
The keep downloaded checkbox does what it says now
This commit is contained in:
parent
ae29d2a9fc
commit
d434a58af2
@ -7,7 +7,6 @@ __author__ = "Melon Bread"
|
|||||||
__version__ = "0.8.0"
|
__version__ = "0.8.0"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
|
|
||||||
import argparse
|
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
@ -15,9 +14,10 @@ import zipfile
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from urllib.request import urlretrieve
|
from urllib.request import urlretrieve
|
||||||
from PySide2.QtWidgets import QApplication, QDialog, QLineEdit, QComboBox, QCheckBox, QPushButton, QFileDialog, \
|
|
||||||
QVBoxLayout, QTextEdit
|
|
||||||
|
|
||||||
|
from PySide2.QtWidgets import (QApplication, QCheckBox, QComboBox, QDialog,
|
||||||
|
QFileDialog, QLineEdit, QPushButton, QTextEdit,
|
||||||
|
QVBoxLayout)
|
||||||
|
|
||||||
URL = 'https://buildbot.libretro.com/nightly'
|
URL = 'https://buildbot.libretro.com/nightly'
|
||||||
|
|
||||||
@ -27,8 +27,8 @@ CORE_LOCATION = {
|
|||||||
'windows': '{}/AppData/Roaming/RetroArch/cores'.format(Path.home())
|
'windows': '{}/AppData/Roaming/RetroArch/cores'.format(Path.home())
|
||||||
}
|
}
|
||||||
|
|
||||||
class Form(QDialog):
|
|
||||||
|
|
||||||
|
class Form(QDialog):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(Form, self).__init__(parent)
|
super(Form, self).__init__(parent)
|
||||||
self.setWindowTitle('RetroUFO')
|
self.setWindowTitle('RetroUFO')
|
||||||
@ -61,7 +61,6 @@ class Form(QDialog):
|
|||||||
self.chkboxKeepDownload = QCheckBox('Keep Downloaded Cores')
|
self.chkboxKeepDownload = QCheckBox('Keep Downloaded Cores')
|
||||||
self.chkboxKeepDownload.setChecked(False)
|
self.chkboxKeepDownload.setChecked(False)
|
||||||
|
|
||||||
|
|
||||||
self.btnGrabCores = QPushButton('Grab Cores')
|
self.btnGrabCores = QPushButton('Grab Cores')
|
||||||
self.btnGrabCores.clicked.connect(self.grab_cores)
|
self.btnGrabCores.clicked.connect(self.grab_cores)
|
||||||
|
|
||||||
@ -94,23 +93,25 @@ class Form(QDialog):
|
|||||||
self.btnCoreLocation.setEnabled(True)
|
self.btnCoreLocation.setEnabled(True)
|
||||||
|
|
||||||
def choose_location(self):
|
def choose_location(self):
|
||||||
directory = QFileDialog.getExistingDirectory(self, 'Choose Target Location', '/home')
|
directory = QFileDialog.getExistingDirectory(
|
||||||
|
self, 'Choose Target Location', '/home')
|
||||||
|
|
||||||
self.leditCoreLocation.insert(directory)
|
self.leditCoreLocation.insert(directory)
|
||||||
|
|
||||||
def grab_cores(self):
|
def grab_cores(self):
|
||||||
self.teditLog.insertPlainText('Starting UFO Grabber')
|
self.teditLog.insertPlainText('Starting UFO Grabber\n')
|
||||||
""" Where the magic happens """
|
""" Where the magic happens """
|
||||||
|
|
||||||
# If a platform and/or architecture is not supplied it is grabbed automatically
|
# If a platform and/or architecture is not supplied it is grabbed automatically
|
||||||
platform = self.get_platform() # TODO: rename this var to prevent conflict
|
platform = self.get_platform(
|
||||||
|
) # TODO: rename this var to prevent conflict
|
||||||
architecture = self.get_architecture()
|
architecture = self.get_architecture()
|
||||||
location = CORE_LOCATION[platform]
|
location = CORE_LOCATION[platform]
|
||||||
|
|
||||||
self.download_cores(platform, architecture)
|
self.download_cores(platform, architecture)
|
||||||
self.extract_cores(location)
|
self.extract_cores(location)
|
||||||
|
|
||||||
if not args.keep:
|
if not self.chkboxKeepDownload.isChecked():
|
||||||
self.clean_up()
|
self.clean_up()
|
||||||
|
|
||||||
def get_platform(self):
|
def get_platform(self):
|
||||||
@ -119,7 +120,8 @@ class Form(QDialog):
|
|||||||
if platform.system() == 'Linux':
|
if platform.system() == 'Linux':
|
||||||
return 'linux'
|
return 'linux'
|
||||||
|
|
||||||
elif platform.system() == 'Windows' or 'MSYS_NT' in platform.system(): # Checks for MSYS environment as well
|
elif platform.system() == 'Windows' or 'MSYS_NT' in platform.system(
|
||||||
|
): # Checks for MSYS environment as well
|
||||||
return 'windows'
|
return 'windows'
|
||||||
else:
|
else:
|
||||||
print('ERROR: Platform not found or supported')
|
print('ERROR: Platform not found or supported')
|
||||||
@ -147,8 +149,9 @@ class Form(QDialog):
|
|||||||
os.makedirs("cores")
|
os.makedirs("cores")
|
||||||
|
|
||||||
# Downloads a list of all the cores available
|
# Downloads a list of all the cores available
|
||||||
urlretrieve('{}/{}/{}/latest/.index-extended'.format(URL, _platform, _architecture),
|
urlretrieve(
|
||||||
'cores/index')
|
'{}/{}/{}/latest/.index-extended'.format(
|
||||||
|
URL, _platform, _architecture), 'cores/index')
|
||||||
self.teditLog.insertPlainText('Obtained core index!')
|
self.teditLog.insertPlainText('Obtained core index!')
|
||||||
|
|
||||||
# Adds all the core's file names to a list
|
# Adds all the core's file names to a list
|
||||||
@ -162,8 +165,9 @@ class Form(QDialog):
|
|||||||
|
|
||||||
# Downloads each core from the list
|
# Downloads each core from the list
|
||||||
for core in cores:
|
for core in cores:
|
||||||
urlretrieve('{}/{}/{}/latest/{}'.format(URL, _platform, _architecture, core),
|
urlretrieve(
|
||||||
'cores/{}'.format(core))
|
'{}/{}/{}/latest/{}'.format(URL, _platform, _architecture,
|
||||||
|
core), 'cores/{}'.format(core))
|
||||||
print('Downloaded {} ...'.format(core))
|
print('Downloaded {} ...'.format(core))
|
||||||
|
|
||||||
# Removes index file for easier extraction
|
# Removes index file for easier extraction
|
||||||
|
Loading…
Reference in New Issue
Block a user