• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python common.SPTDate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: convert_value

    def convert_value(self, col_type, value):
        if col_type == 'timecode':
            timecode = TimeCode(timecode=value)
            value = timecode.get_frames()
        elif col_type in ["time", "timestamp"]:

            from pyasm.common import SPTDate
            if not value:
                value = ""
            elif not SPTDate.has_timezone(value):
                timezone = PrefSetting.get_value_by_key('timezone')
                if timezone:
                    value = SPTDate.add_timezone(value, timezone)
                else:
                    value = SPTDate.add_local_timezone(value)
        elif col_type in ["float", "integer"]:
            if isinstance(value, basestring):
                value = value.replace(",", "")
                if value.startswith("$"):
                    value = value.lstrip("$")

            try:
                if not value:
                    value = None
                elif col_type == "float":
                    value = float(value)
                else:
                    value = int(value)
            except:
                raise UserException("[%s] must a number." % value)
        return value
开发者ID:mincau,项目名称:TACTIC,代码行数:31,代码来源:edit_wdg_action.py


示例2: main

def main(server=None, input=None):
    """
    The main function of the custom script. The entire script was copied
    and pasted into the body of the try statement in order to add some
    error handling. It's all legacy code, so edit with caution.

    :param server: the TacticServerStub object
    :param input: a dict with data like like search_key, search_type, sobject, and update_data
    :return: None
    """
    if not input:
        input = {}

    try:
        # CUSTOM_SCRIPT00046
        #print "UPDATE TASK SORT ESSENTIALS"
        from pyasm.common import SPTDate
        update_data = input.get('update_data')
        sobject = input.get('sobject')
        if 'twog/title' in sobject.get('search_type'):
            server.update(input.get('search_key'), {'tripwire': ''}, triggers=False)
            proj_sk = server.build_search_key('twog/proj', sobject.get('lookup_code'))
            proj_data = {}
            task_data = {}
            if 'bid_end_date' in update_data:
                proj_data['due_date'] = SPTDate.convert_to_local(update_data.get('bid_end_date'))
                task_data['bid_end_date'] = proj_data['due_date']
            if proj_data != {}:
                server.update(proj_sk, proj_data, triggers=False)
                wos = server.eval("@SOBJECT(twog/work_order['proj_code','%s'])" % sobject.get('lookup_code'))
                for wo in wos:
                    server.update(wo.get('__search_key__'), proj_data, triggers=False) 
                    if wo.get('task_code') not in [None,'']:
                        task = server.eval("@SOBJECT(sthpw/task['code','%s'])" % wo.get('task_code'))
                        if len(task) > 0:
                            task = task[0]
                            task_data['tripwire'] = ''
                            server.update(task.get('__search_key__'), task_data, triggers=False)
        elif 'twog/proj' in sobject.get('search_type'):
            wo_sk = server.build_search_key('twog/work_order', sobject.get('lookup_code'))
            wo_data = {}
            if 'bid_end_date' in update_data:
                wo_data['due_date'] = SPTDate.convert_to_local(update_data.get('bid_end_date'))
            if wo_data != {}:
                server.update(wo_sk, wo_data, triggers=False)
        #print "LEAVING UPDATE TASK SORT ESSENTIALS"
    except AttributeError as e:
        traceback.print_exc()
        print str(e) + '\nMost likely the server object does not exist.'
        raise e
    except KeyError as e:
        traceback.print_exc()
        print str(e) + '\nMost likely the input dictionary does not exist.'
        raise e
    except Exception as e:
        traceback.print_exc()
        print str(e)
        raise e
开发者ID:2gDigitalPost,项目名称:custom,代码行数:58,代码来源:update_task_sort_essentials.py


示例3: convert_value

 def convert_value(my, col_type, value):
     if col_type == 'timecode':
         timecode = TimeCode(timecode=value)
         value = timecode.get_frames()
     elif col_type in ["time", "timestamp"]:
         from pyasm.common import SPTDate
         if not SPTDate.has_timezone(value):
             value = SPTDate.add_local_timezone(value)
     elif col_type in ["float", "integer"]:
         if isinstance(value, basestring):
             value = value.replace(",", "")
     return value
开发者ID:pombredanne,项目名称:TACTIC,代码行数:12,代码来源:edit_wdg_action.py


