当前位置: 首页>>代码示例>>Python>>正文


Python TacticServerStub.execute_cmd方法代码示例

本文整理汇总了Python中tactic_client_lib.TacticServerStub.execute_cmd方法的典型用法代码示例。如果您正苦于以下问题:Python TacticServerStub.execute_cmd方法的具体用法?Python TacticServerStub.execute_cmd怎么用?Python TacticServerStub.execute_cmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tactic_client_lib.TacticServerStub的用法示例。


在下文中一共展示了TacticServerStub.execute_cmd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from tactic_client_lib import TacticServerStub [as 别名]
# 或者: from tactic_client_lib.TacticServerStub import execute_cmd [as 别名]
    def execute(self):
        # This will go to a registered remote server and get the project

        #server_code = self.kwargs.get("server")
        #assert server_code
        ## get the registered server
        #server = Search.get_by_code("sthpw/sync_server", server_code)
        #assert server


        project_code = self.kwargs.get("project_code")
        assert project_code

        version = self.kwargs.get("version")
        if not version:
            version = "1.0.0"


        # build the project names
        template_name = "%s-%s.zip" % (project_code, version)
        data_name = "%s-data-%s.zip" % (project_code, version)
        file_name = "%s-files-%s.zip" % (project_code, version)

        tmp_dir = Environment.get_tmp_dir()
        to_dir = tmp_dir
        to_template_path = "%s/%s-%s.zip" % (to_dir, project_code, version)
        to_data_path = "%s/%s-data-%s.zip" % (to_dir, project_code, version)
        to_file_path = "%s/%s-files-%s.zip" % (to_dir, project_code, version)




        #sync_mode = server.get_value("sync_mode")
        sync_mode = "file"

        if sync_mode == "file":
            base_dir = self.kwargs.get("base_dir")

            from_template_path = "%s/%s" % (base_dir, template_name)
            from_data_path = "%s/%s" % (base_dir, data_name)
            from_file_path = "%s/%s" % (base_dir, file_name)
            to_file_path = from_file_path

            # copy the files 
            # ???? why are we copying here?
            shutil.copy(from_template_path, to_template_path)
            shutil.copy(from_data_path, to_data_path)

        else:


            # TEST TEST TEST
            ticket = server.get_value("server")

            remote_server = TacticServerStub(
                protocol='xmlrpc',
                server=server,
                project=project_code,
                #user=user,
                #password=password,
                ticket=ticket,
            )


            class_name = 'tactic.ui.sync.SyncCreateTemplateCmd'
            kwargs = {
                'project_code': project_code
            }
            remote_server.execute_cmd(class_name, kwargs)

            base_url = "http://%s/assets/_temp/" % server


            # download and install the files


            from_template_path = "%s/%s_template-%s.zip" % (base_url, project_code, version)
            from_data_path = "%s/%s_data-%s.zip" % (base_url, project_code, version)

            remote_server.download(from_template_path, to_dir)
            remote_server.download(from_data_path, to_dir)



        # This makes the pretty big assumption that this is an official template
        if not os.path.exists(to_template_path):
            raise Exception("Path [%s] does not exist" % to_template_path)

        template_code = project_code

        try:
            new_project = False

            from tactic.command import ProjectTemplateInstallerCmd

            cmd = ProjectTemplateInstallerCmd(project_code=project_code, path=to_template_path,template_code=template_code, new_project=new_project, version=version)
            cmd.execute()

            Project.set_project(project_code)
            project = Project.get()
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:sync_settings_wdg.py


注:本文中的tactic_client_lib.TacticServerStub.execute_cmd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。