Exemple #1
0
def create_system(system, fe="HyperSpin"):
    rl = RocketLauncher(system=system)
    rl.new_system()

    dont_search = [
        "Commodore 64", "Commodore VIC-20", "MAME", "Sega CD",
        "Sega Dreamcast", "Nintendo DS", "Sony PlayStation"
    ]

    # Build ROM set
    platform = System(system=system)
    if system in dont_search:
        curated_sets = platform.software_lists + platform.nointro + platform.goodset
    else:
        curated_sets = platform.tosec_dirs(
        ) + platform.software_lists + platform.nointro + platform.goodset
    platform.build_rom_set(source_set=curated_sets)
    emu = EmuMovies(system=system)
    emu.create_blanks()

    # Set up Media
    rl.set_up_media(action="link")
    if fe == "HyperSpin" or fe == "all":
        hs = HyperSpin(system=system)
        hs.new_system(action="link", three_d=False)
    elif fe == "RetroFE" or fe == "all":
        pass
    elif fe == "MaLa" or fe == "all":
        pass
    def __init__(self, system):
        Databases.__init__(self, system)
        HyperList.__init__(self, system)
        System.__init__(self, system)

        self.system = system

        self.full_sys = {
            "name": self.system,
            "type": self.platform_type,
            "year": self.year,
            "manufacturer": self.manufacturer,
            "enabled": "true"
        }

        # Paths
        self.rl_ui_path = os.path.join(self.rl_path, "RocketLauncherUI")
        self.settings_path = os.path.join(self.rl_path, "Settings",
                                          self.system)
        self.modules_path = os.path.join(self.rl_path, "Modules")

        # Media
        self.media_path = os.path.join(self.rl_path, "Media")
        self.artwork_path = os.path.join(self.media_path, "Artwork",
                                         self.system)
        self.backgrounds_path = os.path.join(self.media_path, "Backgrounds",
                                             self.system)
        self.bezels_path = os.path.join(self.media_path, "Bezels", self.system)
        self.controller_path = os.path.join(self.media_path, "Controller",
                                            self.system)
        self.fade_path = os.path.join(self.media_path, "Fade", self.system)
        self.guides_path = os.path.join(self.media_path, "Guides", self.system)
        self.logos_path = os.path.join(self.media_path, "Logos", self.system)
        self.manuals_path = os.path.join(self.media_path, "Manuals",
                                         self.system)
        self.multi_path = os.path.join(self.media_path, "MultiGame",
                                       self.system)
        self.music_path = os.path.join(self.media_path, "Music", self.system)
        self.video_path = os.path.join(self.media_path, "Videos", self.system)

        self.media_paths = [
            self.artwork_path, self.backgrounds_path, self.bezels_path,
            self.controller_path, self.fade_path, self.guides_path,
            self.logos_path, self.manuals_path, self.multi_path,
            self.music_path, self.video_path
        ]

        # UI
        self.db_path = os.path.join(self.rl_ui_path, "Databases", self.system)
        self.icon_path = os.path.join(self.rl_ui_path, "Media", "Icons")
        self.ui_logo_path = os.path.join(self.rl_ui_path, "Media", "Logos")
        self.ui_settings_path = os.path.join(self.rl_ui_path, "Settings")
Exemple #3
0
    def put(self, system_id):
        data = request.get_json()
        if data is None or not SystemModel.valid_update_keys(data.keys()):
            abort(401)

        current_system = SystemModel.get_by_id(system_id)
        if not OwnerModel.is_owner_of(current_user, current_system):
            abort(401)

        try:
            current_system.update_from(data)
        except ValueError as e:
            abort(400, e.message)
        return jsonify(current_system.to_json())
Exemple #4
0
    def post(self):
        data = request.get_json()

        system_id = data.get('system_id')
        user_email = data.get('user_email')
        if None in (system_id, user_email):
            abort(400)

        system = System.from_system_id(system_id)
        user = User.from_email(user_email)

        if None in (system, user):
            abort(400)

        if current_user == user:
            abort(400)

        if not Owner.is_owner_of(current_user, system):
            abort(401)

        sec_obj = SecondaryModel.create(user, system)
        sec_obj.put()

        secondaries = SecondaryModel.from_system(system)
        if sec_obj not in secondaries:
            secondaries.append(sec_obj)
        ret = self.get_response_map_from_secondaries(secondaries)
        return jsonify(ret)
