Example #1
0
    def preprocess(self):
        search_type_list = SObject.get_values(self.sobjects,
                                              'search_type',
                                              unique=True)
        search_id_dict = {}
        self.ref_sobject_cache = {}

        # initialize the search_id_dict
        for type in search_type_list:
            search_id_dict[type] = []
        # cache it first
        for sobject in self.sobjects:
            search_type = sobject.get_value('search_type')
            search_id_list = search_id_dict.get(search_type)
            search_id_list.append(sobject.get_value('search_id'))

        from pyasm.search import SearchException
        for key, value in search_id_dict.items():
            try:
                ref_sobjects = Search.get_by_id(key, value)
                sobj_dict = SObject.get_dict(ref_sobjects)
            except SearchException, e:
                print "WARNING: search_type [%s] with id [%s] does not exist" % (
                    key, value)
                print str(e)
                sobj_dict = {}

            # store a dict of dict with the search_type as key
            self.ref_sobject_cache[key] = sobj_dict
Example #2
0
    def preprocess(my):
        search_type_list  = SObject.get_values(my.sobjects, 'search_type', unique=True)
        search_id_dict = {}
        my.ref_sobject_cache = {}

        # initialize the search_id_dict
        for type in search_type_list:
            search_id_dict[type] = []
        # cache it first
        for sobject in my.sobjects:
            search_type = sobject.get_value('search_type')
            search_id_list = search_id_dict.get(search_type)
            search_id_list.append(sobject.get_value('search_id'))

        from pyasm.search import SearchException
        for key, value in search_id_dict.items():
            try:
                ref_sobjects = Search.get_by_id(key, value)
                sobj_dict = SObject.get_dict(ref_sobjects)
            except SearchException, e:
                print "WARNING: search_type [%s] with id [%s] does not exist" % (key, value)
                print str(e)
                sobj_dict = {}

            # store a dict of dict with the search_type as key
            my.ref_sobject_cache[key] = sobj_dict
Example #3
0
    def preprocess(self):

        self.is_preprocessed = True
        # get all of the instances

        search = Search("prod/shot_instance")

        # if not used in a TableWdg, only get the shot instances for one asset
        if not self.parent_wdg:
            search.add_filter('asset_code',
                              self.get_current_sobject().get_code())

        search.add_order_by("shot_code")
        instances = search.get_sobjects()

        self.asset_instances = instances

        self.instances = {}
        for instance in instances:
            asset_code = instance.get_value("asset_code")

            list = self.instances.get(asset_code)
            if not list:
                list = []
                self.instances[asset_code] = list

            list.append(instance)

        search = Search("prod/shot")
        search.add_filters("code",
                           [x.get_value('shot_code') for x in instances])
        shots = search.get_sobjects()
        self.shots = SObject.get_dict(shots, ["code"])
        self.shots_list = shots
Example #4
0
    def preprocess(my):
       
        my.is_preprocessed = True
        # get all of the instances

        search = Search("prod/shot_instance")

        # if not used in a TableWdg, only get the shot instances for one asset
        if not my.parent_wdg:
            search.add_filter('asset_code', my.get_current_sobject().get_code())

        search.add_order_by("shot_code")
        instances = search.get_sobjects()

        my.asset_instances = instances

        my.instances = {}
        for instance in instances:
            asset_code = instance.get_value("asset_code")
            
            list = my.instances.get(asset_code)
            if not list:
                list = []
                my.instances[asset_code] = list

            list.append(instance)
       
        search = Search("prod/shot")
        search.add_filters( "code", [x.get_value('shot_code') for x in instances] )
        shots = search.get_sobjects()
        my.shots = SObject.get_dict(shots, ["code"])
        my.shots_list = shots
Example #5
0
    def build_cache_by_column(self, column):
        # do not build if it already exists
        if self.caches.has_key(column):
            return

        # build a search_key cache
        column_cache = SObject.get_dict(self.sobjects, key_cols=[column])
        self.caches[column] = column_cache
        return column_cache
