Exemplo n.º 1
0
    def __init__(self, **arg):
        """
        :param:
            editor (BaseEditor): optional
            toollist (dict): list of tool to be instanciated
            rtd (runtime data)
            cfd (config data)
            tkd (task data)
        """
        super(BaseAppHandler, self).__init__()

        self._toolList = arg.get('toollist', dict()) if arg else None

        self._editor = arg.get('editor', None)
        if self._editor == None:
            self._editor = BaseEditor(**arg)

        self._runtimedata = arg.get('rtd', None) if arg else None
        self._configdata = arg.get('cfd', None) if arg else None
        self._taskdata = arg.get('tkd', None) if arg else None

        if self._runtimedata == None:
            self._runtimedata = TpVariable()

        if self._configdata == None:
            self._configdata = TpVariable()
            self._configdata.debug = False

        if self._taskdata == None:
            self._taskdata = TpVariable()

        logger = None
        if hasattr(self._configdata, 'do_log') and self._configdata.do_splash:
            from dsk.base.lib.log_manager import LogManager
            l = LogManager()
            l.initialize_custom_handler()
            l.global_debug = True
            logger = l.get_logger(__name__)

        if hasattr(self._configdata,
                   'do_splash') and self._configdata.do_splash:
            try:
                from dsk.base.utils import qt_utils
                if self._configdata.do_splash == True:
                    self._configdata.splash = qt_utils.get_splash()
                    self._configdata.splash.hide()
            except Exception as e:
                if logger:
                    logger.warning("%s" % str(e))

        if hasattr(self._configdata, 'do_auth') and self._configdata.do_auth:
            from dsk.base.conn_helper import shotgun_startup as SGS
            if self._configdata.do_auth == True:
                #get_user_credential
                user = SGS.get_user()
                self._runtimedata.connection = SGS.get_user_connection(user)
Exemplo n.º 2
0
    def __init__(self):
        super(myclassname1, self).__init__()
        from dsk.base.tdata.taskdata.tp_variable import TpVariable,ProcessVar

        # instance
        self.CFD = TpVariable()
        self.CFD.set_with_dict({u'debug': True, u'prefefile': u'cfdfoo'})
        self.RTD = TpVariable()
        self.RTD.set_with_dict({u'debug': False, u'showname': u'devshow'})
        self.TP = ProcessVar()
Exemplo n.º 3
0
def test_taskdata_api():
    t1 = GenPyTask()
    t1.setName("firstTask")
    assert t1.getTypeName()
    assert None == t1.set_comment("this is a comment")
    assert t1.get_argument_string() == ""
    assert t1.get_attribute_names() != ""
    assert isinstance(t1.get_attribute_names(), list)
    assert t1.get_lock_up()
    #print t1.get_lock_up()
    assert t1.is_script() == False
    assert t1.set("module", "dskenv.api.dsk_naming") == True
    assert t1.set("command", "DskNaming")
    assert t1.set("output", "a")

    t2 = GenPyTask()
    t2.setName("secondTask")
    assert t2.set("handler", "exec") == True
    full_text = list()
    full_text.append(
        "show=RTD.showname\nprint a\nprint a.get_base_project_config(show)\nprint a.get_base_version_pack(show)\nprint RTD"
    )
    full_text.append("print RTD.get_as_dict()")
    full_text.append("print CFD.get_as_dict()")
    full_text.append("print TP.get_as_dict()")
    assert t2.set("command", "\n".join(full_text))

    rtd = TpVariable()
    rtd.showname = ashowname
    rtd.debug = False
    cfd = TpVariable()
    cfd.prefefile = "cfdfoo"
    cfd.debug = True

    g = GenGroupTask()
    g.setName("doIt")
    g.setVariable(rtd, cfd)
    g.addChild(t1)
    g.addChild(t2)
    value = TaskDataApi.dumps_to_python(loadedTp=g,
                                        className="myclassname1",
                                        skipComment=False,
                                        doTaskPackage=False,
                                        doTrace=True,
                                        searchPath=None,
                                        mainType="instance")
    #print value

    open("foo.py", "w").write(value)
    #exec(value)
    code = compile(value, '<string>', 'exec')
    ns = {}
    exec code in ns
    assert ns['objectProc'].RTD.showname == ashowname
Exemplo n.º 4
0
class myclassname1(object):
    def __init__(self):
        super(myclassname1, self).__init__()
        from dsk.base.tdata.taskdata.tp_variable import TpVariable,ProcessVar

        # instance
        self.CFD = TpVariable()
        self.CFD.set_with_dict({u'debug': True, u'prefefile': u'cfdfoo'})
        self.RTD = TpVariable()
        self.RTD.set_with_dict({u'debug': False, u'showname': u'devshow'})
        self.TP = ProcessVar()
        ##########end init

    def doIt(self,RTD=None,CFD=None,TP=None):
        CFD = self.CFD.overwrite(CFD)
        RTD = self.RTD.overwrite(RTD)
        TP = self.TP.overwrite(TP)



        #
        # firstTask -- this is a comment
        #
        import dskenv.api.dsk_naming
        a = dskenv.api.dsk_naming.DskNaming()


        #
        # secondTask
        #
        show=RTD.showname
        print a
        print a.get_base_project_config(show)
        print a.get_base_version_pack(show)
        print RTD
        print RTD.get_as_dict()
        print CFD.get_as_dict()
        print TP.get_as_dict()
Exemplo n.º 5
0
class myclassname(object):
    def __init__(self):
        super(myclassname, self).__init__()
        from dsk.base.tdata.taskdata.tp_variable import TpVariable, ProcessVar

        # instance
        self.CFD = TpVariable()
        self.CFD.set_with_dict({u'debug': True, u'prefefile': u'cfdfoo'})
        self.RTD = TpVariable()
        self.RTD.set_with_dict({u'debug': False, u'showname': u'devshow'})
        self.TP = ProcessVar()
        ##########end init

    def MainGroup(self, RTD=None, CFD=None, TP=None):
        CFD = self.CFD.overwrite(CFD)
        RTD = self.RTD.overwrite(RTD)
        TP = self.TP.overwrite(TP)

        #
        # firstTask -- this is a comment
        #
        import dskenv.api.dsk_naming
        a = dskenv.api.dsk_naming.DskNaming()

        #
        # secondTask
        #
        show = RTD.showname
        print a
        print a.get_base_project_config(show)
        print a.get_base_version_pack(show)
        print RTD
        print RTD.get_as_dict()
        print CFD.get_as_dict()
        print TP.get_as_dict()

        #
        # doIt2
        #
        self.doIt2(RTD, CFD, TP)

    ##############################
    def doIt2(self, RTD, CFD, TP):

        #
        # firstTask -- this is a comment
        #
        import dskenv.api.dsk_naming
        a = dskenv.api.dsk_naming.DskNaming()

        #
        # secondTask
        #
        show = RTD.showname
        print a
        print a.get_base_project_config(show)
        print a.get_base_version_pack(show)
        print RTD
        print RTD.get_as_dict()
        print CFD.get_as_dict()
        print TP.get_as_dict()

        #
        # amayatask
        #
        print 'before maya'
        print 'befor maya second line'
        self.amayatask(RTD, CFD, TP)
        print 'after maya'

        #
        # apackage
        #
        #TaskPackage turn off
        return

    ##############################
    def amayatask(self, RTD, CFD, TP):
        def remote_amayatask(RTD, CFD, TP):

            #
            # firstTaskinmaya -- this is in maya
            #
            import dskenv.api.dsk_naming
            a = dskenv.api.dsk_naming.DskNaming()

            #
            # second Taskinmaya -- this is in maya2
            #
            import dskenv.api.dsk_naming33
            a = dskenv.api.dsk_naming33.DskNaming()

        if TP.is_remote():
            TP.set_remote(False)
            return remote_amayatask(RTD, CFD, TP)
        else:
            from dsk.base.lib.wrapper_xenvi import WrapperxEnvi
Exemplo n.º 6
0
def test_taskdata_api_group():
    t1 = GenPyTask()
    t1.setName("firstTask")
    assert t1.getTypeName()
    assert None == t1.set_comment("this is a comment")
    assert t1.get_argument_string() == ""
    assert t1.get_attribute_names() != ""
    assert isinstance(t1.get_attribute_names(), list)
    assert t1.get_lock_up()
    #print t1.get_lock_up()
    assert t1.is_script() == False
    assert t1.set("module", "dskenv.api.dsk_naming") == True
    assert t1.set("command", "DskNaming")
    assert t1.set("output", "a")

    t2 = GenPyTask()
    t2.setName("secondTask")
    assert t2.set("handler", "exec") == True
    full_text = list()
    full_text.append(
        "show=RTD.showname\nprint a\nprint a.get_base_project_config(show)\nprint a.get_base_version_pack(show)\nprint RTD"
    )
    full_text.append("print RTD.get_as_dict()")
    full_text.append("print CFD.get_as_dict()")
    full_text.append("print TP.get_as_dict()")
    assert t2.set("command", "\n".join(full_text))

    t3 = GenPyTask()
    t3.setName("firstTask")
    assert t3.getTypeName()
    assert None == t3.set_comment("this is a comment")
    assert t3.get_argument_string() == ""
    assert t3.get_attribute_names() != ""
    assert isinstance(t3.get_attribute_names(), list)
    assert t3.get_lock_up()
    #print t3.get_lock_up()
    assert t3.is_script() == False
    assert t3.set("module", "dskenv.api.dsk_naming") == True
    assert t3.set("command", "DskNaming")
    assert t3.set("output", "a")

    t4 = GenPyTask()
    t4.setName("secondTask")
    assert t4.set("handler", "exec") == True
    full_text = list()
    full_text.append(
        "show=RTD.showname\nprint a\nprint a.get_base_project_config(show)\nprint a.get_base_version_pack(show)\nprint RTD"
    )
    full_text.append("print RTD.get_as_dict()")
    full_text.append("print CFD.get_as_dict()")
    full_text.append("print TP.get_as_dict()")
    assert t4.set("command", "\n".join(full_text))

    rtd = TpVariable()
    rtd.showname = ashowname
    rtd.debug = False
    cfd = TpVariable()
    cfd.prefefile = "cfdfoo"
    cfd.debug = True

    g = GenGroupTask()
    g.setName("MainGroup")
    g.setVariable(rtd, cfd)
    g.addChild(t1)
    g.addChild(t2)

    g2 = GenGroupTask()
    g2.setName("doIt2")
    g2.setVariable(rtd, cfd)
    g2.addChild(t3)
    g2.addChild(t4)

    g.addChild(g2)

    tmaya = GenExternalTask()
    tmaya.setName("amayatask")
    assert tmaya.set("preExec",
                     "print 'before maya'\nprint 'befor maya second line'")
    assert tmaya.set("postExec", "print 'after maya'")
    assert tmaya.set("block", True)
    assert tmaya.set("daemon", True)
    g2.addChild(tmaya)

    # task in maya 1
    taskinmaya = GenPyTask()
    taskinmaya.setName("firstTaskinmaya")
    assert taskinmaya.getTypeName()
    assert None == taskinmaya.set_comment("this is in maya")
    assert taskinmaya.get_argument_string() == ""
    assert taskinmaya.get_attribute_names() != ""
    assert isinstance(taskinmaya.get_attribute_names(), list)
    assert taskinmaya.get_lock_up()
    #print taskinmaya.get_lock_up()
    assert taskinmaya.is_script() == False
    assert taskinmaya.set("module", "dskenv.api.dsk_naming") == True
    assert taskinmaya.set("command", "DskNaming")
    assert taskinmaya.set("output", "a")
    tmaya.addChild(taskinmaya)

    # task in maya 2
    taskinmaya2 = GenPyTask()
    taskinmaya2.setName("second Taskinmaya")
    assert taskinmaya2.getTypeName()
    assert None == taskinmaya2.set_comment("this is in maya2")
    assert taskinmaya2.get_argument_string() == ""
    assert taskinmaya2.get_attribute_names() != ""
    assert isinstance(taskinmaya2.get_attribute_names(), list)
    assert taskinmaya2.get_lock_up()
    #print taskinmaya.get_lock_up()
    assert taskinmaya2.is_script() == False
    assert taskinmaya2.set("module", "dskenv.api.dsk_naming33") == True
    assert taskinmaya2.set("command", "DskNaming")
    assert taskinmaya2.set("output", "a")
    tmaya.addChild(taskinmaya2)

    tpackage = GenPackageTask()
    tpackage.setName("apackage")
    tpackage.set(
        "file",
        "/mnt/dev/eric/packages/devsoftkit/python/unittest/utest_taskdata/doIt.tpp.gz"
    )
    g2.addChild(tpackage)

    value = TaskDataApi.dumps_to_python(loadedTp=g,
                                        className="myclassname",
                                        skipComment=False,
                                        doTaskPackage=False,
                                        doTrace=True,
                                        searchPath="",
                                        mainType="instance")
    #print value

    open("foo2.py", "w").write(value)
    """
    #exec(value)
    code = compile(value, '<string>', 'exec')
    ns = {}
    exec code in ns
    assert ns['objectProc'].RTD.showname == ashowname
    """
    TaskDataApi.save_tp(g)