示例4: get_timezone_value

 def get_timezone_value(my, value):
     '''given a datetime value, try to convert to timezone specified in the widget.
        If not specified, use the My Preferences time zone'''
     timezone = my.get_option('timezone')
     if not timezone:
         timezone = PrefSetting.get_value_by_key('timezone')
     
     if timezone in ["local", '']:
         value = SPTDate.convert_to_local(value)
     else:
         value = SPTDate.convert_to_timezone(value, timezone)
     
     return value
开发者ID:0-T-0,项目名称:TACTIC,代码行数:13,代码来源:base_table_element_wdg.py


示例5: fix_date

def fix_date(date):
    # This is needed due to the way Tactic deals with dates (using timezone info), post v4.0
    return_date = ''
    date_obj = SPTDate.convert_to_local(date)
    if date_obj not in [None, '']:
        return_date = date_obj.strftime("%Y-%m-%d  %H:%M")
    return return_date
开发者ID:2gDigitalPost,项目名称:custom,代码行数:7,代码来源:common_functions.py


示例6: accesshandler

def accesshandler(request):

    cookies = Cookie.get_cookies(request)

    # if login ticket cookie does not exist, then deny
    if not cookies.has_key('login_ticket'):
        # just refuse access
        return apache.HTTP_FORBIDDEN

    ticket = cookies['login_ticket'].value
    if not ticket:
        return apache.HTTP_FORBIDDEN

    server = TacticServerStub.get(protocol='local')
    expr = "@SOBJECT(sthpw/ticket['ticket','%s'])" % ticket
    sobject = server.eval(expr, single=True)
    now = SPTDate.now()
    expiry = sobject.get("expiry")
    if expiry and expiry < str(now):
        return apache.HTTP_FORBIDDEN

    request.add_common_vars()
    path = str(request.subprocess_env['REQUEST_URI'])
    if path == None:
        return apache.HTTP_FORBIDDEN


    # FIXME: find some mechanism which is more acceptable ... like /icons
    #if path.find("_icon_") != -1:
    #    return apache.OK

    return apache.OK
开发者ID:0-T-0,项目名称:TACTIC,代码行数:32,代码来源:asset_security.py


示例7: init_data

    def init_data(my):

        sobject = my.get_current_sobject()
        value = sobject.get_value(my.due_date_col)
        if not value:
            my.mode = ""
            return

        status = sobject.get_value("status")

        due_date = parser.parse(value)

        # get today's date
        from pyasm.common import SPTDate
        today = SPTDate.start_of_today()

        # get the difference
        delta = due_date - today
        diff = delta.days


        if diff < 0:
            if status.lower() in ["approved", "complete", "done"]:
                mode = "done"
            else:
                mode = "critical"
        elif diff >= 0 and diff < 1:
            mode = "today"
        else:
            mode = "due"
        
        my.mode = mode
        my.diff = diff
开发者ID:nuxping,项目名称:TACTIC,代码行数:33,代码来源:statistic_wdg.py


示例8: get_display

    def get_display(my):

        top = DivWdg()

        value = my.get_value()
        widget_type = my.get_option("type")
        if widget_type in ['integer', 'float', 'timecode', 'currency']:
            top.add_style("float: right")
            my.justify = "right"

        elif widget_type in ['date','time']:
            name = my.get_name()
            if value and not SObject.is_day_column(name):
                value = SPTDate.convert_to_local(value)
                value = str(value)

        else:
            top.add_style("float: left")
            my.justify = "left"
        top.add_style("padding-right: 3px")

        top.add_style("min-height: 15px")

        format = my.get_option('format')
        value = my.get_format_value( value, format )

        top.add(value)

        return top
开发者ID:jayvdb,项目名称:TACTIC,代码行数:29,代码来源:format_element_wdg.py


示例9: make_timestamp

        def make_timestamp():
            from pyasm.common import SPTDate

            # Makes a Timestamp for postgres
            import datetime

            now = SPTDate.convert_to_local(datetime.datetime.now())
            now = datetime.datetime.now()
            return now
开发者ID:2gDigitalPost,项目名称:custom,代码行数:9,代码来源:log_history.py


示例10: main

