Example #1
0
    def get_application_wdg(self):

        page = None

        try:
            project = Project.get()
        except Exception as e:
            Project.set_project("sthpw")
            from pyasm.widget import Error404Wdg
            page = Error404Wdg()
            page.set_message(e.__str__())
            page.status = ''

        application = self.get_top_wdg()

        # get the main page widget
        # NOTE: this needs to happen after the body is put in a Container
        if not page:
            page = self.get_page_widget()
        page.set_as_top()
        if type(page) in types.StringTypes:
            page = StringWdg(page)

        application.add(page, 'content')

        return application
Example #2
0
    def execute(self):

        self.base_dir = self.kwargs.get("base_dir")
        if not self.base_dir:
            self.base_dir = Environment.get_template_dir()


        self.project_code = self.kwargs.get("project_code")
        if not self.project_code:
            self.project_code = Project.get_project_code()

        assert self.project_code

        # project code can be called anything, and we want to have a _template suffix for the template code
        #self.plugin_code = "%s_template" % self.project_code

        #self.template_project_code = re.sub( '_template$', '', self.plugin_code)
        self.template_project_code = self.project_code
        self.project = Project.get_by_code(self.project_code)
        if not self.project:
            raise TacticException('This project [%s] does not exist'%self.project_code)

        self.project_type = self.project.get_value("type")
        if not self.project_type:
            self.project_type = self.project_code
        Project.set_project(self.project_code)

        self.export_template()
Example #3
0
    def get_loader_xml(my, ticket, project_code, snapshot_code, context="", options=""):
        '''uses the loader to generate an execute xml that can be
        used to load the assets'''
        try:
            my.init(ticket)
            Project.set_project(project_code)

            snapshot = Snapshot.get_by_code(snapshot_code)

            # get the loader implementation
            loader_context = ProdLoaderContext()
            loader_context.set_context(context)

            # pass on any message options for the loader
            if options != "":
                loader_context.set_options(options)

            loader = loader_context.get_loader(snapshot)
            loader.execute()

            execute_xml = loader.get_execute_xml()
            xml = execute_xml.get_xml()

        finally:
            DbContainer.close_all()
        
        return xml
Example #4
0
    def test_all(my):
        '''entry point function'''
        my.description = "Checkin unit test"
        my.errors = []

        Batch()

        # FIXME: this is needed for the triggers to be registerd. These
        # triggers have nothing to do with the web
        from pyasm.web import WebInit
        WebInit().execute()

        test_env = UnittestEnvironment()
        test_env.create()

        Project.set_project("unittest")

        try:
            Command.execute_cmd(my)

            # undo the command
            undo = UndoCmd()
            undo.execute()

        finally:
            test_env.delete()
Example #5
0
    def checkin_shot_set(my, ticket, project_code, shot_code, process, context, \
             checkin_as, currency, unknown_ref, desc):
        snapshot_code = ''
        try:
            my.init(ticket)
            Project.set_project(project_code)

            shot = Shot.get_by_code(shot_code)
            checkin = ShotCheckin(shot)
            checkin.set_description(desc)
            checkin.set_process(process)
            checkin.set_context(context)

            is_current = True
            if currency == 'False':
                is_current = False
            is_revision = False
            if checkin_as == 'Revision':
                is_revision = True

            checkin.set_current(is_current)
            checkin.set_revision(is_revision)
            checkin.set_option("unknown_ref", unknown_ref)
            Command.execute_cmd(checkin)
            snapshot_code = checkin.snapshot.get_code()

        finally:
            DbContainer.close_all()
          
        
        return snapshot_code
Example #6
0
    def test_all(self):
        print "Running Sample3d Test"

        from pyasm.security import Batch
        from pyasm.biz import Project
        Batch()
        Project.set_project("sample3d")

        #self.server = TacticServerStub(protocol="local")
        self.server = TacticServerStub(protocol="xmlrpc")
        project_code = "sample3d"
        self.server.set_project(project_code)

        self.server.start("Sample3d Test")
        try:
            self._test_create_search_type()
            self._test_create_submission()
            self._test_get_submission()
            self._test_shot_sequence_hierarchy()
            self._test_query_snapshots()
            #self._test_performance()
        except Exception:
            self.server.abort()
            raise
        self.server.abort()
