Spaces:
No application file
No application file
File size: 3,878 Bytes
3883c60 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
import sys
import traceback
import setup_tools.os as oscheck
import setup_tools.commands as commands
class AutoDebugException(OSError):
def __init__(self, message):
super(AutoDebugException, self).__init__(message)
def action(self):
pass
class WrongPythonVersionException(AutoDebugException):
def action(self):
if oscheck.is_windows():
print('Do you want to download the python 3.10 installer?\nWhen installing, make sure py launcher is selected as well.')
response = input('Y/n: ').upper()
if not response:
response = 'Y'
response = response[0]
if response == 'Y':
commands.run_command('start', 'https://www.python.org/downloads/release/python-31011/') # Last python 3.10 version with windows installer
elif response == 'N':
print('If you ever want to download it, the link is: https://www.python.org/downloads/release/python-31011/')
else:
print('Please use a package manager to install python 3.10. For example: `apt install python3.10` on debian.')
input()
class InstallFailException(AutoDebugException):
def __init__(self, exit_code, stdout, stderr):
super(InstallFailException, self).__init__('Install failed!')
self.exit_code = exit_code
self.stdout = stdout
self.stderr = stderr
def action(self):
print(f'STDOUT:\n{self.stdout}\n\n\n\nSTDERR:\n{self.stderr}\n\n')
if 'https://visualstudio.microsoft.com/visual-cpp-build-tools/'.casefold() in self.stderr.casefold():
print('You need to have visual studio C++ build tools installed. https://visualstudio.microsoft.com/visual-cpp-build-tools/.')
if 'OSError: [WinError: 5] Access is denied:'.casefold() in self.stderr.casefold():
print('OSError, try running again.')
print('Please read the error above carefully. \nIf you are unsure, please create an issue at https://github.com/gitmylo/audio-webui/issues.')
print('When creating an issue, please include your full autodebug message.')
print(f'Exit code: {self.exit_code}')
input()
def print_banner():
print('''
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ''')
def catcher(e: Exception):
if isinstance(e, AutoDebugException):
print_banner()
print(e)
e.action()
elif isinstance(e, ImportError):
e_comp = str(e).casefold()
if 'No module named \'pywintypes\''.casefold() in e_comp:
print('Install finished, pywintypes missing, relaunching script.')
commands.run_command(sys.executable, ' '.join([f'"{arg}"' for arg in sys.argv]))
return
traceback.print_exception(e)
print(e)
print('Your install might have failed to install one of the requirements, are you missing a package?')
print('You can read common issues at https://github.com/gitmylo/audio-webui/wiki/common-issues')
input()
else:
raise e
|