def main(server=None, input=None):
    """
    The main function of the custom script. The entire script was copied
    and pasted into the body of the try statement in order to add some
    error handling. It's all legacy code, so edit with caution.

    :param server: the TacticServerStub object
    :param input: a dict with data like like search_key, search_type, sobject, and update_data
    :return: None
    """
    if not input:
        input = {}

    try:
        # CUSTOM_SCRIPT00049
        #print "IN SET REVENUE MONTH"
        from pyasm.common import SPTDate
        update_data = input.get('update_data')
        if 'due_date' in update_data.keys():
            if update_data.get('due_date') not in [None,'']:
                sobj = input.get('sobject')
                sk = input.get('search_key')
                if sobj.get('expected_delivery_date') in [None,''] and input.get('is_insert'):
                    server.update(sk, {'expected_revenue_month': SPTDate.convert_to_local(update_data.get('due_date')), 'expected_delivery_date': SPTDate.convert_to_local(update_data.get('due_date'))})
                elif not input.get('is_insert'):
                    do_it = True
                    if 'expected_delivery_date' in update_data.keys():
                        if update_data.get('expected_delivery_date') not in [None,'']:
                            do_it = False 
                    if do_it: 
                        server.update(sk, {'expected_revenue_month': SPTDate.convert_to_local(update_data.get('due_date')), 'expected_delivery_date': SPTDate.convert_to_local(update_data.get('due_date'))})
        #print "LEAVING SET REVENUE MONTH"
    except AttributeError as e:
        traceback.print_exc()
        print str(e) + '\nMost likely the server object does not exist.'
        raise e
    except KeyError as e:
        traceback.print_exc()
        print str(e) + '\nMost likely the input dictionary does not exist.'
        raise e
    except Exception as e:
        traceback.print_exc()
        print str(e)
        raise e
开发者ID:2gDigitalPost,项目名称:custom,代码行数:44,代码来源:set_revenue_month.py


示例11: get_display

    def get_display(my):
        sobject = my.get_current_sobject()

        column =  my.kwargs.get('column')
        if column:
            name = column
        else:
            name = my.get_name()
        
        value = my.get_value(name=name)

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

        if type(value) in types.StringTypes:
            wiki = WikiUtil()
            value = wiki.convert(value) 
        if name == 'id' and value == -1:
            value = ''

        elif data_type == "timestamp" or name == "timestamp":
	    if value == 'now':
                value = ''
            elif value:
                # This date is assumed to be GMT
                date = parser.parse(value)
                # convert to local
                if not SObject.is_day_column(name):
                    date = SPTDate.convert_to_local(date)
		try:
		   encoding = locale.getlocale()[1]		
		   value = date.strftime("%b %d, %Y - %H:%M").decode(encoding)
		except:
		   value = date.strftime("%b %d, %Y - %H:%M")

            else:
                value = ''
        else:
            if isinstance(value, Widget):
                return value
            elif not isinstance(value, basestring):
                try:
                    value + 1
                except TypeError:
                    value = str(value)
                else:
                    value_wdg = DivWdg()
                    value_wdg.add_style("float: right")
                    value_wdg.add_style("padding-right: 3px")
                    value_wdg.add( str(value) )
                    return value_wdg

        return value
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:55,代码来源:base_table_element_wdg.py


示例12: fix_date

def fix_date(date):
    #This is needed due to the way Tactic deals with dates (using timezone info), post v4.0
    from pyasm.common import SPTDate
    date_obj = SPTDate.convert_to_local(date)
    #return_date = ''
    #date_obj = SPTDate.convert_to_timezone(date, 'EDT')
    #print "DATE OBJ = %s" % date_obj
    #if date_obj not in [None,'']:
    #    return_date = date_obj.strftime("%Y-%m-%d  %H:%M:%S")
    #return return_date
    return date_obj
开发者ID:2gDigitalPost,项目名称:custom,代码行数:11,代码来源:update_actual_starts.py


示例13: get_display

    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 in ["timestamp","time"] or my.name == "timestamp":
            if value == 'now':
                value = ''
            elif value:
                date = parser.parse(value)
                # we want to match what's in the db which is server local timezone
                if not SPTDate.has_timezone(value):
                    value = SPTDate.convert_to_local(value)
                #value = SPTDate.add_gmt_timezone(date)
                value = str(value)
            else:
                value = ''

        return value
开发者ID:0-T-0,项目名称:TACTIC,代码行数:24,代码来源:base_table_element_wdg.py