Example #6
0
    def build_cache_by_column(my, column):
        # do not build if it already exists
        if my.caches.has_key(column):
            return

        # build a search_key cache
        column_cache = SObject.get_dict(my.sobjects, key_cols=[column])
        my.caches[column] = column_cache
        return column_cache
Example #7
0
    def get_info(self):
        # check if the sobj type is the same
        search_types = SObject.get_values(self.sobjs,
                                          'search_type',
                                          unique=True)
        search_ids = SObject.get_values(self.sobjs, 'search_id', unique=False)

        infos = []
        # this doesn't really work if the same asset is submitted multiple times
        if len(search_types) == 1 and len(search_ids) == len(self.sobjs):
            assets = []
            if search_types[0]:
                assets = Search.get_by_id(search_types[0], search_ids)

            asset_dict = SObject.get_dict(assets)
            for id in search_ids:
                asset = asset_dict.get(id)
                aux_dict = {}
                aux_dict['info'] = SubmissionInfo._get_target_sobject_data(
                    asset)
                aux_dict['search_key'] = '%s:%s' % (search_types[0], id)
                infos.append(aux_dict)

        else:
            # TODO: this is a bit database intensive, mixed search_types not
            # recommended
            search_types = SObject.get_values(self.sobjs, 'search_type',\
                unique=False)
            for idx in xrange(0, len(search_types)):
                search_type = search_types[idx]

                aux_dict = {}
                aux_dict['info'] = ''
                aux_dict['search_key'] = ''
                if search_type:
                    asset = Search.get_by_id(search_type, search_ids[idx])
                    aux_dict['info'] = SubmissionInfo._get_target_sobject_data(
                        asset)
                    aux_dict['search_key'] = '%s:%s' % (search_types[idx],
                                                        search_ids[idx])
                infos.append(aux_dict)
        return infos
Example #8
0
 def get_info(self):
     # check if the sobj type is the same
     search_types = SObject.get_values(self.sobjs, 'search_type', unique=True)
     search_ids = SObject.get_values(self.sobjs, 'search_id', unique=False)
   
     infos = []
     # this doesn't really work if the same asset is submitted multiple times
     if len(search_types) == 1 and len(search_ids) == len(self.sobjs):
         assets = []
         if search_types[0]:
             assets = Search.get_by_id(search_types[0], search_ids)
         
         asset_dict = SObject.get_dict(assets)
         for id in search_ids:
             asset = asset_dict.get(id)
             aux_dict = {}
             aux_dict['info'] = SubmissionInfo._get_target_sobject_data(asset)
             aux_dict['search_key'] = '%s:%s' %(search_types[0], id)
             infos.append(aux_dict)
         
     else:
         # TODO: this is a bit database intensive, mixed search_types not
         # recommended
         search_types = SObject.get_values(self.sobjs, 'search_type',\
             unique=False)
         for idx in xrange(0, len(search_types)):
             search_type = search_types[idx]
                 
             aux_dict = {}
             aux_dict['info'] = ''
             aux_dict['search_key'] = ''
             if search_type:
                 asset = Search.get_by_id(search_type, search_ids[idx])
                 aux_dict['info'] = SubmissionInfo._get_target_sobject_data(asset)
                 aux_dict['search_key'] = '%s:%s' %(search_types[idx], search_ids[idx])
             infos.append(aux_dict)
     return infos