Example #7
0
    def _test_copy_project(self):

        #transaction = Transaction.get(create=True)
        try:
            os.system('dropdb -U postgres "game_copy"')
            from tactic.command import ProjectTemplateInstallerCmd
            cmd =  ProjectTemplateInstallerCmd(project_code='game_copy', template_code='game', mode='copy')
            cmd.execute()
        

            schema_entry = Search.eval("@GET(sthpw/schema['code','game_copy'].code)", single=True)
            self.assertEquals(schema_entry, 'game_copy')
            project_entry = Search.eval("@GET(sthpw/project['code','game_copy'].code)", single=True)
            self.assertEquals(project_entry, 'game_copy')
            Project.set_project('game_copy')

            widget_config_st = Search.eval("@GET(config/widget_config['code','1GAME'].search_type)", single=True) 
            self.assertEquals(widget_config_st, 'game/ticket')

            widget_config_counts = Search.eval("@COUNT(config/widget_config)") 
            self.assertEquals(widget_config_counts, 133)
            Project.set_project('unittest')
        finally:
            
            sql = DbContainer.get('sthpw')
            sql.do_update("delete from project where code ='game_copy'")
            sql.do_update("delete from schema where code ='game_copy'")
            sql.commit()
            
            DbContainer.close_all()
            os.system('dropdb -U postgres "game_copy"')
Example #8
0
    def test_all(self):
        '''entry point function'''
        self.description = "Checkin unit test"
        self.errors = []

        Batch()

        # FIXME: this is needed for the triggers to be registerd. These
        # triggers have nothing to do with the web
        from pyasm.web import WebInit
        WebInit().execute()

        test_env = UnittestEnvironment()
        test_env.create()
        self.transaction = Transaction.get(create=True)

        Project.set_project("unittest")

        try:
            #Command.execute_cmd(self)

            # undo the command
            #undo = UndoCmd()
            #undo.execute()
            self.execute()

        finally:
            self.transaction.rollback()
            test_env.delete()
Example #9
0
    def test_all(my):

      

        try:

            db_res = DbResource.get_default('unittest')
            sql = DbContainer.get(db_res)
            impl = sql.get_database_impl()
            db_type = impl.get_database_type()
            if db_type == "PostgreSQL":
                my.prefix = '''"unittest"."public"'''
                my.sthpw_prefix = '''"sthpw"."public"'''
            else:
                my.prefix = '''"unittest"'''
                my.sthpw_prefix = '''"sthpw"'''


            my._test_get_connect()
            my._test_select_class()
            my._test_insert_class()
            my._test_update_class()
            my._test_insert_and_delete()
            my._test_create_table()
            my._test_transaction()
            my._test_order_by()
            my._test_rpn_filters()
            my._test_search_filter()
            my._test_join()
            my._test_add_drop_column()
       
        finally:
            Project.set_project('unittest')
            my.test_env.delete()
Example #10
0
 def create_set(my, ticket, project_code, set_name, cat_name, selected):
     '''an xml to create a new set node'''
     xml = ''
     asset_code = ''
     try:
         my.init(ticket)
         Project.set_project(project_code)
         cmd = MayaSetCreateCmd()
         cmd.set_set_name(set_name)
         cmd.set_cat_name(cat_name)
         
         Command.execute_cmd(cmd)
         
         asset_code = cmd.get_asset_code() 
         if asset_code:
             cmd = CreateSetNodeCmd()
             cmd.set_asset_code(asset_code)
             cmd.set_instance(set_name)
             cmd.set_contents(selected)
             cmd.execute()
             execute_xml = cmd.get_execute_xml()
             xml = execute_xml.get_xml()
             
     finally:
         DbContainer.close_all()
     
     return [xml, asset_code]
