10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-10-20 06:48:20 +02:00

Installation of external plugin works

This commit is contained in:
Anthony Scemama 2018-12-21 18:35:56 +01:00
parent 316695726b
commit 414df84781

View File

@ -193,8 +193,20 @@ def main(arguments):
d_module_location= dict() d_module_location= dict()
d_local = get_dict_child([QP_SRC]) d_local = get_dict_child([QP_SRC])
d_plugin = get_dict_child([join(QP_PLUGINS, f) for f in listdir(QP_PLUGINS) if isdir(join(QP_PLUGINS, f))]) # d_plugin = get_dict_child([join(QP_PLUGINS, f) for f in listdir(QP_PLUGINS) if isdir(join(QP_PLUGINS, f))])
l_tmp = [ dirname for (dirname, _, filenames) in os.walk(QP_PLUGINS, followlinks=False) for f in filenames if f == 'NEED']
d_repo_of_plugin = {}
d_repo = {}
for (x,y) in [ os.path.split(f) for f in l_tmp ]:
d_repo_of_plugin[y] = x
d_repo[x] = None
l_repository = d_repo.keys()
# m_all_instances = ModuleHandler(l_repository)
# m_instance = ModuleHandler(l_repository)
# l_plugins = [ module for module in m_instance.l_module ]
# print l_plugins
d_plugin = get_dict_child(l_repository)
d_child = d_local.copy() d_child = d_local.copy()
d_child.update(d_plugin) d_child.update(d_plugin)
@ -221,18 +233,19 @@ def main(arguments):
print "Installation...", print "Installation...",
for module_to_cp in l_module_to_cp: for module_to_cp in l_module_to_cp:
src = os.path.join( d_repo_of_plugin[module_to_cp], module_to_cp )
# Find the module. This is ugly. Quick fix, we should refactor des = os.path.join(QP_SRC, module_to_cp)
src = [ join(QP_PLUGINS, f, module_to_cp) for f in listdir(QP_PLUGINS) if isdir(join(QP_PLUGINS, f,module_to_cp) ) ][0] try:
des = os.path.join(QP_SRC, module_to_cp) os.symlink(src, des)
try: install = os.path.join(src,"install")
os.symlink(src, des) if os.path.isfile(install):
install = os.path.join(src,"install") wd = os.getcwd()
if os.path.isfile(install): os.chdir(src)
subprocess.check_call([install]) subprocess.check_call([install])
except OSError: os.chdir(wd)
print "The src directory is broken. Please remove %s" % des except OSError:
raise print "The src directory is broken. Please remove %s" % des
raise
print "[ OK ]" print "[ OK ]"
elif arguments["uninstall"]: elif arguments["uninstall"]: