Example #1
0
    def handle(self, options, global_options, *args):
        from uliweb.orm import get_model
        from uliweb.utils.common import Serial
        import pprint

        self.get_application(global_options)
        WorkflowSpec = get_model('workflow_spec')
        TaskSpec = get_model('task_spec')

        print "TaskSpec : %s" % (TaskSpec.all().count())
        for task in TaskSpec.all():
            print " * %s" % task.name
            if global_options.verbose:
                print "   - modified_date: %s" % task.modified_date
                print "   - source: %s" % task.source
            if options.detail:
                pprint.pprint(Serial.load(task.content))

        print "\nWorkflowSpec : %s" % (WorkflowSpec.all().count())
        for wf in WorkflowSpec.all():
            print " * %s" % wf.name
            if global_options.verbose:
                print "   - modified_date: %s" % wf.modified_date
                print "   - source: %s" % wf.source
            if options.detail:
                pprint.pprint(Serial.load(wf.content))
Example #2
0
 def handle(self, options, global_options, *args):
     from uliweb.orm import get_model
     from uliweb.utils.common import Serial
     import pprint
     
     self.get_application(global_options)
     WorkflowSpec = get_model('workflow_spec')
     TaskSpec = get_model('task_spec')
     
     print "TaskSpec : %s" % (TaskSpec.all().count())
     for task in TaskSpec.all():
         print " * %s" % task.name
         if global_options.verbose:
             print "   - modified_date: %s" % task.modified_date
             print "   - source: %s" % task.source
         if options.detail:
             pprint.pprint(Serial.load(task.content))
     
     print "\nWorkflowSpec : %s" % (WorkflowSpec.all().count())
     for wf in WorkflowSpec.all():
         print " * %s" % wf.name
         if global_options.verbose:
             print "   - modified_date: %s" % wf.modified_date
             print "   - source: %s" % wf.source
         if options.detail:
             pprint.pprint(Serial.load(wf.content))
Example #3
0
    def get_menu(cls, parent):
        from uliweb import functions, settings
        from uliweb.utils.common import Serial

        def _f(_p):
            menus = []
            for row in cls.filter(cls.c.parent == _p, cls.c.type == 'M0000',
                                  cls.c.deploy_type == 'F',
                                  cls.c.status == '00001').order_by(
                                      cls.c.order):
                item = row.to_dict()
                item['link'] = row.value
                item['permissions'] = [x.name for x in row.permissions]
                menus.append(item)
                if row.has_children:
                    item['subs'] = _f(item.id)
                else:
                    item['subs'] = []
            return menus

        menus = []
        use_redis = settings.get_var('RESOURCE/USE_REDIS')
        key = 'MENU:{}'.format(parent)
        if use_redis:
            redis = functions.get_redis()
            v = redis.get(key)
            if v:
                menus = Serial.load(v)
        if not menus:
            p = cls.get(cls.c.name == parent)
            menus = _f(p.id)
            if menus and use_redis:
                redis.set(key, Serial.dump(menus))
        return menus
Example #4
0
    def load_workflow(self, wf_spec_name):

        from uliweb.orm import get_model
        from uliweb.utils.common import Serial

        WorkflowSpec = get_model('workflow_spec')
        TaskSpec = get_model('task_spec')
        spec = WorkflowSpec.get(WorkflowSpec.c.name == wf_spec_name)
        if not spec:
            raise KeyError('worlflow spec (%s) does not exist.' % wf_spec_name)

        proc = Serial.load(spec.content)
        tasks = {}
        task_list = proc.get('tasks', [])
        for key in task_list:
            task = TaskSpec.get(TaskSpec.c.name == task_list[key])
            tasks[key] = Serial.load(task.content)
        return proc, tasks
