Skip to content

Commit

Permalink
pep8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobi committed Jun 20, 2019
1 parent 8be435b commit 58a6d87
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 115 deletions.
24 changes: 13 additions & 11 deletions BlenderUpdaterCLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'''

from colorama import init, Fore
from distutils.dir_util import copy_tree # pylint: disable=no-name-in-module,import-error
from distutils.dir_util import copy_tree # pylint: disable=no-name-in-module,import-error
from progress.bar import IncrementalBar
import argparse
import configparser
Expand All @@ -36,13 +36,15 @@
failed = False
url = 'https://builder.blender.org/download/'
config = configparser.ConfigParser()


class Spinner:
busy = False
delay = 0.1

@staticmethod
def spinning_cursor():
while 1:
while 1:
for cursor in '|/-\\': yield cursor

def __init__(self, title, delay=None):
Expand All @@ -66,6 +68,7 @@ def stop(self):
self.busy = False
time.sleep(self.delay)


parser = argparse.ArgumentParser(description="Update Blender to latest nightly build. (c) 2018-2019 by Tobias Kummer/Overmind Studios.", epilog="example usage: BlenderUpdaterCLI -p C:\\Blender -b 28")
parser.add_argument('-p', '--path', help="Destination path", required=True, type=str)
parser.add_argument('-b', '--blender', help="Desired Blender version, either '-b 279' or '-b 28'", required=True, type=str)
Expand Down Expand Up @@ -157,7 +160,7 @@ def stop(self):
print(Fore.RED + "Syntax error - please use '-a x86' for 32bit or '-a x64' for 64bit")
failed = True

#check for --keep flag
# check for --keep flag
if args.keep:
print(Fore.MAGENTA + "Will keep temporary archive file")
keep_temp = True
Expand All @@ -180,15 +183,15 @@ def stop(self):
failed = True

# Abort if any error occured during parsing
if failed == True:
if failed is True:
print(Fore.RED + "Input errors detected, aborted (check above for details)")
else:
print(Fore.GREEN + "All settings valid, proceeding...")
try:
req = requests.get(url)
except Exception:
print(Fore.RED + "Error connecting to " + url + ", check your internet connection")

filename = re.findall(r'blender-' + blender + r'-\w+-' + opsys + r'[0-9a-zA-Z-._]*' + arch + r'\.' + extension, req.text)

if os.path.isfile('./config.ini'):
Expand Down Expand Up @@ -217,7 +220,7 @@ def stop(self):
elif anyway == 'y':
break
print("Invalid choice, try again!")

else:
config.read('config.ini')
config.add_section('main')
Expand All @@ -235,8 +238,8 @@ def stop(self):
r = requests.get(url + filename[0], stream=True)
with open("./blendertemp/" + filename[0], 'wb') as f:
pbar = IncrementalBar('Downloading', max=int(r.headers['Content-Length']) / chunkSize, suffix='%(percent)d%%')
for chunk in r.iter_content(chunk_size=chunkSize):
if chunk: # filter out keep-alive new chunks
for chunk in r.iter_content(chunk_size=chunkSize):
if chunk: # filter out keep-alive new chunks
pbar.next()
f.write(chunk)
pbar.finish()
Expand Down Expand Up @@ -273,8 +276,8 @@ def stop(self):
spinnerCleanup = Spinner('Cleanup... ')
spinnerCleanup.start()
if(keep_temp):
#just remove the extracted files
shutil.rmtree(os.path.join('./blendertemp/', source[0]))
# just remove the extracted files
shutil.rmtree(os.path.join('./blendertemp/', source[0]))
else:
shutil.rmtree('./blendertemp')

Expand Down Expand Up @@ -303,4 +306,3 @@ def stop(self):
p = subprocess.Popen(BlenderOSXPath)
elif opsys == 'Linux':
p = subprocess.Popen(os.path.join(dir_ + '/blender'))

6 changes: 5 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ requests = "*"
progress = "*"

[dev-packages]
pylint = "*"
pyinstaller = "*"
black = "*"
flake8 = "*"

[requires]
python_version = "3.7"

[pipenv]
allow_prereleases = true
168 changes: 65 additions & 103 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 58a6d87

Please sign in to comment.