Example #9
0
    def execute(my):
        date = Date()
        cur_time = date.get_utc()

        print "Burn down"

        #first = 8 * 60 * 60
        first = 30
        next = 10
       
        # search for all of the tasks that are pending
        search = Search("sthpw/task")
        search.add_filter("status", "Pending")
        sobjects = search.get_sobjects()

        # get the time when this was set to pending
        search = Search("sthpw/status_log")
        search.add_filter("from_status", "Assignment")
        search.add_filter("to_status", "Pending")
        logs = search.get_sobjects()

        logs_dict = SObject.get_dict(logs, ["search_type", "search_id"] )

        # analyze tasks
        ready_sobjects = []

        for sobject in sobjects:
            search_key = sobject.get_search_key()

            
            # get the logs
            log = logs_dict.get(search_key)
            if not log:
                continue

            log_date = Date(db=log.get_value("timestamp"))
            log_time = log_date.get_utc()

            interval = cur_time - log_time


            # if we haven't passed the first marker, then just skip
            if interval < first:
                continue

            # put an upper limit where it doesn't make anymore sense
            if interval > 21*24*60*60:
                continue


            # once we've reached the first marker, email next interval
            start = (interval - first) / next
            print "start: ", interval, first, start

            continue

            parent = sobject.get_parent()
            if not parent:
                print "WARNING: parent does not exist [%s]" % sobject.get_search_key()
                continue

            process = sobject.get_value("process")
            assigned = sobject.get_value("assigned")
            status = sobject.get_value("status")
            code = parent.get_code()

            print (code, assigned, process, status, interval/3600)
            ready_sobjects.append( sobject )





        # TODO: problem how to prevent emails from happening every iteration?

        # this is run every minute, so remember the last time an email has been
        # sent for a particular 
 
        if not ready_sobjects:
            return

        from pyasm.command import Command
        class BurnDownCmd(Command):
            def get_title(my):
                return "Burn Down Command"
            def set_sobjects(my, sobjects):
                my.sobjects = [sobject]
            def execute(my):
                # call email trigger
                from email_trigger import EmailTrigger
                email_trigger = EmailTrigger()
                email_trigger.set_command(my)
                email_trigger.execute()


        # call email trigger
        #cmd = BurnDownCmd()
        #cmd.set_sobjects(ready_sobjects)
        #Command.execute_cmd(cmd)

        # remember the time of each email
        for sobject in ready_sobjects:
            search_key = sobject.get_search_key()
            my.notified[search_key] = cur_time
    def get_display(my):

        my.search_type = my.kwargs.get('search_type')
        my.texture_search_type = my.kwargs.get('texture_search_type')
        assert my.search_type

        app_name = WebContainer.get_web().get_selected_app()
        # add an outside box

        top = DivWdg(css='spt_view_panel')
        #div = DivWdg(css="maq_search_bar")
        div = DivWdg()
        div.add_color("background", "background2", -15)
        my.set_as_panel(top)

        top.add(div)
        div.add_style("margin: 5px")

        div.add_style("padding: 10px")

        div.add_style("font-style: bold")

        process_div = DivWdg()
        process_div.add_style("padding-left: 10px")
        div.add(process_div)
        process_div.add(my.get_process_wdg(my.search_type))
        process_div.add(my.get_context_filter_wdg())
        process_div.add(HtmlElement.br(clear="all"))

        div.add(HtmlElement.br())
        checkin_options = DivWdg(css='spt_ui_options')
        checkin_options.add_style("padding: 10px")

        swap = SwapDisplayWdg()
        #swap.set_off()
        title = SpanWdg("Check in Options")
        SwapDisplayWdg.create_swap_title(title,
                                         swap,
                                         checkin_options,
                                         is_open=False)
        div.add(swap)
        div.add(title)

        checkin_options.add(my.get_file_type_wdg())
        checkin_options.add(my.get_snapshot_type_wdg())
        checkin_options.add(HtmlElement.br(1))
        checkin_options.add(my.get_export_method_wdg())
        checkin_options.add(my.get_checkin_as_wdg())

        #my.add( my.get_render_icon_wdg() )

        # For different export methods
        checkin_options.add(my.get_currency_wdg())

        checkin_options.add(my.get_reference_option())
        checkin_options.add(my.get_auto_version_wdg())
        checkin_options.add(my.get_texture_option(app=app_name))
        checkin_options.add(my.get_handoff_wdg())

        if not my.context_select.get_value(for_display=True):
            my.add(DivWdg('A context must be selected.', css='warning'))
            return

        div.add(checkin_options)

        top.add(my.get_introspect_wdg())
        top.add(HtmlElement.br(2))

        # create the interface
        table = Table()
        table.set_max_width()
        #table.set_class("table")
        table.add_color('background', 'background2')
        #table.add_style('line-height','3.0em')
        #table.add_row(css='smaller')
        tr = table.add_row(css='smaller')
        tr.add_style('height', '3.5em')
        table.add_header("&nbsp;")
        table.add_header("&nbsp;")
        th = table.add_header("Instance")
        th.add_style('text-align: left')
        table.add_header(my.get_checkin())
        table.add_header("Sandbox")
        tr.add_color('background', 'background2', -15)

        # get session and handle case where there is no session
        my.session = SessionContents.get()
        if my.session == None:
            instance_names = []
            asset_codes = []
            node_names = []
        else:
            instance_names = my.session.get_instance_names()
            asset_codes = my.session.get_asset_codes()
            node_names = my.session.get_node_names()

        # get all of the possible assets based on the asset codes
        search = Search(my.search_type)
        search.add_filters("code", asset_codes)
        assets = search.get_sobjects()
        assets_dict = SObject.get_dict(assets, ["code"])

        if my.session:
            my.add("Current Project: <b>%s</b>" % my.session.get_project_dir())
        else:
            my.add("Current Project: Please press 'Introspect'")

        count = 0
        for i in range(0, len(node_names)):
            node_name = node_names[i]
            if not my.session.is_tactic_node(node_name) and \
                not my.session.get_node_type(node_name) in ['transform','objectSet']:
                continue
            instance_name = instance_names[i]

            # backwards compatible:
            try:
                asset_code = asset_codes[i]
            except IndexError, e:
                asset_code = instance_name

            # skip if this is a reference
            if my.list_references == False and \
                    my.session.is_reference(node_name):
                continue

            table.add_row()

            # check that this asset exists
            asset = assets_dict.get(asset_code)
            if not asset:
                continue

            # list items if it is a set
            if asset.get_value('asset_type',
                               no_exception=True) in ["set", "section"]:
                my.current_sobject = asset
                my.handle_set(table, instance_name, asset, instance_names)
                count += 1
            # if this asset is in the database, then allow it to checked in
            if asset:
                if my.session.get_snapshot_code(instance_name,
                                                snapshot_type='set'):
                    continue

                # hack remember this
                my.current_sobject = asset
                my.handle_instance(table, instance_name, asset, node_name)

            else:
                table.add_blank_cell()
                table.add_cell(instance_name)

            count += 1