Example #11
0
    def _test_join(my):
        """ test a select """
        Project.set_project('unittest')
        select = Select()
        db_res = DbResource.get_default('unittest')
        select.set_database(db_res)
        select.add_table("person")
        select.add_join('person','city', 'city_code','code')
        select.add_join('city','country', 'country_code','code')
        select.add_order_by("name_last")

        statement = select.get_statement()
        my.assertEquals(statement, '''SELECT %s"person".* FROM %s"person" LEFT OUTER JOIN %s"city" ON "person"."city_code" = "city"."code" LEFT OUTER JOIN %s"country" ON "city"."country_code" = "country"."code" ORDER BY "person"."name_last"''' % (my.prefix, my.prefix, my.prefix, my.prefix) )


        search = Search('unittest/person')
        search.add_join('unittest/city', 'unittest/person')
        statement = search.get_statement()
        my.assertEquals(statement, '''SELECT %s"person".* FROM %s"person" LEFT OUTER JOIN %s"city" ON "person"."city_code" = "city"."code"''' % (my.prefix,my.prefix, my.prefix))

        statement = search.get_statement()
        # this one has no schema connection, so will be ignored
        search.add_join('sthpw/login', 'unittest/person')
        my.assertEquals(statement, '''SELECT %s"person".* FROM %s"person" LEFT OUTER JOIN %s"city" ON "person"."city_code" = "city"."code"''' % (my.prefix, my.prefix, my.prefix))

        search.add_join('unittest/country', 'unittest/city')
        statement = search.get_statement()
        my.assertEquals(statement, '''SELECT %s"person".* FROM %s"person" LEFT OUTER JOIN %s"city" ON "person"."city_code" = "city"."code" LEFT OUTER JOIN %s"country" ON "city"."country_code" = "country"."code"''' % (my.prefix, my.prefix, my.prefix, my.prefix) )
Example #12
0
    def update_session(my, ticket, project_code, user, pid, data):

        try:
            my.init(ticket)
            Project.set_project(project_code) 
            # get the session sobject
            sobject = None
            search = Search("prod/session_contents", project_code=project_code)
            search.add_filter("login", user)
            search.add_filter("pid", pid)
            sobject = search.get_sobject()

            # if none exists, then create one
            if sobject == None:
                search_type = SearchType.build_search_type('prod/session_contents', project_code)
                sobject = SearchType.create(search_type)
                sobject.set_value("login", user)
                sobject.set_value("pid", pid)

            sobject.set_value("data", data)

            impl = search.get_database_impl()
            sobject.set_value("timestamp", impl.get_timestamp_now(), quoted=False)
            sobject.commit()

        finally:
            DbContainer.close_all()

        return True
Example #13
0
    def init(self):
        
        web = WebContainer.get_web()

        project_code = web.get_form_value("project")
        if project_code:
            Project.set_project(project_code)

        method = web.get_form_value("method")
        widget_class = web.get_form_value("widget")
        if widget_class == "":
            return
       
        arg_type = web.get_form_value("arg_type")
        if arg_type == "dict" and not method:
            args = web.get_form_args()
            exec(Common.get_import_from_class_path(widget_class))
            widget = eval("%s.init_dynamic(args)" % widget_class)
        elif method:
            widget = Common.create_from_method(widget_class, method)
        else:
            widget_args = web.get_form_values(WebEnvironment.ARG_NAME)
            widget = Common.create_from_class_path(widget_class, widget_args)

        # tell the widget that it is the top widget
        widget.set_as_top()

        self.add(widget)
Example #14
0
    def import_default_side_bar(self):
        code = Search.eval(
            "@GET(config/widget_config['code','WIDGET_CONFIG000000'].code)",
            single=True)
        if code:
            print "Default side bar already exists!"
            return

        project_code = self.kwargs.get('project_code')
        # It looks like project=XXX on SearchType.create does not work
        Project.set_project(project_code)
        config = SearchType.create("config/widget_config?project=%s" %
                                   project_code)
        config.set_value("code", "WIDGET_CONFIG000000")
        config.set_value("category", "SideBarWdg")
        config.set_value("search_type", "SideBarWdg")
        config.set_value("view", "project_view")

        xml = '''<?xml version='1.0' encoding='UTF-8'?>
<config>
  <project_view>
    <element name='_home' title='Examples'/>
  </project_view>
</config>
'''
        config.set_value("config", xml)

        config.commit()