Exemple #5
0
 def get(self, system_id):
     """
     :param system_id:
     :return: is_connected, type_id, latest_data
     """
     data = SystemModel.get_by_id(system_id)
     return jsonify(data.to_json())
Exemple #6
0
    def __init__(self, system=None):
        Arcade.__init__(self)
        System.__init__(self, system)

        self.system = system

        # HyperSpin Paths
        self.db_path = os.path.join(self.hs_path, "Databases", self.system)
        self.media_path = os.path.join(self.hs_path, "Media", self.system)
        self.settings_path = os.path.join(self.hs_path, "Settings")
        # Images
        self.images_path = os.path.join(self.media_path, "Images")
        self.artwork1_path = os.path.join(self.images_path, "Artwork1")
        self.artwork2_path = os.path.join(self.images_path, "Artwork2")
        self.artwork3_path = os.path.join(self.images_path, "Artwork3")
        self.artwork4_path = os.path.join(self.images_path, "Artwork4")
        self.backgrounds_path = os.path.join(self.images_path, "Backgrounds")
        self.genre_backgrounds_path = os.path.join(self.images_path, "Genre", "Backgrounds")
        self.genre_wheel_path = os.path.join(self.images_path, "Genre", "Wheel")
        self.letters_path = os.path.join(self.images_path, "Letters")
        self.other_path = os.path.join(self.images_path, "Other")
        self.particle_path = os.path.join(self.images_path, "Particle")
        self.special_path = os.path.join(self.images_path, "Special")
        self.wheel_path = os.path.join(self.images_path, "Wheel")
        # Other Media
        self.themes_path = os.path.join(self.media_path, "Themes")
        self.video_path = os.path.join(self.media_path, "Video")

        self.default_systems = ["Atari 5200",
                                "Atari Lynx",
                                "Daphne",
                                "NEC TurboGrafx-16",
                                "Nintendo 64",
                                "Nintendo Entertainment System",
                                "Nintendo Game Boy Advance",
                                "Panasonic 3DO",
                                "Sega 32X",
                                "Sega CD",
                                "Sega Dreamcast",
                                "Sega Game Gear",
                                "Sega Genesis",
                                "Sega Master System",
                                "Sega Model 2",
                                "SNK Neo Geo",
                                "SNK Neo Geo Pocket Color",
                                "Sony PlayStation",
                                "Super Nintendo Entertainment System"]
Exemple #7
0
    def _system_ini(self):
        """
        "_system_ini" sets default values for the way the System menu looks in HyperSpin and sets the
        ROM path and extensions

        Args:
            self

        Returns:
            None

        Raises:
            None
        """
        platform = System(system=self.system)
        if type(platform.extensions) == list:
            extension = "zip, 7z, {}".format(platform.extensions[0])
        elif type(platform.extensions) == str:
            extension = "zip, 7z, {}".format(platform.extensions)
        else:
            extension = "zip, 7z"
        msg = "HS: Setting {} Defaults".format(self.system)
        logger.info(msg)
        ini = os.path.join(self.hs_path, "Settings", self.system + ".ini")
        if os.path.isfile(ini):
            config = configparser.ConfigParser()
            config.optionxform = str
            config.read(ini)
        else:
            src_ini = os.path.join(self.hs_path, "Settings", "MAME.ini")
            shutil.copy(src_ini, ini)
            config = configparser.ConfigParser()
            config.optionxform = str
            config.read(ini)

        config.set("exe info", "rompath", os.path.relpath(os.path.join(self.rom_path, self.system), self.hs_path))
        config.set("exe info", "romextension", extension)
        config.set("wheel", "alpha", "1")
        config.set("wheel", "style", "vertical")

        config.set("wheel", "y_rotation", "center")

        config.set("wheel", "norm_large", "256")
        config.set("wheel", "norm_small", "200")
        config.set("wheel", "vert_large", "300")
        config.set("wheel", "vert_small", "150")

        config.set("wheel", "horz_wheel_y", "575")

        config.set("video defaults", "path", os.path.join(self.media_path, "Video"))

        config.set("sounds", "game_sounds", "false")
        config.set("sounds", "wheel_click", "false")

        config.set("navigation", "remove_info_wheel", "true")
        config.set("navigation", "remove_info_text", "true")

        with open(ini, mode="w") as f:
            config.write(f, space_around_delimiters=False)
Exemple #8
0
    def get(self, system_id):
        system = System.from_system_id(system_id)
        if system is None or not Owner.is_owner_of(current_user, system):
            abort(400)

        secondaries = SecondaryModel.from_system(system)
        ret = self.get_response_map_from_secondaries(secondaries)
        return jsonify(ret)
Exemple #9
0
 def get_system(self, system_id):
     """
     :param system_id:
     :return: system details
     """
     url = "{}/systems/{}/".format(BASE_URL, system_id)
     results = self.r.get(url, headers=self._get_auth_header()).json()
     return System(**results['systems'])
Exemple #10
0
def update_system(system,
                  source_set,
                  update_roms=True,
                  action="copy",
                  three_d=False,
                  fe="HyperSpin",
                  update_rl_media=False):
    # Build ROMs of missing ROMs
    platform = System(system=system)
    if update_roms:
        emu = EmuMovies(system=system)
        emu.create_blanks()
        if len(source_set) == 0:
            curated_sets = platform.tosec_dirs(
            ) + platform.software_lists + platform.nointro + platform.goodset
            platform.build_rom_set(source_set=curated_sets)
        else:
            platform.build_rom_set(source_set=source_set)
    # Update the Media
    if update_rl_media:
        rl = RocketLauncher(system=system)
        rl.set_up_media(action="link")

    if fe == "HyperSpin" or fe == "all":
        hs = HyperSpin(system=system)
        hs.update_system(update_roms=update_roms,
                         action=action,
                         three_d=three_d)
    elif fe == "RetroFE" or fe == "all":
        pass
    elif fe == "MaLa" or fe == "all":
        pass
Exemple #11
0
    def _write_hs_menu(self, sort=False, remove=False):
        """
        "write_hs_menu" is a method that adds a system to the Main Menu.xml database, a.k.a. the Main Menu

        Args:
            self
            sort (required): If true, sorts by Manufacturer, Platform Type and Year
            remove (optional): If tru, removes the system from the Menu

        Returns:
            None

        Raises:
            None
        """
        systems = self._read_hs_menu()

        if remove:
            systems.remove(self.system)
        elif self.system not in systems:
            systems.append(self.system)

        platform = {}
        platforms = []

        for system in systems:
            plat = System(system)
            platform["name"] = plat.system
            platform["manufacturer"] = plat.manufacturer.lower()
            platform["type"] = plat.platform_type.lower()
            platform["year"] = plat.year
            platforms.append(dict(platform))

        # Sort by Manufacturer, then by Platform type, then by Year
        if sort:
            final_systems = sorted(platforms, key=lambda platform: (
                platform["manufacturer"],
                platform["type"],
                platform["year"]))
        else:
            final_systems = platforms
        xml = os.path.join(self.hs_path, "Databases", "Main Menu", "Main Menu.xml")
        try:
            shutil.copy(xml, "{}_backup_{}.xml".format(xml, time.strftime("%Y%m%d")))
            root = ET.Element("menu")
            for name in final_systems:
                ET.SubElement(root, "game", name=name["name"])
        except FileNotFoundError:
            msg = "System Menu does not exist"
            logger.info(msg)
            root = ET.Element("menu")
            for name in final_systems:
                ET.SubElement(root, "game", name=name["name"])

        pretty = self.prettify(root)
        with open(xml, mode="w") as xml:
            xml.write(pretty)
Exemple #12
0
 def get_systems(self):
     """
     :return: list of systems
     """
     url = "{}/systems/".format(BASE_URL)
     results = self.r.get(url, headers=self._get_auth_header()).json()
     systems = []
     for system in results['systems']:
         systems.append(System(**system))
     return systems
Exemple #13
0
    def update_device_association(self, serial_number, req_data):
        system_id = req_data.get("system_id")
        device = DeviceModel.from_serial_number(serial_number)
        if device is None:
            abort(400, 'No such device.')

        if system_id is not None:
            system = System.from_system_id(system_id)
            return self.associate_device(device, system)
        else:
            return self.disassociate_device(device)
Exemple #14
0
    def put(self, system_id):
        data = request.get_json()
        if data is None or not SystemModel.valid_update_keys(data.keys()):
            abort(401)

        ks_status = data.get("ks_enabled")
        if ks_status is None:
            abort(400)

        current_system = SystemModel.get_by_id(system_id)

        owner = OwnerModel.is_owner_of(current_user, current_system)
        is_sec, _ = SecondaryModel.is_secondary_of(current_user,
                                                   current_system)

        if not (owner or is_sec):
            abort(401)

        current_system.ks_enabled = ks_status
        current_system.put()

        return jsonify(current_system.to_json())