Example #11
0
    def get_display(my):


        my.search_type = my.kwargs.get('search_type')
        my.texture_search_type = my.kwargs.get('texture_search_type')
        assert my.search_type

        app_name = WebContainer.get_web().get_selected_app()
        # add an outside box


        top = DivWdg(css='spt_view_panel')
        #div = DivWdg(css="maq_search_bar")
        div = DivWdg()
        div.add_color("background", "background2", -15)
        my.set_as_panel(top)

        top.add(div)
        div.add_style("margin: 5px")

        div.add_style("padding: 10px")
        
        div.add_style("font-style: bold")



        process_div = DivWdg()
        process_div.add_style("padding-left: 10px")
        div.add(process_div)
        process_div.add( my.get_process_wdg(my.search_type))
        process_div.add( my.get_context_filter_wdg() )
        process_div.add(HtmlElement.br(clear="all")) 


        div.add( HtmlElement.br() )
        checkin_options = DivWdg(css='spt_ui_options')
        checkin_options.add_style("padding: 10px")

        swap = SwapDisplayWdg()
        #swap.set_off()
        title = SpanWdg("Check in Options")
        SwapDisplayWdg.create_swap_title(title, swap, checkin_options, is_open=False)
        div.add(swap)
        div.add(title)


        checkin_options.add( my.get_file_type_wdg() )
        checkin_options.add( my.get_snapshot_type_wdg() )
        checkin_options.add(HtmlElement.br(1)) 
        checkin_options.add( my.get_export_method_wdg() )
        checkin_options.add( my.get_checkin_as_wdg() )

        #my.add( my.get_render_icon_wdg() )

        # For different export methods
        checkin_options.add( my.get_currency_wdg() )

        checkin_options.add( my.get_reference_option())
        checkin_options.add( my.get_auto_version_wdg())
        checkin_options.add( my.get_texture_option(app=app_name))
        checkin_options.add( my.get_handoff_wdg())
       
        if not my.context_select.get_value(for_display=True):
            my.add(DivWdg('A context must be selected.', css='warning'))
            return

        div.add(checkin_options)
      
        
        top.add( my.get_introspect_wdg() )
        top.add(HtmlElement.br(2))
        
        # create the interface
        table = Table()
        table.set_max_width()
        #table.set_class("table")
        table.add_color('background','background2') 
        #table.add_style('line-height','3.0em')
        #table.add_row(css='smaller')
        tr = table.add_row(css='smaller')
        tr.add_style('height', '3.5em')
        table.add_header("&nbsp;")
        table.add_header("&nbsp;")
        th = table.add_header("Instance")
        th.add_style('text-align: left')
        table.add_header(my.get_checkin())
        table.add_header("Sandbox")
        tr.add_color('background','background2', -15)
        

        # get session and handle case where there is no session
        my.session = SessionContents.get()
        if my.session == None:
            instance_names = []
            asset_codes = []
            node_names = []
        else:
            instance_names = my.session.get_instance_names()
            asset_codes = my.session.get_asset_codes()
            node_names = my.session.get_node_names()

        # get all of the possible assets based on the asset codes
        search = Search(my.search_type)
        search.add_filters("code", asset_codes)
        assets = search.get_sobjects()
        assets_dict = SObject.get_dict(assets, ["code"])

        if my.session:
            my.add("Current Project: <b>%s</b>" % my.session.get_project_dir() )
        else:
            my.add("Current Project: Please press 'Introspect'")


        count = 0
        for i in range(0, len(node_names) ):
            node_name = node_names[i]
            if not my.session.is_tactic_node(node_name) and \
                not my.session.get_node_type(node_name) in ['transform','objectSet']:
                    continue
            instance_name = instance_names[i]

            # backwards compatible:
            try:
                asset_code = asset_codes[i]
            except IndexError, e:
                asset_code = instance_name

            # skip if this is a reference
            if my.list_references == False and \
                    my.session.is_reference(node_name):
                continue

            table.add_row()


            # check that this asset exists
            asset = assets_dict.get(asset_code)
            if not asset:
                continue
           
            # list items if it is a set
            if asset.get_value('asset_type', no_exception=True) in ["set", "section"]:
                my.current_sobject = asset
                my.handle_set( table, instance_name, asset, instance_names)
                count +=1
            # if this asset is in the database, then allow it to checked in
            if asset:
                if my.session.get_snapshot_code(instance_name, snapshot_type='set'):
                    continue

                # hack remember this
                my.current_sobject = asset
                my.handle_instance(table, instance_name, asset, node_name)

            else:
                table.add_blank_cell()
                table.add_cell(instance_name)


            count += 1
Example #12
0
 def _init_snapshots(my):
     '''preselect all of the snapshots'''
     snapshots = Snapshot.get_latest_by_sobjects(my.sobjects)
     my.snapshot_dict = SObject.get_dict(snapshots,\
         key_cols=['search_type','search_id'])
Example #13
0
    def preprocess(self):

        # protect against the case where there is a single sobject that
        # is an insert (often seen in "insert")
        if self.is_preprocessed == True:
            return

        skip = False
        if len(self.sobjects) == 1:
            if not self.sobjects[0].has_value("search_type"):
                skip = True

        if not skip:
            search_types = SObject.get_values(self.sobjects,
                                              'search_type',
                                              unique=True)

            try:
                search_codes = SObject.get_values(self.sobjects,
                                                  'search_code',
                                                  unique=True)
                search_ids = None
            except Exception as e:
                print "WARNING: ", e
                search_ids = SObject.get_values(self.sobjects,
                                                'search_id',
                                                unique=True)
                search_codes = None
        else:
            search_types = []
            search_codes = []

        # if there is more than one search_type, then go get each parent
        # individually
        # NOTE: this is very slow!!!!
        ref_sobjs = []
        if len(search_types) > 1:
            ref_sobjs = []
            for tmp_sobj in self.sobjects:
                try:
                    ref_sobj = tmp_sobj.get_parent()
                    if ref_sobj:
                        ref_sobjs.append(ref_sobj)
                    else:
                        warning = "Dangling reference: %s" % tmp_sobj.get_search_key(
                        )
                        Environment.add_warning(warning, warning)
                except SearchException as e:
                    # skips unknown search_type/project
                    print e.__str__()
                    continue

        elif len(search_types) == 1:
            search_type = self.sobjects[0].get_value("search_type")
            try:
                if search_codes != None:
                    ref_sobjs = Search.get_by_code(search_type, search_codes)
                else:
                    ref_sobjs = Search.get_by_id(search_type, search_ids)
            except SearchException as e:
                # skips unknown search_type/project
                print e.__str__()
                pass

        # TODO: None defaults to search_key, should be empty
        self.ref_sobj_dict = SObject.get_dict(ref_sobjs, None)

        # when drawn as part of a TbodyWdg, we want to disable the calculation
        # of most things so that it will not try to display a prev row
        if self.get_option('disable') == 'true':
            self.ref_sobj_dict = None
            self.empty = True

        self.is_preprocessed = True
 def preprocess(my):
     episode_codes = SObject.get_values(my.sobjects, 'episode_code')
     search = Search(NatPause)
     search.add_filters('episode_code', episode_codes)
     net_pauses = search.get_sobjects()
     my.sobject_dict = SObject.get_dict(net_pauses, key_cols=['episode_code'])
