|
|
|
#!/usr/bin/env python
|
|
|
|
import numpy as np
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import json
|
|
|
|
import importlib
|
|
|
|
import importlib.util
|
|
|
|
"""
|
|
|
|
_config['system']['source'] = path #{'id':'cloud','auth':{'url':url,'uid':uid,'token':token}}
|
|
|
|
|
|
|
|
if show :
|
|
|
|
_df = pd.DataFrame({"available":themes.List()})
|
|
|
|
if _df.shape[0] > 0 :
|
|
|
|
values = themes.installed(_root)
|
|
|
|
values = values + np.repeat(f"""{FAILED}""", _df.shape[0] - len(values)).tolist()
|
|
|
|
_df['installed'] = values
|
|
|
|
else:
|
|
|
|
_df = f"""{FAILED} No themes were found in registry,\ncurl {themes.URL}/api/themes/List (QCMS_HOST_URL should be set)"""
|
|
|
|
print (_df)
|
|
|
|
if name :
|
|
|
|
# we need to install the theme, i.e download it and update the configuration
|
|
|
|
#
|
|
|
|
try:
|
|
|
|
_object = themes.Get(name)
|
|
|
|
path = os.sep.join([_root,'_assets','themes',name])
|
|
|
|
if not os.path.exists(path) :
|
|
|
|
os.makedirs(path)
|
|
|
|
_object = _object[name] #-- formatting (...)
|
|
|
|
for _filename in _object :
|
|
|
|
css = _object[_filename]
|
|
|
|
f = open(os.sep.join([path,_filename+'.css']),'w')
|
|
|
|
f.write(css)
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
#
|
|
|
|
# Let us update the configuration file ...
|
|
|
|
#
|
|
|
|
_config['system']['theme'] = name
|
|
|
|
config.write(_config,manifest)
|
|
|
|
_msg = f"""{PASSED} successfully downloaded {name} \n{PASSED} updated manifest {manifest}
|
|
|
|
"""
|
|
|
|
except Exception as e:
|
|
|
|
_msg = f"""{FAILED} operation failed "{str(e)}"
|
|
|
|
"""
|
|
|
|
|
|
|
|
pass
|
|
|
|
print (_msg)
|
|
|
|
|