fix for division by 0 problem for projects without any modules
This commit is contained in:
parent
a72f7f6eba
commit
8c38f35167
49
update.py
49
update.py
@ -194,31 +194,34 @@ def fetch_modules(config, module_directory):
|
||||
config.sections()))
|
||||
n = len(l)
|
||||
|
||||
i = 0
|
||||
print_progress_bar(text='- fetching modules:', done=0, total=n, width=30)
|
||||
list_of_modules = []
|
||||
for section in config.sections():
|
||||
if config.has_option(section, 'source'):
|
||||
for src in config.get(section, 'source').split('\n'):
|
||||
module_name = os.path.basename(src)
|
||||
list_of_modules.append(module_name)
|
||||
dst = os.path.join(module_directory, 'autocmake_%s' % module_name)
|
||||
if 'http' in src:
|
||||
fetch_url(src, dst)
|
||||
else:
|
||||
if os.path.exists(src):
|
||||
shutil.copyfile(src, dst)
|
||||
|
||||
if n > 0: # otherwise division by zero in print_progress_bar
|
||||
i = 0
|
||||
print_progress_bar(text='- fetching modules:', done=0, total=n, width=30)
|
||||
for section in config.sections():
|
||||
if config.has_option(section, 'source'):
|
||||
for src in config.get(section, 'source').split('\n'):
|
||||
module_name = os.path.basename(src)
|
||||
list_of_modules.append(module_name)
|
||||
dst = os.path.join(module_directory, 'autocmake_%s' % module_name)
|
||||
if 'http' in src:
|
||||
fetch_url(src, dst)
|
||||
else:
|
||||
sys.stderr.write("ERROR: %s does not exist\n" % src)
|
||||
sys.exit(-1)
|
||||
i += 1
|
||||
print_progress_bar(
|
||||
text='- fetching modules:',
|
||||
done=i,
|
||||
total=n,
|
||||
width=30
|
||||
)
|
||||
print('')
|
||||
if os.path.exists(src):
|
||||
shutil.copyfile(src, dst)
|
||||
else:
|
||||
sys.stderr.write("ERROR: %s does not exist\n" % src)
|
||||
sys.exit(-1)
|
||||
i += 1
|
||||
print_progress_bar(
|
||||
text='- fetching modules:',
|
||||
done=i,
|
||||
total=n,
|
||||
width=30
|
||||
)
|
||||
print('')
|
||||
|
||||
return list_of_modules
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user