Example #15
0
    def preprocess(self):
        
        # protect against the case where there is a single sobject that
        # is an insert (often seen in "insert")
        if self.is_preprocessed == True:
            return

        skip = False
        if len(self.sobjects) == 1:
            if not self.sobjects[0].has_value("search_type"):
                skip = True

        if not skip:
            search_types = SObject.get_values(self.sobjects, 'search_type', unique=True)

            try:
                search_codes = SObject.get_values(self.sobjects, 'search_code', unique=True)
                search_ids = None
            except Exception as e:
                print "WARNING: ", e
                search_ids = SObject.get_values(self.sobjects, 'search_id', unique=True)
                search_codes = None
        else:
            search_types = []
            search_codes = []


        # if there is more than one search_type, then go get each parent
        # individually
        # NOTE: this is very slow!!!!
        ref_sobjs = []
        if len(search_types) > 1:
            ref_sobjs = []
            for tmp_sobj in self.sobjects:
                try:
                    ref_sobj = tmp_sobj.get_parent()
                    if ref_sobj:
                        ref_sobjs.append(ref_sobj)
                    else:
                        warning = "Dangling reference: %s" % tmp_sobj.get_search_key()
                        Environment.add_warning(warning, warning)
                except SearchException as e:
                    # skips unknown search_type/project
                    print e.__str__()
                    continue

        elif len(search_types) == 1:
            search_type =  self.sobjects[0].get_value("search_type")
            try:
                if search_codes != None:
                    ref_sobjs = Search.get_by_code(search_type, search_codes)
                else:
                    ref_sobjs = Search.get_by_id(search_type, search_ids)
            except SearchException as e:
                # skips unknown search_type/project
                print e.__str__()
                pass

        # TODO: None defaults to search_key, should be empty
        self.ref_sobj_dict = SObject.get_dict(ref_sobjs, None)

        # when drawn as part of a TbodyWdg, we want to disable the calculation
        # of most things so that it will not try to display a prev row
        if self.get_option('disable') == 'true':
            self.ref_sobj_dict = None
            self.empty = True
  
        self.is_preprocessed = True