Exemple #15
0
    def create_blanks(self, extension="txt"):
        """
        "create_blanks" Method creates temporary files in a new directory in your EmuMovies folder.
        This proves useful if you would like to use EmuMovies to gather the artwork
        and movies for ROMs you may not have.

        Args:
            extension(optional, default = txt):  extension of the file

        Returns:
            None

        Raises:
            None
        """
        from models.system import System
        platform = System(system=self.system)
        db = Databases(system=self.system)
        system, roms = db.read_system_xml(
            db=os.path.join(self.rl_path, "RocketLauncherUI", "Databases",
                            self.system, "{}.xml".format(self.system)))
        temp_dir = os.path.join(self.emu_movies_path, platform.emu_movies_name,
                                "_Temp")
        if not os.path.isdir(temp_dir):
            os.makedirs(temp_dir)
        num = 0
        num_of_roms = len(roms)
        for rom in roms:
            if num % 100 == 0:
                msg = "Creating {} of {} temp ROM Files".format(
                    num, num_of_roms)
                logger.info(msg)
            elif num == num_of_roms:
                msg = "Creating {} of {} temp ROM Files".format(
                    num + 1, num_of_roms)
                logger.info(msg)
            num += 1

            tempfile = "{}.{}".format(rom["name"], extension)
            fname = os.path.join(temp_dir, tempfile)

            with open(fname, mode="w", encoding="UTF-8") as f:
                f.write("ROM Name:      {}\n".format(rom["name"]))
                f.write("Description:   {}\n".format(rom["description"]))
                f.write("Clone Of:      {}\n".format(rom["cloneof"]))
                f.write("CRC:           {}\n".format(rom["crc"]))
                f.write("Manufacturer:  {}\n".format(rom["manufacturer"]))
                f.write("Year:          {}\n".format(rom["year"]))
                f.write("Genre:         {}\n".format(rom["genre"]))
                f.write("Rating:        {}\n".format(rom["rating"]))
                f.write("Enabled:       {}".format(rom["enabled"]))
Exemple #16
0
    def get(self, system_id):
        system = SystemModel.from_system_id(system_id)

        is_owner = OwnerModel.is_owner_of(current_user, system)
        is_sec, _ = SecondaryModel.is_secondary_of(current_user, system)

        if not (is_owner or is_sec):
            abort(401)

        frames = system.get_latest_data_frames()

        devid_loc = {
            f.device_key.get().serial_num: get_download_url(f.location)
            for f in frames
        }
        return jsonify(devid_loc)
Exemple #17
0
    def read_database(self):
        """
        "read_database" Reads the No Intro XML based databases and sorts the information into a dictionary of
        values to be used to create a RocketLauncher Database.

        Args:
            self

        Returns:
            Dictionary of ROM names with descriptive info

        Raises:
            None
        """
        root_path = os.path.join(self.clrmamepro, "datfiles", "NoIntro")
        files = os.listdir(root_path)
        from models.system import System
        platform = System(self.system)
        db = ""
        for fname in files:
            no_intro_name = fname.split(" (")
            if no_intro_name[0] == platform.nointro_db:
                db = os.path.join(root_path, fname)
                msg = "Using the database found at {}".format(db)
                logger.info(msg)

        with open(db, mode="r") as fd:
            doc = xmltodict.parse(fd.read())

        output = {}
        roms = []
        data = doc["datafile"]["game"]
        for rom_info in data:
            output["name"] = rom_info["@name"]
            output["crc"] = rom_info["rom"]["@crc"].zfill(8).upper()
            output["md5"] = rom_info["rom"]["@md5"]
            output["sha1"] = rom_info["rom"]["@sha1"]
            roms.append(dict(output))

        languages = [
            'Cs', 'Da', 'De', 'El', 'En', 'Es', 'Fi', 'Fr', 'Hu', 'It', 'Ja',
            'Ko', 'Nl', 'No', 'Pl', 'Pt', 'Ru', 'Sv', 'Tr'
        ]
        regions = [
            'Asia', 'Australia', 'Brazil', 'Canada', 'China', 'Denmark',
            'Europe', 'Finland', 'France', 'Germany', 'Greece', 'Hong Kong',
            'Italy', 'Japan', 'Korea', 'Mexico', 'Netherlands', 'Norway',
            'Russia', 'Spain', 'Sweden', 'Taiwan', 'USA', 'Unknown', 'World'
        ]
        bad_dump = "[b]"
        bios = "[BIOS]"

        for rom in roms:
            temp1 = rom["name"].replace(bad_dump, "(b)")
            temp2 = temp1.replace(")", "")
            rom_list = temp2.split(" (")
            rom["short_desc"] = rom_list[0]
            if bios in rom_list[0]:
                rom["bios"] = True
            if len(rom_list[1:]) > 1:
                for i in rom_list[1:]:
                    if i == "b":
                        rom["bad_dump"] = True
                    elif i in regions:
                        rom["region"] = i
                    elif i == "Demo":
                        rom["demo"] = True
                    elif "Kiosk" in i:
                        rom["Kiosk"] = True
                    elif i == "Unl":
                        rom["unl"] = True
                    elif "Rev" in i:
                        rom["rev"] = i
                    elif "NDSi Enhanced" in i:
                        rom["NDSi Enhanced"] = True
                    elif "SGB Enhanced" in i:
                        rom["SGB Enhanced"] = True
                    elif "GB Compatible" in i:
                        rom["GB Compatible"] = True
                    elif "Wii Virtual Console" in i:
                        rom["Wii Virtual Console"] = True
                    elif "iQue" in i:
                        rom["iQue"] = True
                    elif "Proto" in i:
                        rom["prototype"] = True
                    elif "Beta" in i:
                        rom["beta"] = True
                    elif i in languages:
                        rom["language"] = [i]
                    elif "," in i:
                        stuff = [x.strip() for x in i.split(',')
                                 ]  # Split the string and remove whitespace
                        for j in stuff:
                            if j in languages:
                                rom["language"] = stuff
                            elif j in regions:
                                rom["region"] = stuff
            elif len(rom_list[1:]) == 1:
                if "," in rom_list[1]:
                    stuff = rom_list[1].split(", ")
                    if stuff[0] in regions:
                        rom["region"] = stuff
                elif rom_list[1] in regions:
                    rom["region"] = rom_list[1]
        return roms
