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


Python Environment.get_ticket方法代码示例

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


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

示例1: download_transaction_files

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_ticket [as 别名]
    def download_transaction_files(self, transactions):
        '''This uses a simple httpd download mechanism to get the files.
        '''

        remote_host = sync_utils.get_remote_host()

        download_mode = 'http'

        # Try a mode where files are zipped
        if download_mode == 'zip':
            remote_server.download_zip(paths)



        # go through each transaction and look at the files
        for transaction in transactions:
            transaction_xml = transaction.get("transaction")
            cmd = TransactionFilesCmd(transaction_xml=transaction_xml, mode='relative')
            paths = cmd.execute()


            # download to the temp dir
            to_dir = Environment.get_tmp_dir()
            ticket = Environment.get_ticket()
            to_dir = "%s/%s" % (to_dir, ticket)

            # or we could download directly to that asset directory
            base_dir = Environment.get_asset_dir()

            # do the slow method
            for path in paths:
                url = "%s/assets/%s" % (remote_host, path)

                print("downloading: ", url)
                remote_server.download(url, to_dir)

                # FIXME: the problem with this is that it is not undoable
                #dirname = os.path.dirname(path)
                #to_dir = "%s/%s" % (base_dir, dirname)
                #print("to_dir: ", to_dir)


                remote_server.download(url, to_dir)
开发者ID:mincau,项目名称:TACTIC,代码行数:45,代码来源:run_transaction_cmd.py

示例2: execute

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_ticket [as 别名]
    def execute(my):

        template_dir = Environment.get_template_dir()

        # find the 
        template_dir = my.kwargs.get("template_dir")
        if not template_dir:
            return


        path = None

        template_name = os.path.basename(template_dir)
        template_dir = os.path.dirname(template_dir)

        filenames = os.listdir(template_dir)
        for filename in filenames:
            if not filename.endswith(".zip"):
                continue

            if filename.startswith(template_name):
                path = "%s/%s" % (template_dir, filename)
                break

        if not path:
            return


        asset_dir = Environment.get_asset_dir()

        ticket = Environment.get_ticket()
        cache_dir = "%s/_cache/%s" % (asset_dir, ticket)

        if not os.path.exists(cache_dir):
            os.makedirs(cache_dir)

        shutil.copy(path, cache_dir)

        my.info["filename"] = filename
开发者ID:0-T-0,项目名称:TACTIC,代码行数:41,代码来源:project_template_wdg.py

示例3: send_request

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_ticket [as 别名]
    def send_request(my, url, headers, data={} ):

        ticket = Environment.get_ticket()

        method = headers.get("Method")
        if method == 'POST':
            data['login_ticket'] = ticket
            import urllib
            data = urllib.urlencode(data)
            request = urllib2.Request(url, data)
        else:
            url = "%s?login_ticket=%s" % (url, ticket)
            request = urllib2.Request(url)

        for key,value in headers.items():
            request.add_header(key,value)

        try:
            response = urllib2.urlopen(request)
        except Exception, e:
            # try again
            print "WARNING: ", e
            response = urllib2.urlopen(request)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:25,代码来源:rest_test.py

示例4: execute

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_ticket [as 别名]
    def execute(self):

        import datetime
        now = datetime.datetime.now()
        version = now.strftime("%Y%m%d_%H%M%S")


        project_code = self.kwargs.get("project_code")
        if project_code:
            project = Project.get_by_code(project_code)
        else:
            project = Project.get()
        project_code = project.get_code()

        server_code = self.kwargs.get("server")
        assert server_code

        if not isinstance(server_code, basestring):
            server_code = server_code.get_value("code")


        base_dir = self.kwargs.get('base_dir')
        ticket = Environment.get_ticket()
        tmp_dir = "%s/sync_%s" % (Environment.get_tmp_dir(), ticket)
        if not os.path.exists(tmp_dir):
            os.makedirs(tmp_dir)


        server = Search.get_by_code("sthpw/sync_server", server_code)
        if server.get_value("sync_mode") == "file":
            if not base_dir:
                base_dir = server.get_value("base_dir")

        else:
            raise Exception("sync mode [%s] not support" % sync_mode)
            # FIXME: not sure if this is valid anymore
            asset_dir = Environment.get_asset_dir()
            base_dir = "%s/_temp" % asset_dir


        # create the project template
        from tactic.command import ProjectTemplateCreatorCmd
        cmd = ProjectTemplateCreatorCmd(project_code=project_code, version=version, base_dir=tmp_dir)
        cmd.execute()

        project_path = cmd.get_zip_path()


        # create zip of the project files
        from pyasm.common import ZipUtil
        zip_util = ZipUtil()
        asset_dir = Environment.get_asset_dir()
        project_dir = "%s/%s" % (asset_dir, project_code)

        zip_dir = "%s/%s" % (tmp_dir, project_code)
        file_path = "%s-files-%s.zip" % (zip_dir, version)

        if os.path.exists(file_path):
            os.unlink(file_path)
        zip_util.zip_dir2(project_dir, zip_path=file_path)




        # create a manifest for all the data in the project.
        xml = Xml()
        self.xml = xml

        xml.create_doc("manifest")
        manifest_node = xml.get_root_node()
        xml.set_attribute(manifest_node, "code", "%s-data" % project_code)

        search_types = project.get_search_types()

        # just dump the data
        for search_type in search_types:
            data_node = xml.create_element("sobject")
            xml.append_child(manifest_node, data_node)
            xml.set_attribute(data_node, "search_type", search_type.get_value("search_type"))


        # dump the note entries
        data_node = xml.create_element("sobject")
        xml.append_child(manifest_node, data_node)
        xml.set_attribute(data_node, "expression", "@SOBJECT(sthpw/note['project_code','%s'])" % project_code)
        xml.set_attribute(data_node, "search_type", "sthpw/note")


        # dump the task entries
        data_node = xml.create_element("sobject")
        xml.append_child(manifest_node, data_node)
        xml.set_attribute(data_node, "expression", "@SOBJECT(sthpw/task['project_code','%s'])" % project_code)
        xml.set_attribute(data_node, "search_type", "sthpw/task")


        # dump the snapshot entries
        data_node = xml.create_element("sobject")
        xml.append_child(manifest_node, data_node)
        xml.set_attribute(data_node, "expression", "@SOBJECT(sthpw/snapshot['project_code','%s'])" % project_code)
        xml.set_attribute(data_node, "search_type", "sthpw/snapshot")
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:sync_settings_wdg.py


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