示例14: _test_time

    def _test_time(my):
        ''' test timezone related behavior'''
        sobject = SearchType.create('sthpw/task')
        sobject.set_value('project_code','unittest')
        sobject.set_value('bid_start_date', '2014-11-11 05:00:00')
        time = sobject.get_value('bid_start_date')
        my.assertEquals(time, '2014-11-11 05:00:00')

        sobject.commit()

        time = sobject.get_value('bid_start_date')
        my.assertEquals(time, '2014-11-11 05:00:00')
        from pyasm.search import DbContainer
        sql = DbContainer.get('sthpw')
        db_value = sql.do_query('SELECT bid_start_date from task where id = %s'%sobject.get_id())
        
        # 2014-11-11 00:00:00 is actually written to the database
        my.assertEquals(db_value[0][0].strftime('%Y-%m-%d %H:%M:%S %Z'), '2014-11-11 00:00:00 ')
        
        # an sType specified without a project but with an id could be a common human error
        # but it should handle that fine
        obj1 = Search.eval('@SOBJECT(unittest/person?project=unittest["id", "%s"])'%sobject.get_id(), single=True)
        obj2= Search.eval('@SOBJECT(unittest/person?id=2["id", "%s"])'%sobject.get_id(), single=True)
        obj3 = Search.eval('@SOBJECT(sthpw/task?id=2["id", "%s"])'%sobject.get_id(), single=True)
        task = Search.eval('@SOBJECT(sthpw/task["id", "%s"])'%sobject.get_id(), single=True)

        # EST and GMT diff is 5 hours
        my.assertEquals(task.get_value('bid_start_date'), '2014-11-11 05:00:00')


        # test NOW() auto conversion
        sobj = SearchType.create('sthpw/note')
        sobj.set_value('process','TEST')
        sobj.set_value('note','123')
        my.assertEquals(sobj.get_value('timestamp'), "")
        sobj.commit()

        # this is local commited time converted back to GMT
        committed_time = sobj.get_value('timestamp')
        
        from dateutil import parser
        committed_time = parser.parse(committed_time)

        from pyasm.common import SPTDate
        now = SPTDate.now()
        diff = now - committed_time
        # should be roughly the same minute, not hours apart
        my.assertEquals(diff.seconds < 60, True)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:48,代码来源:biz_test.py


示例15: get_text_value

    def get_text_value(my):

        value = my.get_value()
        widget_type = my.get_option("type")
        
        if widget_type in ['date','time']:
            name = my.get_name()
            if not SObject.is_day_column(name):
                value = SPTDate.convert_to_local(value)
                value = str(value)
 
        format = my.get_option('format')
        
        if format == 'Checkbox':
            value = str(value)
        else:
            value = my.get_format_value( value, format )

       
        return value
开发者ID:jayvdb,项目名称:TACTIC,代码行数:20,代码来源:format_element_wdg.py


示例16: get_display

    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,代码行数:21,代码来源:base_table_element_wdg.py


示例17: test_time

def test_time():

    from pyasm.search import SearchType
    sobj = SearchType.create('sthpw/note')
    sobj.set_value('process','TEST')
    sobj.set_value('note','123')
    sobj.commit()


    sobj.set_value('note', 'new note')
    sobj.commit()

    # check change_timestamp
    change_t = Search.eval("@SOBJECT(sthpw/change_timestamp['search_type','sthpw/note']['search_code','%s'])"%sobj.get_code(), single=True)
    if change_t:
        change_t_timestamp = change_t.get('timestamp')
        change_t_timestamp = parser.parse(change_t_timestamp)

        from pyasm.common import SPTDate
        now = SPTDate.now()

        diff = now - change_t_timestamp
        # should be roughly the same minute, not hours apart
        print "Change timestamp diff is ", diff.seconds 
开发者ID:0-T-0,项目名称:TACTIC,代码行数:24,代码来源:dynamic_update_wdg.py


示例18: execute

    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,代码行数:101,代码来源:dynamic_update_wdg.py


示例19: main

def main(server=None, input=None):
    """
    The main function of the custom script. The entire script was copied
    and pasted into the body of the try statement in order to add some
    error handling. It's all legacy code, so edit with caution.

    :param server: the TacticServerStub object
    :param input: a dict with data like like search_key, search_type, sobject, and update_data
    :return: None
    """
    if not input:
        input = {}

    try:
        # CUSTOM_SCRIPT00003
        # Matthew Tyler Misenhimer
        # This is run when a task is added. Tasks are added when a pipeline is attached to a title or project.
        # This will take info from the task and create either a work order or proj
        # THIS IS ADD_WO_OR_PROJ
        # sobj is a task sobject
        from pyasm.common import Environment
        from pyasm.common import SPTDate
        sobj = input.get('sobject')
        # If it wasn't manually inserted, then it is a normally added task (from pipeline attachment)
        if 'Manually Inserted' in sobj.get('pipeline_code'):
            return

        sobj_sk = server.build_search_key('sthpw/task', sobj.get('code'))
        proj = None
        order = None
        is_master = False
        mr_title = None
        title_title = ''
        title_code = ''
        title_episode = ''
        title_territory = ''
        title_platform = ''
        title_id_number = ''
        client_name = ''
        login = Environment.get_login()
        user_name = login.get_login()
        #This sees if the sobject was being cloned or not. If so, then set the templ_me field to true
        cloning_expr = "@SOBJECT(twog/action_tracker['login','%s']['action','cloning'])" % (user_name)
        cloning = server.eval(cloning_expr)
        templ_me = False
        title_due_date = None
        if len(cloning) > 0:
            templ_me = True
        if 'twog/proj' in sobj.get('search_type'):
            prexpr = "@SOBJECT(twog/proj['id','%s'])" % sobj.get('search_id')
            proj = server.eval(prexpr)[0]
            killed_task = False
            if proj:
                mr_title_expr = "@SOBJECT(twog/title['code','%s'])" % proj.get('title_code')
                mr_title = server.eval(mr_title_expr)
                if mr_title:
                    mr_title = mr_title[0]
                if mr_title:
                    title_code = mr_title.get('code')
                    title_title = mr_title.get('title')
                    title_due_date = SPTDate.convert_to_local(mr_title.get('due_date'))
                    title_episode = mr_title.get('episode')
                    title_territory = mr_title.get('territory')
                    title_platform = mr_title.get('platform')
                    title_id_number = mr_title.get('title_id_number')
                    client_code = mr_title.get('client_code')
                    client_names = server.eval("@GET(twog/client['code','%s'].name)" % client_code)
                    if len(client_names) > 0:
                        client_name = client_names[0]
                if mr_title:
                    order = server.eval("@SOBJECT(twog/order['code','%s'])" % mr_title.get('order_code'))[0]
                    order_classification = order.get('classification')
                    #If it is a master, kill the task so it won't show up in operator views
                    if order_classification in ['master','Master']:
                        is_master = True
                        server.retire_sobject(sobj_sk)
                        killed_task = True
                        server.update(proj.get('__search_key__'), {'task_code': ''})
            pipeline_code = proj.get('pipeline_code')
            spt_processes = server.eval("@SOBJECT(config/process['pipeline_code','%s']['process','%s'])"%(pipeline_code, sobj.get('process')))
            # take the first one, we dont expect duplicates
            spt_process = spt_processes[0]

            # query if it exists
            work_order  = server.query('twog/work_order', filters=[('process',sobj.get('process')), ('proj_code', proj.get('code')), ('description', spt_process.get('description')), ('parent_pipe', pipeline_code)])

            if work_order:
                return

            # find work order template
            desc = spt_process.get('description')
            if not desc:
                desc = ''
            wot_expr = "@SOBJECT(twog/work_order_templ['process','%s']['parent_pipe','%s'])" % (sobj.get('process'), pipeline_code)
            work_order_template = server.eval(wot_expr)
            if work_order_template:
                work_order_template = work_order_template[0]
            instructions = ''
            estimated_work_hours = ''
            work_group = ''
#.........这里部分代码省略.........
开发者ID:2gDigitalPost,项目名称:custom,代码行数:101,代码来源:add_work_order_or_proj.py


示例20: main

def main(server=None, input=None):
    """
    The main function of the custom script. The entire script was copied
    and pasted into the body of the try statement in order to add some
    error handling. It's all legacy code, so edit with caution.

    :param server: the TacticServerStub object
    :param input: a dict with data like like search_key, search_type, sobject, and update_data
    :return: None
    """
    if not input:
        input = {}

    try:
        # CUSTOM_SCRIPT00044
        def removekey(d, key):
            r = dict(d)
            del r[key]
            return r
        # This will act as a recursive trigger.
        if 'update_data' in input.keys():
            from pyasm.common import SPTDate
        
            update_data = input.get('update_data') 
            ukeys = update_data.keys()
            sobject = input.get('sobject')
            keep_going = True
            if 'tripwire' in ukeys:
                if update_data.get('tripwire') == 'No Send Back':
                    keep_going = False
                    task = server.eval("@SOBJECT(sthpw/task['code','%s'])" % sobject.get('task_code'))
                    if task:
                        task = task[0]
                        server.update(task.get('__search_key__'), {'tripwire': ''}, triggers=False)
                        server.update(input.get('search_key'), {'tripwire': ''}, triggers=False)
            if keep_going:
                prev_data = input.get('prev_data')
                sobject = input.get('sobject')
                search_type = input.get('search_type').split('?')[0]
                search_key = input.get('search_key')
                code = search_key.split('code=')[1]
                st_kids = {'twog/order': ['twog/title', 'order_code'], 'twog/title': ['twog/proj', 'title_code'], 'twog/proj': ['twog/work_order', 'proj_code']}
                kids_data = {}
                task_data = {}
                if 'po_number' in ukeys:
                    kids_data['po_number'] = update_data.get('po_number')
                    task_data['po_number'] = update_data.get('po_number')
                if 'name' in ukeys and search_type == 'twog/order':
                    kids_data['order_name'] = update_data.get('name')
                if 'order_name' in ukeys:
                    kids_data['order_name'] = update_data.get('order_name')
                    task_data['order_name'] = update_data.get('order_name')
                if 'territory' in ukeys:
                    kids_data['territory'] = update_data.get('territory')
                    task_data['territory'] = update_data.get('territory')
                if 'title' in ukeys:
                    kids_data['title'] = update_data.get('title')
                    task_data['title'] = update_data.get('title')
                if 'episode' in ukeys: 
                    kids_data['episode'] = update_data.get('episode')
                    task_data['episode'] = update_data.get('episode')
                if 'platform' in ukeys: 
                    kids_data['platform'] = update_data.get('platform')
                    task_data['platform'] = update_data.get('platform')
                if 'title_id_number' in ukeys: 
                    kids_data['title_id_number'] = update_data.get('title_id_number')
                    task_data['title_id_number'] = update_data.get('title_id_number')
                if 'login' in ukeys: 
                    kids_data['login'] = update_data.get('login')
                    task_data['login'] = update_data.get('login')
                if 'client_code' in ukeys: 
                    cl_c = update_data.get('client_code')
                    if cl_c not in [None,'']:
                        kids_data['client_code'] = cl_c 
                        task_data['client_code'] = cl_c 
                if 'client_name' in ukeys: 
                    cl_n =  update_data.get('client_name')
                    if cl_n not in [None,'']:
                        kids_data['client_name'] = cl_n 
                        task_data['client_name'] = cl_n 
                if 'status' in ukeys and search_type not in ['twog/order','twog/title']:
                    task_data['status'] = update_data.get('status')
                if 'expected_delivery_date' in ukeys and search_type != 'twog/title':
                    kids_data['expected_delivery_date'] = SPTDate.convert_to_local(update_data.get('expected_delivery_date'))
                if 'due_date' in ukeys:
                    kids_data['due_date'] = SPTDate.convert_to_local(update_data.get('due_date'))
                    if search_type in ['twog/proj','twog/work_order']:
                        task_data['bid_end_date'] = kids_data['due_date']
                if 'start_date' in ukeys:
                    kids_data['start_date'] = SPTDate.convert_to_local(update_data.get('start_date'))
                    if search_type in ['twog/proj','twog/work_order']:
                        task_data['bid_start_date'] = kids_data['start_date']
                if kids_data != {} and search_type != 'twog/work_order':
                    kids_expr = "@SOBJECT(%s['%s','%s'])" % (st_kids[search_type][0], st_kids[search_type][1], code)
                    kids = server.eval(kids_expr)
                    for kid in kids:
                        server.update(kid.get('__search_key__'), kids_data) 
                if task_data != {} and search_type in ['twog/proj','twog/work_order']:
                    task_code = sobject.get('task_code')
                    if task_code not in [None,'']:
#.........这里部分代码省略.........
开发者ID:2gDigitalPost,项目名称:custom,代码行数:101,代码来源:update_down.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.Xml类代码示例发布时间:2022-05-25
下一篇:
Python common.Environment类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap