Exemplo n.º 1
0
    def setUp(self):
        new_dota_dir()
        self.manager = ModManager()
        #         self.real_method = self.manager._dota_path
        #         self.manager._dota_path = Mock(return_value = mkdtemp())

        self.mod1_folder = join(self.manager._d2mp_path(), "mod1")
        self.mod1_info_file = join(self.mod1_folder, "addoninfo.txt")

        self.mod2_folder = join(self.manager._d2mp_path(), "mod2")
        self.mod2_info_file = join(self.mod2_folder, "addoninfo.txt")

        self.mod_to_delete_folder = join(self.manager._d2mp_path(),
                                         "mod_to_delete")
        self.mod_to_delete_info_file = join(self.mod2_folder, "addoninfo.txt")

        self.mods = [basename(f) for f in [self.mod1_folder, self.mod2_folder]]

        for folder in [
                self.mod1_folder, self.mod2_folder, self.mod_to_delete_folder
        ]:
            if not isdir(folder): os.mkdir(folder)

        for f in [
                self.mod1_info_file, self.mod2_info_file,
                self.mod_to_delete_info_file
        ]:
            if not isfile(f): open(f, "w").close()

        shutil.rmtree(self.manager._mod_path())
Exemplo n.º 2
0
 def _init_message(self):
     man = ModManager()
     return {
         "msg": "init",
         "SteamIDs": man.steam_ids(),
         "Mods": man.mods_as_json(),
         "Version": man.get_version(),
     }
Exemplo n.º 3
0
    def setUp(self):
        new_dota_dir()
        ModManager.install_mod = Mock(side_effect=self.send_reply)
        XSocketsClient.start = Mock()
        ConnectionManager.send = Mock()

        self.manager = ModManager()
        self.con = ConnectionManager()
        self.manager.signals.message.connect(self.con.send)
Exemplo n.º 4
0
def command(cmd):
    if sys.platform == "darwin":
        return call(["open", ModManager().steam_exe(), "steam://%s" % cmd])
    else:
        return call([ModManager().steam_exe(), "steam://%s" % cmd])
Exemplo n.º 5
0
 def _create_mod_manager(self):
     self.manager = ModManager()
     self.manager.mod_game_info()
     self.manager.signals.message.connect(self.show_message_from_mod_manager)
     self.manager.signals.error.connect(self.show_error_from_mod_manager)
Exemplo n.º 6
0
 def show_mod_list(self):
     self.show_message("Mod List", ModManager().mod_names_as_string())
Exemplo n.º 7
0
    def uninstall(self):
        ModManager().delete_mods()
#         ModManager().uninstall_d2mp()
        self.exit()
Exemplo n.º 8
0
 def _command_set_mod(self, content):
     ModManager().set_mod(content["Mod"]["name"])
Exemplo n.º 9
0
 def _command_del_mod(self, content):
     mod_name = content["Mod"]["name"]
     version = content["Mod"]["version"]
     self.message.emit("Uninstalling Mod %s v%s" % (mod_name, version))
     ModManager().delete_mod(mod_name, version)
Exemplo n.º 10
0
 def _command_install_mod(self, content):
     url = content["url"]
     mod_name = content["Mod"]["name"]
     version = content["Mod"]["version"]
     self.message.emit("Installing Mod %s v%s" % (mod_name, version))
     ModManager().install_mod(mod_name, version, url)
Exemplo n.º 11
0
    def test_singleton(self):
        man1 = ModManager()
        man2 = ModManager()

        self.assertEqual(man1, man2)
Exemplo n.º 12
0
    def setUp(self):
        self.dota_info_normal = """
            "GameInfo"
            {
              game  "DOTA 2"
              gamelogo 1
              type multiplayer_only
              nomodels 1
              nohimodel 1
              nocrosshair 0
              GameData        "dota.fgd"
              SupportsDX8 0
            
            
              FileSystem
              {
                SteamAppId        816
                ToolsAppId        211
                
                SearchPaths
                {
                  Game        |gameinfo_path|.
                  Game        platform
                }
              }
            }"""

        self.dota_info_modded = """
             "GameInfo"
            {
              game  "DOTA 2"
              gamelogo 1
              type multiplayer_only
              nomodels 1
              nohimodel 1
              nocrosshair 0
              GameData        "dota.fgd"
              SupportsDX8 0
            
            
              FileSystem
              {
                SteamAppId        816
                ToolsAppId        211
                
                SearchPaths
                {
                  Game        |gameinfo_path|.
                  Game        platform
                  Game        |gameinfo_path|addons\d2moddin
                }
              }
            }"""

        new_dota_dir()
        self.manager = ModManager()
        #         self.real_method = self.manager._dota_path
        #         self.manager._dota_path = Mock(return_value = mkdtemp())
        dota_subdir = join(self.manager._dota_path(), "dota")
        if not isdir(dota_subdir): mkdir(dota_subdir)
        write_to_file(self.manager.dota_info_file(), self.dota_info_normal)