make setup backwards compatible

change the f'' to ''.format()
This commit is contained in:
BrianPetkovsek 2019-06-14 21:37:38 -04:00
parent a1e1d98929
commit b5da9ebbf7

View File

@ -94,7 +94,7 @@ class Video2xSetup:
""" """
for file in self.trash: for file in self.trash:
try: try:
print(f'Deleting: {file}') print('Deleting: {}'.format(file))
os.remove(file) os.remove(file)
except FileNotFoundError: except FileNotFoundError:
pass pass
@ -108,7 +108,7 @@ class Video2xSetup:
self.trash.append(ffmpeg_zip) self.trash.append(ffmpeg_zip)
with zipfile.ZipFile(ffmpeg_zip) as zipf: with zipfile.ZipFile(ffmpeg_zip) as zipf:
zipf.extractall(f'{os.getenv("localappdata")}\\video2x') zipf.extractall('{}\\video2x'.format(os.getenv("localappdata")))
def _install_waifu2x_caffe(self): def _install_waifu2x_caffe(self):
""" Install waifu2x_caffe """ Install waifu2x_caffe
@ -117,7 +117,7 @@ class Video2xSetup:
import requests import requests
# Get latest release of waifu2x-caffe via GitHub API # Get latest release of waifu2x-caffe via GitHub API
latest_release = json.loads(requests.get('https://api.github.com/repos/lltcggie/waifu2x-caffe/releases/latest').content) latest_release = json.loads(requests.get('https://api.github.com/repos/lltcggie/waifu2x-caffe/releases/latest').content.decode('utf-8'))
for a in latest_release['assets']: for a in latest_release['assets']:
if 'waifu2x-caffe.zip' in a['browser_download_url']: if 'waifu2x-caffe.zip' in a['browser_download_url']:
@ -125,7 +125,7 @@ class Video2xSetup:
self.trash.append(waifu2x_caffe_zip) self.trash.append(waifu2x_caffe_zip)
with zipfile.ZipFile(waifu2x_caffe_zip) as zipf: with zipfile.ZipFile(waifu2x_caffe_zip) as zipf:
zipf.extractall(f'{os.getenv("localappdata")}\\video2x') zipf.extractall('{}\\video2x'.format(os.getenv("localappdata")))
def _install_waifu2x_converter_cpp(self): def _install_waifu2x_converter_cpp(self):
""" Install waifu2x_caffe """ Install waifu2x_caffe
@ -135,7 +135,7 @@ class Video2xSetup:
import requests import requests
# Get latest release of waifu2x-caffe via GitHub API # Get latest release of waifu2x-caffe via GitHub API
latest_release = json.loads(requests.get('https://api.github.com/repos/DeadSix27/waifu2x-converter-cpp/releases/latest').content) latest_release = json.loads(requests.get('https://api.github.com/repos/DeadSix27/waifu2x-converter-cpp/releases/latest').content.decode('utf-8'))
for a in latest_release['assets']: for a in latest_release['assets']:
if re.search(r'waifu2x-DeadSix27-win64_v[0-9]*\.zip', a['browser_download_url']): if re.search(r'waifu2x-DeadSix27-win64_v[0-9]*\.zip', a['browser_download_url']):
@ -143,7 +143,7 @@ class Video2xSetup:
self.trash.append(waifu2x_converter_cpp_zip) self.trash.append(waifu2x_converter_cpp_zip)
with zipfile.ZipFile(waifu2x_converter_cpp_zip) as zipf: with zipfile.ZipFile(waifu2x_converter_cpp_zip) as zipf:
zipf.extractall(f'{os.getenv("localappdata")}\\video2x\\waifu2x-converter-cpp') zipf.extractall('{}\\video2x\\waifu2x-converter-cpp'.format(os.getenv("localappdata")))
def _generate_config(self): def _generate_config(self):
""" Generate video2x config """ Generate video2x config
@ -157,14 +157,14 @@ class Video2xSetup:
# configure only the specified drivers # configure only the specified drivers
if self.driver == 'all': if self.driver == 'all':
template_dict['waifu2x_caffe']['waifu2x_caffe_path'] = f'{local_app_data}\\video2x\\waifu2x-caffe\\waifu2x-caffe-cui.exe' template_dict['waifu2x_caffe']['waifu2x_caffe_path'] = '{}\\video2x\\waifu2x-caffe\\waifu2x-caffe-cui.exe'.format(local_app_data)
template_dict['waifu2x_converter']['waifu2x_converter_path'] = f'{local_app_data}\\video2x\\waifu2x-converter-cpp' template_dict['waifu2x_converter']['waifu2x_converter_path'] = '{}\\video2x\\waifu2x-converter-cpp'.format(local_app_data)
elif self.driver == 'waifu2x_caffe': elif self.driver == 'waifu2x_caffe':
template_dict['waifu2x_caffe']['waifu2x_caffe_path'] = f'{local_app_data}\\video2x\\waifu2x-caffe\\waifu2x-caffe-cui.exe' template_dict['waifu2x_caffe']['waifu2x_caffe_path'] = '{}\\video2x\\waifu2x-caffe\\waifu2x-caffe-cui.exe'.format(local_app_data)
elif self.driver == 'waifu2x_converter': elif self.driver == 'waifu2x_converter':
template_dict['waifu2x_converter']['waifu2x_converter_path'] = f'{local_app_data}\\video2x\\waifu2x-converter-cpp' template_dict['waifu2x_converter']['waifu2x_converter_path'] = '{}\\video2x\\waifu2x-converter-cpp'.format(local_app_data)
template_dict['ffmpeg']['ffmpeg_path'] = f'{local_app_data}\\video2x\\ffmpeg-latest-win64-static\\bin' template_dict['ffmpeg']['ffmpeg_path'] = '{}\\video2x\\ffmpeg-latest-win64-static\\bin'.format(local_app_data)
template_dict['video2x']['video2x_cache_directory'] = None template_dict['video2x']['video2x_cache_directory'] = None
template_dict['video2x']['preserve_frames'] = False template_dict['video2x']['preserve_frames'] = False
@ -180,10 +180,10 @@ def download(url, save_path, chunk_size=4096):
from tqdm import tqdm from tqdm import tqdm
import requests import requests
output_file = f'{save_path}\\{url.split("/")[-1]}' output_file = '{}\\{}'.format(save_path, url.split("/")[-1])
print(f'Downloading: {url}') print('Downloading: {}'.format(url))
print(f'Chunk size: {chunk_size}') print('Chunk size: {}'.format(chunk_size))
print(f'Saving to: {output_file}') print('Saving to: {}'.format(output_file))
stream = requests.get(url, stream=True) stream = requests.get(url, stream=True)
total_size = int(stream.headers['content-length']) total_size = int(stream.headers['content-length'])
@ -212,7 +212,7 @@ if __name__ == "__main__":
try: try:
args = process_arguments() args = process_arguments()
print('Video2X Setup Script') print('Video2X Setup Script')
print(f'Version: {VERSION}') print('Version: {}'.format(VERSION))
# do not install pip modules if script # do not install pip modules if script
# is packaged in exe format # is packaged in exe format