Example #16
0
                    continue

        elif len(search_types) == 1:
            search_type =  my.sobjects[0].get_value("search_type")
            try:
                if search_codes != None:
                    ref_sobjs = Search.get_by_code(search_type, search_codes)
                else:
                    ref_sobjs = Search.get_by_id(search_type, search_ids)
            except SearchException, e:
                # skips unknown search_type/project
                print e.__str__()
                pass

        # TODO: None defaults to search_key, should be empty
        my.ref_sobj_dict = SObject.get_dict(ref_sobjs, None)

        # when drawn as part of a TbodyWdg, we want to disable the calculation
        # of most things so that it will not try to display a prev row
        if my.get_option('disable') == 'true':
            my.ref_sobj_dict = None
            my.empty = True
  
        my.is_preprocessed = True

    #def handle_td(my, td):
    #    td.add_class("task_spacer_column")
    #    td.add_style("font-weight: bold")
    #    if my.empty:
    #        td.add_style("border-top: 0px")
Example #17
0
    def execute(my):
        date = Date()
        cur_time = date.get_utc()

        print "Burn down"

        #first = 8 * 60 * 60
        first = 30
        next = 10

        # search for all of the tasks that are pending
        search = Search("sthpw/task")
        search.add_filter("status", "Pending")
        sobjects = search.get_sobjects()

        # get the time when this was set to pending
        search = Search("sthpw/status_log")
        search.add_filter("from_status", "Assignment")
        search.add_filter("to_status", "Pending")
        logs = search.get_sobjects()

        logs_dict = SObject.get_dict(logs, ["search_type", "search_id"])

        # analyze tasks
        ready_sobjects = []

        for sobject in sobjects:
            search_key = sobject.get_search_key()

            # get the logs
            log = logs_dict.get(search_key)
            if not log:
                continue

            log_date = Date(db=log.get_value("timestamp"))
            log_time = log_date.get_utc()

            interval = cur_time - log_time

            # if we haven't passed the first marker, then just skip
            if interval < first:
                continue

            # put an upper limit where it doesn't make anymore sense
            if interval > 21 * 24 * 60 * 60:
                continue

            # once we've reached the first marker, email next interval
            start = (interval - first) / next
            print "start: ", interval, first, start

            continue

            parent = sobject.get_parent()
            if not parent:
                print "WARNING: parent does not exist [%s]" % sobject.get_search_key(
                )
                continue

            process = sobject.get_value("process")
            assigned = sobject.get_value("assigned")
            status = sobject.get_value("status")
            code = parent.get_code()

            print(code, assigned, process, status, interval / 3600)
            ready_sobjects.append(sobject)

        # TODO: problem how to prevent emails from happening every iteration?

        # this is run every minute, so remember the last time an email has been
        # sent for a particular

        if not ready_sobjects:
            return

        from pyasm.command import Command

        class BurnDownCmd(Command):
            def get_title(my):
                return "Burn Down Command"

            def set_sobjects(my, sobjects):
                my.sobjects = [sobject]

            def execute(my):
                # call email trigger
                from email_trigger import EmailTrigger
                email_trigger = EmailTrigger()
                email_trigger.set_command(my)
                email_trigger.execute()

        # call email trigger
        #cmd = BurnDownCmd()
        #cmd.set_sobjects(ready_sobjects)
        #Command.execute_cmd(cmd)

        # remember the time of each email
        for sobject in ready_sobjects:
            search_key = sobject.get_search_key()
            my.notified[search_key] = cur_time
Example #18
0
                    continue

        elif len(search_types) == 1:
            search_type = my.sobjects[0].get_value("search_type")
            try:
                if search_codes != None:
                    ref_sobjs = Search.get_by_code(search_type, search_codes)
                else:
                    ref_sobjs = Search.get_by_id(search_type, search_ids)
            except SearchException, e:
                # skips unknown search_type/project
                print e.__str__()
                pass

        # TODO: None defaults to search_key, should be empty
        my.ref_sobj_dict = SObject.get_dict(ref_sobjs, None)

        # when drawn as part of a TbodyWdg, we want to disable the calculation
        # of most things so that it will not try to display a prev row
        if my.get_option('disable') == 'true':
            my.ref_sobj_dict = None
            my.empty = True

        my.is_preprocessed = True

    #def handle_td(my, td):
    #    td.add_class("task_spacer_column")
    #    td.add_style("font-weight: bold")
    #    if my.empty:
    #        td.add_style("border-top: 0px")