Example #15
0
    def test_all(my):
        batch = Batch()
        Environment.get_security().set_admin(True)

        from pyasm.unittest import UnittestEnvironment, Sample3dEnvironment
        test_env = UnittestEnvironment()
        test_env.create()

        sample3d_env = Sample3dEnvironment(project_code='sample3d')
        sample3d_env.create()

        Project.set_project("unittest")
        try:
            my.access_manager = Environment.get_security().get_access_manager()
            my._test_all()

        finally:
            #Project.set_project("unittest")
            Environment.get_security()._access_manager = my.access_manager
            my._tear_down()
            Environment.get_security().set_admin(True)
            test_env.delete()
            Environment.get_security().set_admin(True)
            sample3d_env.delete()
            Site.pop_site()
Example #16
0
    def execute(self):

        self.base_dir = self.kwargs.get("base_dir")
        if not self.base_dir:
            self.base_dir = Environment.get_template_dir()

        self.project_code = self.kwargs.get("project_code")
        if not self.project_code:
            self.project_code = Project.get_project_code()

        assert self.project_code

        # project code can be called anything, and we want to have a _template suffix for the template code
        #self.plugin_code = "%s_template" % self.project_code

        #self.template_project_code = re.sub( '_template$', '', self.plugin_code)
        self.template_project_code = self.project_code
        self.project = Project.get_by_code(self.project_code)
        if not self.project:
            raise TacticException('This project [%s] does not exist' %
                                  self.project_code)

        self.project_type = self.project.get_value("type")
        if not self.project_type:
            self.project_type = self.project_code
        Project.set_project(self.project_code)

        self.export_template()
Example #17
0
    def test_all(self):
        Batch()
        from pyasm.web.web_init import WebInit
        WebInit().execute()

        test_env = UnittestEnvironment()
        test_env.create()

        self._test_command()
        self._test_trigger()
        trigger_key = "triggers:cache"
        Container.put(trigger_key, None)

        try:
            self._test_api_trigger()
            self._test_insert_trigger()

            # test copy project from template
            self._test_copy_project()
            # clear again for subsequent Client API test
            trigger_key = "triggers:cache"

            Container.put(trigger_key, None)
            trigger_key2 = Trigger.KEY
            Container.put(trigger_key2, None)
        finally:
            Project.set_project('unittest')
            test_env.delete()
Example #18
0
    def setUp(my):
        # start batch environment
        Batch()

        from pyasm.biz import Project

        Project.set_project("unittest")
Example #19
0
    def get_application_wdg(self):

        page = None

        try:
            project = Project.get()
        except Exception as e:
            Project.set_project("sthpw")
            from pyasm.widget import Error404Wdg
            page = Error404Wdg()
            page.set_message(e.__str__())
            page.status = ''


        application = self.get_top_wdg()

        # get the main page widget
        # NOTE: this needs to happen after the body is put in a Container
        if not page:
            page = self.get_page_widget()
        page.set_as_top()
        if type(page) in types.StringTypes:
            page = StringWdg(page)

        application.add(page, 'content')


        return application
Example #20
0
    def test_all(self):
        batch = Batch()
        Environment.get_security().set_admin(True)

        from pyasm.unittest import UnittestEnvironment, Sample3dEnvironment
        test_env = UnittestEnvironment()
        test_env.create()

        sample3d_env = Sample3dEnvironment(project_code='sample3d')
        sample3d_env.create()

        Project.set_project("unittest")
        try:
            self.access_manager = Environment.get_security().get_access_manager()   
            self._test_all()

        finally:
            # Reset access manager for tear down 
            Environment.get_security()._access_manager =  self.access_manager
            Environment.get_security().reset_access_manager() 
            self._tear_down()
            Environment.get_security().set_admin(True)
            test_env.delete()
            Environment.get_security().set_admin(True)
            sample3d_env.delete()
            Site.pop_site()
Example #21
0
    def test_all(self):
        '''entry point function'''

        Batch(site="demo")

        # Allows for triggers
        from pyasm.web import WebInit
        WebInit().execute()

        # Set up test environment
        from pyasm.unittest import Sample3dEnvironment
        test_env = Sample3dEnvironment(project_code='sample3d')
        Project.set_project("sample3d")
        test_env.create()
        
        # Commit environment setup transaction 
        #transaction = Transaction.get()
        #transaction.commit()
   
        # Get updates - creates shots and tasks
        self.updates = self._get_updates()
        
        try:
            self._test_no_updates()
            self._test_insert()
            self._test_status_change()
            self._test_compare()
            self._test_empty_update()
            #self._test_time()
        finally:
            test_env.delete()
Example #22
0
    def test_all(self):
        Batch()
        from pyasm.web.web_init import WebInit
        WebInit().execute()

        test_env = UnittestEnvironment()
        test_env.create()


        self._test_command()
        self._test_trigger()
        trigger_key = "triggers:cache"
        Container.put(trigger_key, None)

        try:
            self._test_api_trigger()
            self._test_insert_trigger()

            # test copy project from template
            self._test_copy_project()
            # clear again for subsequent Client API test
            trigger_key = "triggers:cache"

            Container.put(trigger_key, None)
            trigger_key2 = Trigger.KEY
            Container.put(trigger_key2, None)
        finally:
            Project.set_project('unittest')
            test_env.delete()
Example #23
0
    def checkin_textures(my, ticket, project_code, asset_code, paths, file_ranges, node_names, attrs, use_handoff_dir=False, md5s=[]):
        '''creates a number of textures under a single asset'''
        new_paths = []
        try:
            my.init(ticket)
            Project.set_project(project_code)

            parent = Asset.get_by_code(asset_code)
            #parent = Search.get_by_search_key(search_key)
            context = 'publish'
            checkin = TextureCheckin(parent, context, paths, file_ranges, node_names, attrs, use_handoff_dir=use_handoff_dir, md5s=md5s)
            Command.execute_cmd(checkin)

            new_paths = checkin.get_texture_paths()
            #md5_list = checkin.get_texture_md5()
            file_code_list = checkin.get_file_codes()
            
            #loader_context = ProdLoaderContext()
            #updater = loader_context.get_updater(snapshot, asset_code, instance)
            #execute_xml = updater.get_execute_xml()
            #xml = execute_xml.to_string()
            
        finally:
            DbContainer.close_all()

        return new_paths, file_code_list
Example #24
0
    def test_all(self):
        '''entry point function'''
        self.description = "Checkin unit test"
        self.errors = []

        Batch()

        # FIXME: this is needed for the triggers to be registerd. These
        # triggers have nothing to do with the web
        from pyasm.web import WebInit
        WebInit().execute()


        test_env = UnittestEnvironment()
        test_env.create()
        self.transaction = Transaction.get(create=True)

        Project.set_project("unittest")
       
        try:
            #Command.execute_cmd(self)

            # undo the command
            #undo = UndoCmd()
            #undo.execute()
            self.execute()

        finally:
            self.transaction.rollback()
            test_env.delete()
Example #25
0
    def execute(my):

        my.base_dir = my.kwargs.get("base_dir")
        if not my.base_dir:
            my.base_dir = Environment.get_template_dir()

        my.project_code = my.kwargs.get("project_code")
        if not my.project_code:
            my.project_code = Project.get_project_code()

        assert my.project_code

        # project code can be called anything, and we want to have a _template suffix for the template code
        #my.plugin_code = "%s_template" % my.project_code

        #my.template_project_code = re.sub( '_template$', '', my.plugin_code)
        my.template_project_code = my.project_code
        my.project = Project.get_by_code(my.project_code)
        if not my.project:
            raise TacticException('This project [%s] does not exist' %
                                  my.project_code)

        my.project_type = my.project.get_value("type")
        if not my.project_type:
            my.project_type = my.project_code
        Project.set_project(my.project_code)

        my.export_template()
Example #26
0
    def test_all(my):
        '''entry point function'''
        my.description = "Checkin unit test"
        my.errors = []

        Batch()

        # FIXME: this is needed for the triggers to be registerd. These
        # triggers have nothing to do with the web
        from pyasm.web import WebInit
        WebInit().execute()


        test_env = UnittestEnvironment()
        test_env.create()

        Project.set_project("unittest")

        try:
            Command.execute_cmd(my)

            # undo the command
            undo = UndoCmd()
            undo.execute()

        finally:
            test_env.delete()
Example #27
0
    def import_default_side_bar(self):
        code = Search.eval("@GET(config/widget_config['code','WIDGET_CONFIG000000'].code)", single=True)
        if code:
            print "Default side bar already exists!"
            return

        
        project_code = self.kwargs.get('project_code')
        # It looks like project=XXX on SearchType.create does not work
        Project.set_project(project_code)
        config = SearchType.create("config/widget_config?project=%s" % project_code)
        config.set_value("code", "WIDGET_CONFIG000000")
        config.set_value("category", "SideBarWdg")
        config.set_value("search_type", "SideBarWdg")
        config.set_value("view", "project_view")
        
        xml = '''<?xml version='1.0' encoding='UTF-8'?>
<config>
  <project_view>
    <element name='_home' title='Examples'/>
  </project_view>
</config>
'''
        config.set_value("config", xml)

        config.commit()
Example #28
0
    def execute(my):

        my.base_dir = my.kwargs.get("base_dir")
        if not my.base_dir:
            my.base_dir = Environment.get_template_dir()


        my.project_code = my.kwargs.get("project_code")
        if not my.project_code:
            my.project_code = Project.get_project_code()

        assert my.project_code

        # project code can be called anything, and we want to have a _template suffix for the template code
        #my.plugin_code = "%s_template" % my.project_code

        #my.template_project_code = re.sub( '_template$', '', my.plugin_code)
        my.template_project_code = my.project_code
        my.project = Project.get_by_code(my.project_code)
        if not my.project:
            raise TacticException('This project [%s] does not exist'%my.project_code)

        my.project_type = my.project.get_value("type")
        if not my.project_type:
            my.project_type = my.project_code
        Project.set_project(my.project_code)

        my.export_template()
Example #29
0
    def test_all(self):
        print "Running Sample3d Test"

        from pyasm.security import Batch
        from pyasm.biz import Project
        Batch()
        Project.set_project("sample3d")


        #self.server = TacticServerStub(protocol="local")
        self.server = TacticServerStub(protocol="xmlrpc")
        project_code = "sample3d"
        self.server.set_project(project_code)


        self.server.start("Sample3d Test")
        try:
            self._test_create_search_type()
            self._test_create_submission()
            self._test_get_submission()
            self._test_shot_sequence_hierarchy()
            self._test_query_snapshots()
            #self._test_performance()
        except Exception:
            self.server.abort()
            raise
        self.server.abort()
Example #30
0
 def execute(my):
     try:
         #Batch()
         #Command.execute_cmd(timed_trigger)
         Project.set_project(my.project_code)
         timed_triggers[my.index].execute()
     except Exception, e:
         print "Error running trigger"
         raise
Example #31
0
 def execute(my):
     try:
         #Batch()
         #Command.execute_cmd(timed_trigger)
         Project.set_project(my.project_code)
         timed_triggers[my.index].execute()
     except Exception, e:
         print "Error running trigger"
         raise
Example #32
0
    def get_application_wdg(my):

        page = None

        try:
            project = Project.get()
        except Exception, e:
            Project.set_project("sthpw")
            from pyasm.widget import Error404Wdg
            page = Error404Wdg()
Example #33
0
    def __init__(self, project_code=None, login_code=None, site=None):
        self.set_app_server("batch")

        if not site:
            # if not explicitly set, keep the current site
           site = Site.get_site() 


        plugin_dir = Environment.get_plugin_dir()
        if plugin_dir not in sys.path:
            sys.path.insert(0, plugin_dir)

        super(Batch,self).__init__()

        self.login_code = login_code

        # clear the main container
        Container.create()

        if site:
            Site.set_site(site)

        # set this as the environment
        if not project_code:
            self.context = self.get_default_context()
        else:
            self.context = project_code

        Environment.set_env_object( self )

        # set up the security object
        security = Security()
        Environment.set_security(security)

        self._do_login()
        site_dir = Environment.get_site_dir()
        if site_dir not in sys.path:
            sys.path.insert(0, site_dir)

        # set the project
        from pyasm.biz import Project

        if self.context == "batch":
            Project.set_project("admin")
        else:
            Project.set_project(self.context)

        self.initialize_python_path()


        # start workflow engine
        #from pyasm.command import Workflow
        #Workflow().init()

        DbContainer.commit_thread_sql()
