print functions

pull/1/head
Castro0o 5 years ago
parent 1e109546b6
commit 9652ec2a2f

@ -96,13 +96,12 @@ def clean_dir(dirfullpath):
def print_colormsg(msg, level):
if level == 'fail':
print(Colors.FAIL)
color_cmd = Colors.FAIL
elif level == 'warning':
print(Colors.WARNING)
color_cmd = Colors.WARNING
elif level == 'ok':
print(Colors.BLUE)
print(msg)
print(Colors.ENDC)
color_cmd = Colors.BLUE
print(color_cmd, msg, Colors.ENDC)
class Colors:

@ -1,5 +1,6 @@
import os, argparse, sys, re
from mwclient import Site
from mwclient import (Site,
errors)
from jinja2 import Template
from functions import (print_colormsg,
reorder_imgs)
@ -97,15 +98,19 @@ for n, _file in enumerate(lsimgs):
)
_file_path = os.path.join(args.dir, _file)
print(_file_path)
if not args.dry:
pageurl = f'https://{args.host}{args.path}index.php/File:{pagename}'
with open(_file_path, 'rb') as _f:
site.upload(file=_file_path,
filename=pagename,
description=img_smw_prop_val,
ignore=True)
print(img_smw_prop_val)
print(f'https://{args.host}{args.path}index.php/File:{pagename}')
try:
site.upload(file=_file_path,
filename=pagename,
description=img_smw_prop_val,
ignore=True)
print(img_smw_prop_val)
except errors.APIError as e:
print_colormsg(f'Error: {e.info}\n'
f'It will not be uploaded',
level='fail')
print(f'See image at {pageurl}')

Loading…
Cancel
Save