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


Python SPTDate.add_gmt_timezone方法代码示例

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


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

示例1: get_display

# 需要导入模块: from pyasm.common import SPTDate [as 别名]
# 或者: from pyasm.common.SPTDate import add_gmt_timezone [as 别名]
    def get_display(my):
        sobject = my.get_current_sobject()
        name = my.get_name()
        value = my.get_value()

        if sobject:
            data_type = SearchType.get_column_type(sobject.get_search_type(), name)
        else:
            data_type = 'text'

        if data_type == "timestamp" or my.name == "timestamp":
	    if value == 'now':
                value = ''
            elif value:
                date = parser.parse(value)
                value = SPTDate.add_gmt_timezone(date)
                value = str(value)
            else:
                value = ''

        return value
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:23,代码来源:base_table_element_wdg.py

示例2: execute

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

        start = time.time()

        from pyasm.common import SPTDate
        timestamp = SPTDate.now()
        timestamp = SPTDate.add_gmt_timezone(timestamp)
        timestamp = SPTDate.convert_to_local(timestamp)
        format = '%Y-%m-%d %H:%M:%S'
        timestamp = timestamp.strftime(format)


        updates = my.kwargs.get("updates")
        if isinstance(updates, basestring):
            updates = jsonloads(updates)

        last_timestamp = my.kwargs.get("last_timestamp")
        #assert last_timestamp
        if not last_timestamp:
            my.info = {
                "updates": {},
                "timestamp": timestamp
            }
            return

        last_timestamp = parser.parse(last_timestamp)
        last_timestamp = SPTDate.add_gmt_timezone(last_timestamp)
        #last_timestamp = last_timestamp - timedelta(hours=24)


        #print "last: ", last_timestamp

        # get out all of the search_keys
        client_keys = set()
        for id, values_list in updates.items():
            if isinstance(values_list, dict):
                values_list = [values_list]

            for values in values_list:
                handler = values.get("handler")
                if handler:
                    handler = Common.create_from_class_path(handler)
                    search_key = handler.get_search_key()
                else:
                    search_key = values.get("search_key")

                if search_key:
                    client_keys.add(search_key)

        # find all of the search that have changed
        changed_keys = set()
        for check_type in ['sthpw/change_timestamp', 'sthpw/sobject_log']:
            search = Search(check_type)
            search.add_filter("timestamp", last_timestamp, op=">")
            search.add_filters("search_type", ["sthpw/sobject_log", "sthpw/status_log"], op="not in")
            #print search.get_statement()
            changed_sobjects = search.get_sobjects()
            for sobject in changed_sobjects:
                search_type = sobject.get_value("search_type")
                search_code = sobject.get_value("search_code")
                if search_type.startswith("sthpw/"):
                    search_key = "%s?code=%s" % (search_type, search_code)
                else:
                    search_key = "%s&code=%s" % (search_type, search_code)
                changed_keys.add(u'%s'%search_key)

        intersect_keys = client_keys.intersection(changed_keys)

        #for x in client_keys:
        #    print x
        #print "---"
        #print "changed_keys: ", changed_keys
        #print "---"
        #print "intersect_keys: ", intersect_keys


        from pyasm.web import HtmlElement

        results = {}
        for id, values_list in updates.items():

            if isinstance(values_list, dict):
                values_list = [values_list]


            for values in values_list:

                handler = values.get("handler")
                if handler:
                    handler = Common.create_from_class_path(handler)
                    search_key = handler.get_search_key()
                else:
                    search_key = values.get("search_key")

                if search_key and search_key not in intersect_keys:
                    continue

                # evaluate any compare expressions
                compare = values.get("compare")
                if compare:
#.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:TACTIC,代码行数:103,代码来源:dynamic_update_wdg.py

示例3: execute

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

        start = time.time()

        from pyasm.common import SPTDate
        timestamp = SPTDate.now()
        timestamp = SPTDate.add_gmt_timezone(timestamp)
        timestamp = SPTDate.convert_to_local(timestamp)
        format = '%Y-%m-%d %H:%M:%S'
        timestamp = timestamp.strftime(format)
        
        updates = my.kwargs.get("updates")
        if isinstance(updates, basestring):
            updates = jsonloads(updates)
        last_timestamp = my.kwargs.get("last_timestamp")
        #assert last_timestamp
        if not last_timestamp:
            my.info = {
                "updates": {},
                "timestamp": timestamp
            }
            return

        last_timestamp = parser.parse(last_timestamp)
        last_timestamp = SPTDate.add_gmt_timezone(last_timestamp)
        
        # give 2 seconds of extra room 
        last_timestamp = last_timestamp - timedelta(seconds=2)


        # get out all of the search_keys
        client_keys = set()
        client_stypes = set()
        for id, values_list in updates.items():
            if isinstance(values_list, dict):
                values_list = [values_list]

            for values in values_list:
                handler = values.get("handler")
                if handler:
                    handler = Common.create_from_class_path(handler)
                    # it could be a list
                    search_key = handler.get_search_key()
                else:
                    search_key = values.get("search_key")

                if search_key:
                    if isinstance(search_key, list):
                        search_key_set = set(search_key)
                    else:
                        search_key_set = set()
                        search_key_set.add(search_key)
                    client_keys.update(search_key_set)

                stype = values.get("search_type")
                if stype:
                    client_stypes.add(stype)

        # find all of the search that have changed
        changed_keys = set()
        changed_types = set()
        for check_type in ['sthpw/change_timestamp', 'sthpw/sobject_log']:
            search = Search(check_type)
            search.add_filter("timestamp", last_timestamp, op=">")
            search.add_filters("search_type", ["sthpw/sobject_log", "sthpw/status_log"], op="not in")
            changed_sobjects = search.get_sobjects()
            for sobject in changed_sobjects:
                search_type = sobject.get_value("search_type")
                search_code = sobject.get_value("search_code")
                if search_type.startswith("sthpw/"):
                    search_key = "%s?code=%s" % (search_type, search_code)
                else:
                    search_key = "%s&code=%s" % (search_type, search_code)
                changed_keys.add(u'%s'%search_key)
                changed_types.add(search_type)

        intersect_keys = client_keys.intersection(changed_keys)



        from pyasm.web import HtmlElement

        results = {}
        for id, values_list in updates.items():
            if isinstance(values_list, dict):
                values_list = [values_list]

            for values in values_list:

                handler = values.get("handler")
                if handler:
                    handler = Common.create_from_class_path(handler)
                    # handler can return a list of search_keys
                    search_key = handler.get_search_key()
                else:
                    search_key = values.get("search_key")

                stype = values.get("search_type")
                if search_key:
                    if isinstance(search_key, list):
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:dynamic_update_wdg.py


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