Example #34
0
 def execute(self):
     try:
         #Batch()
         #Command.execute_cmd(timed_trigger)
         Project.set_project(self.project_code)
         timed_triggers[self.index].execute()
     except Exception as e:
         raise
     finally:
         DbContainer.close_thread_sql()
         DbContainer.commit_thread_sql()
         DbContainer.close_all()
Example #35
0
    def test_all(self):
        # start batch environment
        Batch(login_code='admin')

        test_env = UnittestEnvironment()
        test_env.create()
        Project.set_project('admin')

        try:
            self._test_csv_export()
        finally:
            test_env.delete()
Example #36
0
    def get_application_wdg(my):

        page = None

        try:
            project = Project.get()
        except Exception, e:
            Project.set_project("sthpw")
            from pyasm.widget import Error404Wdg
            page = Error404Wdg()
            page.set_message(e.__str__())
            page.status = ''
Example #37
0
    def get_application_wdg(my):

        page = None

        try:
            project = Project.get()
        except Exception, e:
            Project.set_project("sthpw")
            from pyasm.widget import Error404Wdg
            page = Error404Wdg()
            page.set_message(e.__str__())
            page.status = ''
Example #38
0
 def execute(self):
     try:
         #Batch()
         #Command.execute_cmd(timed_trigger)
         Project.set_project(self.project_code)
         timed_triggers[self.index].execute()
     except Exception as e:
         raise
     finally:
         DbContainer.close_thread_sql()
         DbContainer.commit_thread_sql()
         DbContainer.close_all()
Example #39
0
    def checkin_frames(my, ticket, project_code, queue_id):
        try:
            my.init(ticket)
            Project.set_project(project_code)

            cmd = CheckinFramesXMLRPC()
            cmd.set_args(ticket, queue_id)
            Command.execute_cmd(cmd)

        finally:
            DbContainer.close_all()

        return True
Example #40
0
    def test_all(self):
        # start batch environment
        Batch(login_code='admin')

        test_env = UnittestEnvironment()
        test_env.create()
        Project.set_project('admin')

       
        try:
            self._test_csv_export()
        finally:
            test_env.delete()
Example #41
0
    def create_assets(my, ticket, project_code, set_code, names):

        try:
            my.init(ticket)
            Project.set_project(project_code)

            cmd = CreateSetAssetsCmd()
            cmd.set_set_code(set_code)
            cmd.set_names(names)
            Command.execute_cmd(cmd)
            asset_codes = cmd.get_asset_codes()
        finally:
            DbContainer.close_all()

        return asset_codes
Example #42
0
    def test_all(my):
        Batch()
        from pyasm.web.web_init import WebInit
        WebInit().execute()

        test_env = UnittestEnvironment()
        test_env.create()
        my.transaction = Transaction.get(create=True)
        try:
            my._test_multiple_schema()
        finally:
            my.transaction.rollback()
            Project.set_project('unittest')

            test_env.delete()
Example #43
0
    def test_all(my):
        Batch()
        from pyasm.web.web_init import WebInit
        WebInit().execute()

        test_env = UnittestEnvironment()
        test_env.create()
        my.transaction = Transaction.get(create=True)
        try:
            my._test_multiple_schema()
        finally:
            my.transaction.rollback()
            Project.set_project('unittest')

            test_env.delete()
Example #44
0
    def checkin_set(my, ticket, project_code, asset_code, context):
        snapshot_code = ''
        try:
            my.init(ticket)
            Project.set_project(project_code)

            new_set = Asset.get_by_code(asset_code)
            checkin = MayaGroupCheckin(new_set)
            checkin.set_context(context)
            checkin.set_description("Initial Publish")
            Command.execute_cmd(checkin)
            snapshot_code = checkin.snapshot.get_code()
        finally:
            DbContainer.close_all()
          
        return snapshot_code
Example #45
0
 def checkin_flash_shot(my, ticket, project_code,shot_code, context, comment):
         
     snapshot_code = ''
     try:
         my.init(ticket)
         Project.set_project(project_code)
         from pyasm.flash import FlashShotSObjectPublishCmd
         shot = Shot.get_by_code(shot_code)
         
         checkin = FlashShotSObjectPublishCmd(shot, context, comment)
         Command.execute_cmd(checkin)
         snapshot_code = checkin.snapshot.get_code()
     finally:
         DbContainer.close_all()
     
     return snapshot_code 
Example #46
0
    def get_shot_loader_xml(my, ticket, project_code, snapshot_code, shot_code, instance_name, context="", options=""):
        '''uses the loader to generate an execute xml that can be
        used to load the assets'''
        try:
            my.init(ticket)
            Project.set_project(project_code)

            snapshot = Snapshot.get_by_code(snapshot_code)

            # get the shot
            shot = Shot.get_by_code(shot_code)
            if not shot:
                raise ServiceException("No shot [%s] exists" % shot_code)


            # get the loader implementation
            loader_context = ProdLoaderContext()
            loader_context.set_shot(shot)
            loader_context.set_context(context)

            # pass on any message options for the loader
            if options != "":
                loader_context.set_options(options)

            loader = loader_context.get_loader(snapshot)

            # just set the shot if we are loading the shot
            if shot_code == instance_name:
                loader.set_instance(shot)
            else:
                instance = ShotInstance.get_by_shot(shot, instance_name)
                if not instance:
                    raise TacticException('Asset Instance [%s] not found in shot [%s]'%(instance_name, shot.get_code()))
                loader.set_instance(instance)

            # setting all instances in anim to be loaded with the unique flag
            loader.set_unique()

            loader.execute()

            execute_xml = loader.get_execute_xml()
            xml = execute_xml.get_xml()

        finally:
            DbContainer.close_all()
        
        return xml
Example #47
0
    def __init__(my, project_code=None, login_code=None, site=None):
        my.set_app_server("batch")

        plugin_dir = Environment.get_plugin_dir()
        if plugin_dir not in sys.path:
            sys.path.insert(0, plugin_dir)

        super(Batch, my).__init__()

        my.login_code = login_code

        # clear the main container
        Container.create()

        if site:
            Site.set_site(site)

        # set this as the environment
        if not project_code:
            my.context = my.get_default_context()
        else:
            my.context = project_code

        Environment.set_env_object(my)

        # set up the security object
        security = Security()
        Environment.set_security(security)

        my._do_login()
        site_dir = Environment.get_site_dir()
        if site_dir not in sys.path:
            sys.path.insert(0, site_dir)

        # set the project
        from pyasm.biz import Project

        if my.context == "batch":
            Project.set_project("admin")
        else:
            Project.set_project(my.context)

        my.initialize_python_path()

        DbContainer.commit_thread_sql()
Example #48
0
    def test_all(self):
        # intialiaze the framework as a batch process
        batch = Batch()
        from pyasm.web.web_init import WebInit
        WebInit().execute()

        self.test_env = UnittestEnvironment()
        self.test_env.create()
        #from pyasm.biz import Project
        #Project.set_project("unittest")

        try:
            self._test_transaction()
            self._test_undo()
            self._test_file_undo()
            self._test_debug_log()
        except:

            Project.set_project('unittest')
            self.test_env.delete()
Example #49
0
    def import_default_side_bar(my):
        project_code = my.kwargs.get('project_code')
        # It looks like project=XXX on SearchType.create does not work
        Project.set_project(project_code)
        config = SearchType.create("config/widget_config?project=%s" %
                                   project_code)
        config.set_value("code", "WIDGET_CONFIG000000")
        config.set_value("category", "SideBarWdg")
        config.set_value("search_type", "SideBarWdg")
        config.set_value("view", "project_view")

        xml = '''<?xml version='1.0' encoding='UTF-8'?>
<config>
  <project_view>
    <element name='_home' title='Examples'/>
  </project_view>
</config>
'''
        config.set_value("config", xml)

        config.commit()