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()))
|
config.sections()))
|
||||||
n = len(l)
|
n = len(l)
|
||||||
|
|
||||||
i = 0
|
|
||||||
print_progress_bar(text='- fetching modules:', done=0, total=n, width=30)
|
|
||||||
list_of_modules = []
|
list_of_modules = []
|
||||||
for section in config.sections():
|
|
||||||
if config.has_option(section, 'source'):
|
if n > 0: # otherwise division by zero in print_progress_bar
|
||||||
for src in config.get(section, 'source').split('\n'):
|
i = 0
|
||||||
module_name = os.path.basename(src)
|
print_progress_bar(text='- fetching modules:', done=0, total=n, width=30)
|
||||||
list_of_modules.append(module_name)
|
for section in config.sections():
|
||||||
dst = os.path.join(module_directory, 'autocmake_%s' % module_name)
|
if config.has_option(section, 'source'):
|
||||||
if 'http' in src:
|
for src in config.get(section, 'source').split('\n'):
|
||||||
fetch_url(src, dst)
|
module_name = os.path.basename(src)
|
||||||
else:
|
list_of_modules.append(module_name)
|
||||||
if os.path.exists(src):
|
dst = os.path.join(module_directory, 'autocmake_%s' % module_name)
|
||||||
shutil.copyfile(src, dst)
|
if 'http' in src:
|
||||||
|
fetch_url(src, dst)
|
||||||
else:
|
else:
|
||||||
sys.stderr.write("ERROR: %s does not exist\n" % src)
|
if os.path.exists(src):
|
||||||
sys.exit(-1)
|
shutil.copyfile(src, dst)
|
||||||
i += 1
|
else:
|
||||||
print_progress_bar(
|
sys.stderr.write("ERROR: %s does not exist\n" % src)
|
||||||
text='- fetching modules:',
|
sys.exit(-1)
|
||||||
done=i,
|
i += 1
|
||||||
total=n,
|
print_progress_bar(
|
||||||
width=30
|
text='- fetching modules:',
|
||||||
)
|
done=i,
|
||||||
print('')
|
total=n,
|
||||||
|
width=30
|
||||||
|
)
|
||||||
|
print('')
|
||||||
|
|
||||||
return list_of_modules
|
return list_of_modules
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user