Exemple #18
0
def random_system():
    s = System.create(60)
    s.put()
    yield s
    s.key.delete()
Exemple #19
0
plt.close("all")
plt.rc('text', usetex=True)
plt.rc('font', family='serif')

phi_init = 0.0

t_sim_end = 60  # sec
sampling_rate = 100  # Hz
N = t_sim_end * sampling_rate + 1
time = np.linspace(0, t_sim_end, num=N)
''' Define flight plan as below '''
wpt_list = np.array([20., 0., 20., 800.])
wpt_arr = np.ndarray(shape=(2, 2), dtype=float, buffer=wpt_list)
''' Define simulation components '''
sys = System(phi=phi_init, psi=0, use_jac=True)
env = Env(wind_dir_to=np.deg2rad(120), wind_spd=13)
fpl = FlightPlan(wpt_arr)
ac = Aircraft(fpl)

''
sim = Sim(ac, sys, env, time, verbose=False)
#sim.override_roll(np.deg2rad(40))
sim.run_simulation()

fig1 = plt.figure()
wp = ac.flight_plan.wpt_arr
plt.plot(sim.logs['S_x'][:-2], sim.logs['S_y'][:-2], wp[:, 0], wp[:, 1], 'ro',
         wp[:, 0], wp[:, 1], 'r')
# plt.plot(time[:-2], sim.logs['x'][:-2])
plt.grid()
Exemple #20
0
N = t_sim_end * sampling_rate + 1
time = np.linspace(0, t_sim_end, num=N)
''' Define flight plan as below '''
# TODO the two mirrored flight plans below demonstrate the twofold effects of the suggested improvements
wpt_list = np.array([0., 0., 0., 80., -20., 40., -20., 300., 200., 300.])
wpt_listA = np.array([0., 0., 0., 80., 20., 40., 20., 300., -200., 300.])
wpt_listB = np.array([0., 0., 0., 80., 150., 80., 150., 300., -200., 300.])
wpt_listC = np.array([0., 0., 0., 80., -150., 80., -150., 300., 200., 300.])
wpt_arr = np.ndarray(shape=(5, 2), dtype=float, buffer=wpt_listA)
''' Define simulation components '''
ac_tas = 15.
env = Env(wind_dir_to=np.deg2rad(90), wind_spd=12)
init = bn.get_wind_corr(track_angle=np.deg2rad(0),
                        tas=ac_tas,
                        wind_obs=env.wind_to)
sys = System(phi=phi_init, psi=init[0], use_jac=True)