Example #5
0
    def deserialize(self, obj):
        from redbreast.core.spec import CoreWFManager
        from uliweb.orm import get_model
        from uliweb.utils.common import Serial
        WFTask = get_model('workflow_task')
        WFTrans = get_model('workflow_trans')

        self.obj = obj
        if obj:
            workflow_spec = CoreWFManager.get_workflow_spec(obj.spec_name)
            self.spec = workflow_spec
            self.state = obj.state
            self.data = Serial.load(obj.data)
            self.ref_unique_id = obj.ref_unique_id

            #DEBUG -------------------------
            if __DEBUG__:
                print 'workflow deserialize -----------------------------(1)'
                print 'ref_unique_id: %s-%s' % (self.ref_unique_id, obj.ref_unique_id)
                print 'spec_name: %s' % self.spec.name
                print 'state: %s' % self.state
                print 'workflow deserialize -----------------------------(2)'

            #DEBUG


            start_task_obj = None
            task_list = {}

            for task_obj in obj.tasks.order_by(WFTask.c.id):
                if not start_task_obj:
                    start_task_obj = task_obj
                task_list[task_obj.id] = self.Task(
                    self, self.spec.get_task_spec(task_obj.alias_name), state=None)
                task_list[task_obj.id].deserialize(task_obj)

            #DEBUG -------------------------
            if __DEBUG__:
                for a in task_list:
                    print a, task_list[a]
                print "----------------------------------------------"
                print task_list[start_task_obj.id]
                print "----------------------------------------------"
            #DEBUG -------------------------

            self.task_tree = task_list[start_task_obj.id]

            for trans_obj in obj.trans.order_by(WFTrans.c.id):
                from_task_id = trans_obj._from_task_
                to_task_id = trans_obj._to_task_
                if from_task_id and to_task_id:
                    task_list[from_task_id].children.append(task_list[to_task_id])
                    task_list[to_task_id].parents.append(task_list[from_task_id])
Example #6
0
    def deserialize(self, obj):
        from redbreast.core.spec import CoreWFManager
        from uliweb.orm import get_model
        from uliweb.utils.common import Serial

        WFTask = get_model("workflow_task")
        WFTrans = get_model("workflow_trans")

        self.obj = obj
        if obj:
            workflow_spec = CoreWFManager.get_workflow_spec(obj.spec_name)
            self.spec = workflow_spec
            self.state = obj.state
            self.data = Serial.load(obj.data)
            self.ref_unique_id = obj.ref_unique_id

            # DEBUG -------------------------
            if __DEBUG__:
                print "workflow deserialize -----------------------------(1)"
                print "ref_unique_id: %s-%s" % (self.ref_unique_id, obj.ref_unique_id)
                print "spec_name: %s" % self.spec.name
                print "state: %s" % self.state
                print "workflow deserialize -----------------------------(2)"

            # DEBUG

            start_task_obj = None
            task_list = {}

            for task_obj in obj.tasks.order_by(WFTask.c.id):
                if not start_task_obj:
                    start_task_obj = task_obj
                task_list[task_obj.id] = self.Task(self, self.spec.get_task_spec(task_obj.alias_name), state=None)
                task_list[task_obj.id].deserialize(task_obj)

            # DEBUG -------------------------
            if __DEBUG__:
                for a in task_list:
                    print a, task_list[a]
                print "----------------------------------------------"
                print task_list[start_task_obj.id]
                print "----------------------------------------------"
            # DEBUG -------------------------

            self.task_tree = task_list[start_task_obj.id]

            for trans_obj in obj.trans.order_by(WFTrans.c.id):
                from_task_id = trans_obj._from_task_
                to_task_id = trans_obj._to_task_
                if from_task_id and to_task_id:
                    task_list[from_task_id].children.append(task_list[to_task_id])
                    task_list[to_task_id].parents.append(task_list[from_task_id])
Example #7
0
def process():
    from uliweb.utils.common import Serial
    from uliweb.mail import Mail

    redis = functions.get_redis()
    while 1:
        data = redis.brpop("sendmail", 5)
        if data:
            message = Serial.load(data[1])
            log.info(message)
            Mail().send_mail(**message)
        else:
            log.info("no data")
Example #8
0
    def deserialize(self, obj):
        from uliweb.utils.common import Serial
        #state
        self.obj = obj
        if self.obj:
            self._state = obj.state
            self.state_history = [obj.state]
            self.uuid = obj.uuid

            self.data = Serial.load(obj.data)

            #data for deliver
            self.deliver_msg = self.get_data('deliver_msg', "")
            self.operator = self.get_data('operator', "")
            self.next_tasks = self.get_data('next_tasks', [])
Example #9
0
    def deserialize(self, obj):
        from uliweb.utils.common import Serial
        #state
        self.obj = obj
        if self.obj:
            self._state = obj.state
            self.state_history = [obj.state]
            self.uuid = obj.uuid

            self.data = Serial.load(obj.data)

            #data for deliver
            self.deliver_msg = self.get_data('deliver_msg', "")
            self.operator = self.get_data('operator', "")
            self.next_tasks = self.get_data('next_tasks', [])