'''
Created on 19 lut 2020

@author: fpawlak
'''

import os
import sys
from Classes.LibrariesInstaller import LibrariesInstaller
from Classes.CodesysLibsScriptsException import CodesysLibsScriptsException
from Classes.Config import Config
from Classes.AviableLibrariesParser import AviableLibrariesParser
import traceback


config = Config(os.path.dirname(__file__) + '\\config.cfg');
aviableLibraries = AviableLibrariesParser(config.remoteRepository.path)

try:
    installer = LibrariesInstaller(librarymanager)
    repository = installer.getRepository(config.localRepository)
    installer.installLibs(repository, config.remoteRepository.path, aviableLibraries)
except CodesysLibsScriptsException as e:
    print(e.mainException)
    traceback.print_exc()
    sys.exit(-1)