fpl = FlightPlan(wpt_arr, accept_dist=60)
rreg = RollRegulator(phi_max=42)  # default phi_max is 35
nreg = L1NavRegulator(period=20)  # default period is 30
ac = Aircraft(fpl, roll_reg=rreg, nav_reg=nreg, tas=ac_tas)

sim = Sim(ac, sys, env, time, verbose=False)
#sim.override_roll(np.deg2rad(40))
sim.run_simulation()

fig1 = plt.figure()
wp = ac.flight_plan.wpt_arr
plt.plot(sim.logs['S_x'][:-2], sim.logs['S_y'][:-2], wp[:, 0], wp[:, 1], 'ro',
         wp[:, 0], wp[:, 1], 'r', sim.logs['S_x'][:-2:f * 2],
         sim.logs['S_y'][:-2:f * 2], 'gx')
Exemple #21
0
import time
from tkinter import *
from gui.create_table import create_table
from models.system import System, CacheL2, Memory, Lock
from threading import Thread
from utils.utils import format_instruction

lock = Lock()
cache_l2 = CacheL2()
memory = Memory()
system = System(cache_l2, memory, lock)
# system.change_mode(1)
system.start()


def run_gui():
    container = Canvas(root, width=940, height=40, bg='#42db8c')
    container.place(x=0, y=460)

    p_numbers = ["P0", "P1", "P2", "P3"]
    p_number_var = StringVar()
    p_number_var.set("P0")
    p_number = OptionMenu(root, p_number_var, *p_numbers)
    p_number.place(x=30, y=470, width=50)

    instruction_types = ["READ", "WRITE", "CALC"]
    instruction_type_var = StringVar()
    instruction_type_var.set("READ")
    instruction_type = OptionMenu(root, instruction_type_var,
                                  *instruction_types)
    instruction_type.place(x=90, y=470, width=100)
Exemple #22
0
def detect(user_id, system_name, filename):
    document_warn_events = []
    possible_abnormal_clusters = []

    old_result = Result.objects(path=f'{system_name}/{filename}')
    if old_result:
        events = old_result.get().events

        for event in events:
            if event.status == 'WARN':
                document_warn_events.append(event)

        clusters = old_result.get().clusters

        for cluster in clusters:
            if cluster.num_possible_abnormal_events != 0:
                possible_abnormal_clusters.append(cluster)

    else:
        parser = LogParser(
            f'{config.UPLOADS_FOLDER}/{user_id}/{system_name}/{filename}')
        events, log_sequences = parser.parse()

        extractor = FeatureExtractor(log_sequences, events)
        log_sequences = extractor.extract()

        clustering = Clustering(log_sequences, events)
        log_sequences, clusters = clustering.cluster()

        document_clusters = []
        for cluster in clusters:
            document_clusters.append(
                Cluster(centroid=cluster.get('centroid'),
                        num_possible_abnormal_events=cluster.get(
                            'num_possible_abnormal_events'),
                        possible_abnormal_events=cluster.get(
                            'possible_abnormal_events')))

        document_events = []
        document_names = []
        for name, status in events.items():
            document_events.append(Event(name=name, status=status))
            document_names.append(name)

        system = System.objects(name=system_name).first()

        system_events_name = [event.name for event in system.events]

        setEvents = set(document_names)
        setSystemEventsName = set(system_events_name)

        unregisteredEvents = list(setEvents - setSystemEventsName)

        document_unregister_events = []

        for name, status in events.items():
            if name in unregisteredEvents:
                document_unregister_events.append(
                    Event(name=name, status=status))
            if status == 'WARN':
                document_warn_events.append(Event(name=name, status=status))

        system.events = document_unregister_events
        system.save()

        result = Result(user_id=user_id,
                        path=f'{system_name}/{filename}',
                        events=document_events,
                        clusters=document_clusters)

        result.save()

        for cluster in document_clusters:
            if cluster.num_possible_abnormal_events != 0:
                possible_abnormal_clusters.append(cluster)

    return jsonify({
        'events': document_warn_events,
        'clusters': possible_abnormal_clusters
    })
Exemple #23
0
def test_system_from_id_none():
    assert System.from_system_id(None) is None
Exemple #24
0
def test_system_from_id(random_system):
    assert random_system == System.from_system_id(
        random_system.key.integer_id())
Exemple #25
0
 def loadSystems(self):
     self.systems = System.select()
Exemple #26
0
 def create(cls, user_obj, grace):
     system = System.create(grace)
     system.put()
     return cls(user_key=user_obj.key, system_key=system.key)
Exemple #27
0
 def loadSystems(self):
     self.systems = System.select()