Exemple #1
0
 def update_mod(self, params):
     try:
         update_file = self.file_pick({"multiple": False})[0]
     except IndexError:
         return
     mod = BcmlMod.from_json(params["mod"])
     if (mod.path / "options.json").exists():
         options = json.loads((mod.path / "options.json").read_text(),
                              encoding="utf-8")
     else:
         options = {}
     remergers = mergers.get_mergers_for_mod(mod)
     rmtree(mod.path)
     with Pool(maxtasksperchild=1000) as pool:
         new_mod = install.install_mod(
             Path(update_file),
             insert_priority=mod.priority,
             options=options,
             pool=pool,
         )
         remergers |= {
             m
             for m in mergers.get_mergers_for_mod(new_mod)
             if m.NAME not in {m.NAME
                               for m in remergers}
         }
         try:
             install.refresh_merges()
         except Exception:  # pylint: disable=broad-except
             pool.terminate()
             raise
Exemple #2
0
 def get_mod_edits(self, params=None):
     mod = BcmlMod.from_json(params["mod"])
     edits = {}
     merger_list = sorted({m() for m in mergers.get_mergers()}, key=lambda m: m.NAME)
     for merger in merger_list:
         edits[merger.friendly_name] = merger.get_mod_edit_info(mod)
     return {key: sorted({str(v) for v in value}) for key, value in edits.items()}
Exemple #3
0
 def reprocess(self, params):
     mod = BcmlMod.from_json(params["mod"])
     rmtree(mod.path / "logs")
     if (mod.path / "options.json").exists():
         options = json.loads((mod.path / "options.json").read_text())
     else:
         options = {}
     install.generate_logs(mod.path, options)
Exemple #4
0
 def mod_action(self, params):
     mod = BcmlMod.from_json(params["mod"])
     action = params["action"]
     if action == "enable":
         install.enable_mod(mod)
     elif action == "disable":
         install.disable_mod(mod)
     elif action == "uninstall":
         install.uninstall_mod(mod)
     elif action == "update":
         self.update_mod(params)
     elif action == "reprocess":
         self.reprocess(params)
Exemple #5
0
 def update_mod(self, params):
     try:
         update_file = self.file_pick({"multiple": False})[0]
     except IndexError:
         return
     mod = BcmlMod.from_json(params["mod"])
     if (mod.path / "options.json").exists():
         options = json.loads((mod.path / "options.json").read_text())
     else:
         options = {}
     rmtree(mod.path)
     with Pool(maxtasksperchild=500) as pool:
         new_mod = install.install_mod(
             Path(update_file),
             insert_priority=mod.priority,
             options=options,
             pool=pool,
         )
Exemple #6
0
 def get_mod_info(self, params):
     mod = BcmlMod.from_json(params["mod"])
     util.vprint(mod)
     img = ""
     try:
         img = base64.b64encode(mod.get_preview().read_bytes()).decode("utf8")
     except:  # pylint: disable=bare-except
         pass
     return {
         "changes": [
             m.NAME.upper() for m in mergers.get_mergers() if m().is_mod_logged(mod)
         ],
         "desc": mod.description,
         "date": mod.date,
         "processed": (mod.path / ".processed").exists(),
         "image": img,
         "url": mod.url,
     }
Exemple #7
0
 def apply_queue(self, params):
     mods = []
     for move_mod in params["moves"]:
         mod = BcmlMod.from_json(move_mod["mod"])
         mods.append(mod)
         mod.change_priority(move_mod["priority"])
     with Pool(maxtasksperchild=500) as pool:
         for i in params["installs"]:
             print(i)
             mods.append(
                 install.install_mod(
                     Path(i["path"].replace("QUEUE", "")),
                     options=i["options"],
                     insert_priority=i["priority"],
                     pool=pool,
                 ))
         try:
             install.refresh_merges()
         except Exception:  # pylint: disable=broad-except
             pool.terminate()
             raise
     install.refresh_master_export()