Exemple #1
0
def get_fame_toolbox_modelica_libraries():
    flag = 1
    # check if any critical library is missing
    if (os.path.isdir(os.path.join(script_dir, "FAME"))
            and os.path.isdir(os.path.join(script_dir, "MSL"))
            and os.path.isdir(os.path.join(script_dir, "pre-faulted"))):
        flag = 0
    if flag == 1:
        # going redownload whole set of key libraries
        if os.path.exists(os.path.join(script_dir, "FAME")):
            shutil.rmtree(os.path.join(script_dir, "FAME"))
        if os.path.exists(os.path.join(script_dir, "MSL")):
            shutil.rmtree(os.path.join(script_dir, "MSL"))
        if os.path.exists(os.path.join(script_dir, "pre-faulted")):
            shutil.rmtree(os.path.join(script_dir, "pre-faulted"))
        fetch.fetch_and_unpack_zip_file(
            "http://fame-deploy.parc.com/C2M2L_Decl/fault-enabled-libraries/FAME_Toolkit_Modelica_Files.zip",
            script_dir)
        shutil.move(
            os.path.join(script_dir, "FAME_Toolkit_Modelica_Files", "FAME"),
            os.path.join(script_dir, "FAME"))
        shutil.move(
            os.path.join(script_dir, "FAME_Toolkit_Modelica_Files", "MSL"),
            os.path.join(script_dir, "MSL"))
        shutil.move(
            os.path.join(script_dir,
                         "FAME_Toolkit_Modelica_Files", "pre-faulted"),
            os.path.join(script_dir, "pre-faulted"))
        shutil.rmtree(os.path.join(script_dir, "FAME_Toolkit_Modelica_Files"))
def get_fame_toolbox_modelica_libraries():
    flag = 1
    # check if any critical library is missing
    if (os.path.isdir(os.path.join(script_dir,"FAME")) and 
            os.path.isdir(os.path.join(script_dir,"MSL")) and
            os.path.isdir(os.path.join(script_dir,"pre-faulted"))):
        flag = 0
    if flag == 1:
        # going redownload whole set of key libraries
        if os.path.exists(os.path.join(script_dir,"FAME")):
            shutil.rmtree(os.path.join(script_dir,"FAME"))
        if os.path.exists(os.path.join(script_dir,"MSL")):
            shutil.rmtree(os.path.join(script_dir,"MSL"))
        if os.path.exists(os.path.join(script_dir,"pre-faulted")):
            shutil.rmtree(os.path.join(script_dir,"pre-faulted"))
        fetch.fetch_and_unpack_zip_file("http://fame-deploy.parc.com/C2M2L_Decl/fault-enabled-libraries/FAME_Toolkit_Modelica_Files.zip", script_dir)
        shutil.move(os.path.join(script_dir,"FAME_Toolkit_Modelica_Files","FAME"),
                os.path.join(script_dir,"FAME"))
        shutil.move(os.path.join(script_dir,"FAME_Toolkit_Modelica_Files","MSL"),
                os.path.join(script_dir,"MSL"))
        shutil.move(os.path.join(script_dir,"FAME_Toolkit_Modelica_Files","pre-faulted"),
                os.path.join(script_dir,"pre-faulted"))
        shutil.rmtree(os.path.join(script_dir,"FAME_Toolkit_Modelica_Files"))
from collections import OrderedDict
import fetch

script_dir = os.path.dirname(os.path.realpath(__file__))
#script_dir = os.getcwd()
output_dir = os.path.abspath(os.path.join(script_dir, "../"))
library_dir = os.path.realpath(os.path.join(script_dir, "..\Libraries"))
aug_library_dir = os.path.realpath(
    os.path.join(script_dir, "AugmentedLibraries"))
if not os.path.exists(aug_library_dir):
    aug_library_dir = os.path.realpath(
        os.path.join(script_dir, "..\AugmentedLibraries"))
    if not os.path.exists(aug_library_dir):
        try:
            fetch.fetch_and_unpack_zip_file(
                "http://fame-deploy.parc.com/C2M2L_Decl/fault-enabled-libraries/AugmentedLibraries.zip",
                output_dir)
        except:
            outfile = open(os.join(output_dir, "_FAILED.txt"), "w")
            outfile.write("Missing Augmented Library.\n")
            outfile.write(
                "Please download and put in ..\AugmentedLibraries folder \n")
            outfile.close()
            sys.exit()

cyphy_model_dir = os.path.realpath(os.path.join(script_dir, "..\CyPhy"))

fault_sim_rslt_dir = os.path.realpath(
    os.path.join(script_dir, "fault_sim_rslt"))
shutil.rmtree(fault_sim_rslt_dir, ignore_errors=True)
os.makedirs(fault_sim_rslt_dir)
import os, sys, shutil
import numpy as np
import json
from collections import OrderedDict
import fetch

script_dir = os.path.dirname(os.path.realpath(__file__))
#script_dir = os.getcwd()
output_dir = os.path.abspath(os.path.join(script_dir,"../"))
library_dir = os.path.realpath(os.path.join(script_dir,"..\Libraries"))
aug_library_dir = os.path.realpath(os.path.join(script_dir,"AugmentedLibraries"))
if not os.path.exists(aug_library_dir):
    aug_library_dir = os.path.realpath(os.path.join(script_dir,"..\AugmentedLibraries"))
    if not os.path.exists(aug_library_dir):
        try:
            fetch.fetch_and_unpack_zip_file("http://fame-deploy.parc.com/C2M2L_Decl/fault-enabled-libraries/AugmentedLibraries.zip", output_dir)
        except:
            outfile = open(os.join(output_dir,"_FAILED.txt"),"w")
            outfile.write("Missing Augmented Library.\n")
            outfile.write("Please download and put in ..\AugmentedLibraries folder \n")
            outfile.close()
            sys.exit()

cyphy_model_dir = os.path.realpath(os.path.join(script_dir,"..\CyPhy"))

fault_sim_rslt_dir = os.path.realpath(os.path.join(script_dir,"fault_sim_rslt"))
shutil.rmtree(fault_sim_rslt_dir,ignore_errors=True)
os.makedirs(fault_sim_rslt_dir)

# using CyPhy's Driveline postprocessing module.