コード例 #1
0
    def execute(my):
        filename = my.kwargs.get("filename")
        ticket = my.kwargs.get("ticket")
        upload_dir = Environment.get_upload_dir(ticket=ticket)
        # can't rely on that
        #ticket = Environment.get_ticket()
        asset_temp_dir = "%s/temp/%s" % (Environment.get_asset_dir(), ticket)

        if not os.path.exists(asset_temp_dir):
            os.makedirs(asset_temp_dir)

        from_path = "%s/%s" % (upload_dir, filename)
        icon_creator = IconCreator(from_path)
        icon_creator.execute()
        icon_path = icon_creator.get_icon_path()

        to_path = "%s/%s" % (asset_temp_dir, filename)

        if icon_path:
            shutil.copy(icon_path, to_path)
            my.info = {
                "web_path": "/assets/temp/%s/%s" % (ticket, filename),
                "lib_path": to_path
            }
        else:
            my.info = {}
コード例 #2
0
    def checkin_files(my):
        basedir = my.get_upload_dir(my.ticket)
        file_types = []
        for filename in my.filenames:

            file_path = "%s/%s" % (basedir, filename)
            my.file_paths.append(file_path)
            # for now, use the extension as the type
            basename, ext = os.path.splitext(filename)

            file_types.append(ext)

            # should create an icon here
            if ext == ".png":
                creator = IconCreator(file_path)
                creator.create_icons()

                icon_path = creator.get_icon_path()
                my.file_paths.append(icon_path)
                file_types.append("icon")

                # remove the web file
                try:
                    os.unlink(creator.get_web_path())
                except OSError, e:
                    print e
コード例 #3
0
    def execute(my):
        filename = my.kwargs.get("filename")
        ticket = my.kwargs.get("ticket")
        upload_dir = Environment.get_upload_dir(ticket=ticket)
        # can't rely on that
        #ticket = Environment.get_ticket()
        asset_temp_dir = "%s/temp/%s" % (Environment.get_asset_dir(), ticket)

        if not os.path.exists(asset_temp_dir):
            os.makedirs(asset_temp_dir)

        from_path = "%s/%s" % (upload_dir, filename)
        icon_creator = IconCreator(from_path)
        icon_creator.execute()
        icon_path = icon_creator.get_icon_path()

        to_path = "%s/%s" % (asset_temp_dir, filename)
        
        if icon_path:
            shutil.copy(icon_path, to_path)
            my.info = {
                "web_path": "/assets/temp/%s/%s" % (ticket, filename),
                "lib_path": to_path
            }
        else:
            my.info = {}
コード例 #4
0
ファイル: flash_publish_cmd.py プロジェクト: 0-T-0/TACTIC
    def checkin_files(my):
        basedir = my.get_upload_dir(my.ticket)
        file_types = []
        for filename in my.filenames:

            file_path = "%s/%s" % (basedir, filename)
            my.file_paths.append(file_path)
            # for now, use the extension as the type
            basename, ext = os.path.splitext(filename)
            
            file_types.append(ext)

            # should create an icon here
            if ext == ".png":
                creator = IconCreator(file_path)
                creator.create_icons()

                icon_path = creator.get_icon_path()
                my.file_paths.append(icon_path)
                file_types.append("icon")
                
                # remove the web file
                try:
                    os.unlink(creator.get_web_path())
                except OSError, e:    
                    print e
コード例 #5
0
ファイル: flash_render_cmd.py プロジェクト: rajubuddha/TACTIC
    def _check_in_swf(my, snapshot, sobject, render, pat, final_pat,
                      render_dir, filenames):
        final_path = icon_path = ''
        for name in filenames:
            if pat.match(name):
                final_name = pat.sub(final_pat, name)
                shutil.move(render_dir + "/" + name, render_dir \
                    + "/" + final_name)
                src_path = "%s/%s" % (render_dir, final_name)
                if final_name.endswith('.png'):
                    icon_creator = IconCreator(src_path)
                    icon_creator.create_icons()
                    icon_path = icon_creator.get_icon_path()
                elif final_name.endswith('.swf'):
                    final_path = src_path
        types = ["main"]
        paths = [final_path]

        if icon_path:
            paths.append(icon_path)
            types.append('icon')
        checkin = FileCheckin(render,
                              paths,
                              types,
                              context="render",
                              column="images")
        checkin.execute()
コード例 #6
0
ファイル: flash_render_cmd.py プロジェクト: rajubuddha/TACTIC
    def _check_in_png(my, snapshot, sobject, render, pat, final_pat,
                      render_dir, filenames):
        icon_path = final_path = ''
        icon_creator = None

        file_range = my.render_context.get_frame_range()

        for name in filenames:
            if pat.match(name):
                final_name = pat.sub(final_pat, name)
                shutil.move(render_dir + "/" + name,
                            render_dir + "/" + final_name)
                final_path = "%s/%s" % (render_dir, final_name)
                icon_creator = IconCreator(final_path)
                icon_creator.create_icons()
        if icon_creator:
            icon_path = icon_creator.get_icon_path()
        gen_icon_path = re.sub("(.*_icon\.)(\d{4})(\.png)", r"\1####\3",
                               icon_path)
        gen_final_path = re.sub("(.*\.)(\d{4})(\.png)", r"\1####\3",
                                final_path)
        types = ["main", "icon"]
        paths = [gen_final_path, gen_icon_path]

        # check that all the files exist
        try:
            for path in paths:
                FileGroup.check_paths(path, file_range)
        except FileException, e:
            print( "The frame range of layer [%s] probably\
                does not match the shot's frame range [%s]. %s" \
                %(sobject.get_value('name'), file_range.get_key(), e))

            # FIXME: this is a little redundant, but it works
            count = 0
            file_paths = FileGroup.expand_paths(paths[0], file_range)
            for file_path in file_paths:
                if not os.path.exists(file_path):
                    break
                count += 1
            file_range.frame_end = count
コード例 #7
0
ファイル: flash_render_cmd.py プロジェクト: 0-T-0/TACTIC
 def _check_in_swf(my, snapshot, sobject, render, pat, final_pat, render_dir, filenames):
     final_path = icon_path = ''
     for name in filenames:
         if pat.match(name):
             final_name = pat.sub(final_pat, name)
             shutil.move(render_dir + "/" + name, render_dir \
                 + "/" + final_name)
             src_path = "%s/%s" % (render_dir, final_name) 
             if final_name.endswith('.png'):
                 icon_creator = IconCreator(src_path)
                 icon_creator.create_icons()
                 icon_path = icon_creator.get_icon_path()
             elif final_name.endswith('.swf'):
                 final_path = src_path
     types = ["main"]
     paths = [final_path]
     
     if icon_path:
         paths.append(icon_path)
         types.append('icon')
     checkin = FileCheckin(render, paths, types, context="render", column="images")
     checkin.execute()
コード例 #8
0
ファイル: flash_render_cmd.py プロジェクト: 0-T-0/TACTIC
    def _check_in_png(my, snapshot, sobject, render, pat, final_pat, render_dir, filenames):
        icon_path = final_path = ''
        icon_creator = None

        file_range = my.render_context.get_frame_range()
        
        for name in filenames:
            if pat.match(name):
                final_name = pat.sub(final_pat, name)
                shutil.move(render_dir + "/" + name, render_dir + "/" + final_name)
                final_path = "%s/%s" % (render_dir, final_name)
                icon_creator = IconCreator(final_path)
                icon_creator.create_icons()
        if icon_creator:
            icon_path = icon_creator.get_icon_path()
        gen_icon_path = re.sub("(.*_icon\.)(\d{4})(\.png)", r"\1####\3", icon_path) 
        gen_final_path = re.sub("(.*\.)(\d{4})(\.png)", r"\1####\3", final_path)  
        types = ["main", "icon"]
        paths = [gen_final_path, gen_icon_path]
        
        # check that all the files exist
        try:
            for path in paths:
                FileGroup.check_paths(path, file_range)    
        except FileException, e:
            print( "The frame range of layer [%s] probably\
                does not match the shot's frame range [%s]. %s" \
                %(sobject.get_value('name'), file_range.get_key(), e))
           
            # FIXME: this is a little redundant, but it works
            count = 0
            file_paths = FileGroup.expand_paths(paths[0], file_range)
            for file_path in file_paths:
                if not os.path.exists(file_path):
                    break
                count += 1
            file_range.frame_end = count
コード例 #9
0
    def execute(my):

        project_code = my.kwargs.get('project_code')
        project_title = my.kwargs.get('project_title')
        project_type = my.kwargs.get('project_type')
        if not project_type:
            project_type = "simple"

        is_template = my.kwargs.get('is_template')
        project_theme = my.kwargs.get('project_theme')

        use_default_side_bar = my.kwargs.get('use_default_side_bar')
        if use_default_side_bar in [False, 'false']:
            use_default_side_bar = False
        else:
            use_default_side_bar = True

        assert project_code
        assert project_type
        if project_type:
            # check to see if it exists
            search = Search("sthpw/project_type")
            search.add_filter("code", project_type)
            project_type_sobj = search.get_sobject()
            if not project_type_sobj:

                # just create a default one in this case if it is named
                # after the project code
                if not is_template and project_type == project_code:
                    project_type = 'default'

                # create a new project type
                search = Search("sthpw/project_type")
                search.add_filter("code", project_type)
                project_type_sobj = search.get_sobject()
                if not project_type_sobj:
                    project_type_sobj = SearchType.create("sthpw/project_type")
                    project_type_sobj.set_value("code", project_type)
                    project_type_sobj.set_value("type", "simple")
                    project_type_sobj.commit()

        # set the current project to Admin
        Project.set_project("admin")

        # create a new project sobject
        project = SearchType.create("sthpw/project")
        project.set_value("code", project_code)
        project.set_value("title", project_title)
        project.set_value("type", project_type)
        # set the update of the database to current (this is obsolete)
        #project.set_value("last_db_update", "now()")
        project.set_value("last_version_update", "2.5.0.v01")

        if is_template in ['true', True, 'True']:
            project.set_value("is_template", True)
        else:
            project.set_value("is_template", False)

        if project_type != "default":
            category = Common.get_display_title(project_type)
            project.set_value("category", category)

        project.commit()

        # if there is an image, check it in
        upload_path = my.kwargs.get("project_image_path")
        if upload_path:
            if not os.path.exists(upload_path):
                raise TacticException(
                    "Cannot find upload image for project [%s]" % upload_path)
            file_type = 'main'

            file_paths = [upload_path]
            file_types = [file_type]

            source_paths = [upload_path]
            from pyasm.biz import IconCreator
            if os.path.isfile(upload_path):
                icon_creator = IconCreator(upload_path)
                icon_creator.execute()

                web_path = icon_creator.get_web_path()
                icon_path = icon_creator.get_icon_path()
                if web_path:
                    file_paths = [upload_path, web_path, icon_path]
                    file_types = [file_type, 'web', 'icon']

            from pyasm.checkin import FileCheckin
            checkin = FileCheckin(project,
                                  context='icon',
                                  file_paths=file_paths,
                                  file_types=file_types)
            checkin.execute()

        # find project's base_type
        base_type = project.get_base_type()

        if not base_type and project_type == 'unittest':
            base_type = 'unittest'
        elif not base_type:
            base_type = 'simple'

        # get the database for this project
        db_resource = project.get_project_db_resource()

        database = db_resource.get_database_impl()
        #database = DatabaseImpl.get()
        database_type = database.get_database_type()
        if database_type == 'Oracle':
            raise TacticException(
                "Creation of project is not supported. Please create manually")

        # creating project database
        print "Creating database '%s' ..." % project_code
        try:
            # create the datbase
            database.create_database(db_resource)
        except Exception, e:
            print str(e)
            print "WARNING: Error creating database [%s]" % project_code
コード例 #10
0
    def execute(my):

        project_code = my.kwargs.get("project_code")
        project_title = my.kwargs.get("project_title")
        project_type = my.kwargs.get("project_type")
        if not project_type:
            project_type = "simple"

        is_template = my.kwargs.get("is_template")
        project_theme = my.kwargs.get("project_theme")

        use_default_side_bar = my.kwargs.get("use_default_side_bar")
        if use_default_side_bar in [False, "false"]:
            use_default_side_bar = False
        else:
            use_default_side_bar = True

        assert project_code
        assert project_type
        if project_type:
            # check to see if it exists
            search = Search("sthpw/project_type")
            search.add_filter("code", project_type)
            project_type_sobj = search.get_sobject()
            if not project_type_sobj:

                # just create a default one in this case if it is named
                # after the project code
                if not is_template and project_type == project_code:
                    project_type = "default"

                # create a new project type
                search = Search("sthpw/project_type")
                search.add_filter("code", project_type)
                project_type_sobj = search.get_sobject()
                if not project_type_sobj:
                    project_type_sobj = SearchType.create("sthpw/project_type")
                    project_type_sobj.set_value("code", project_type)
                    project_type_sobj.set_value("type", "simple")
                    project_type_sobj.commit()

        # set the current project to Admin
        Project.set_project("admin")

        # create a new project sobject
        project = SearchType.create("sthpw/project")
        project.set_value("code", project_code)
        project.set_value("title", project_title)
        project.set_value("type", project_type)
        # set the update of the database to current (this is obsolete)
        # project.set_value("last_db_update", "now()")
        project.set_value("last_version_update", "2.5.0.v01")

        if is_template in ["true", True, "True"]:
            project.set_value("is_template", True)
        else:
            project.set_value("is_template", False)

        if project_type != "default":
            category = Common.get_display_title(project_type)
            project.set_value("category", category)

        project.commit()

        # if there is an image, check it in
        upload_path = my.kwargs.get("project_image_path")
        if upload_path:
            if not os.path.exists(upload_path):
                raise TacticException("Cannot find upload image for project [%s]" % upload_path)
            file_type = "main"

            file_paths = [upload_path]
            file_types = [file_type]

            source_paths = [upload_path]
            from pyasm.biz import IconCreator

            if os.path.isfile(upload_path):
                icon_creator = IconCreator(upload_path)
                icon_creator.execute()

                web_path = icon_creator.get_web_path()
                icon_path = icon_creator.get_icon_path()
                if web_path:
                    file_paths = [upload_path, web_path, icon_path]
                    file_types = [file_type, "web", "icon"]

            from pyasm.checkin import FileCheckin

            checkin = FileCheckin(project, context="icon", file_paths=file_paths, file_types=file_types)
            checkin.execute()

        # find project's base_type
        base_type = project.get_base_type()

        if not base_type and project_type == "unittest":
            base_type = "unittest"
        elif not base_type:
            base_type = "simple"

        # get the database for this project
        db_resource = project.get_project_db_resource()

        database = db_resource.get_database_impl()
        # database = DatabaseImpl.get()
        database_type = database.get_database_type()
        if database_type == "Oracle":
            raise TacticException("Creation of project is not supported. Please create manually")

        # creating project database
        print "Creating database '%s' ..." % project_code
        try:
            # create the datbase
            database.create_database(db_resource)
        except Exception, e:
            print str(e)
            print "WARNING: Error creating database [%s]" % project_code
コード例 #11
0
ファイル: create_project_cmd.py プロジェクト: mincau/TACTIC
    def execute(self):

        project_code = self.kwargs.get('project_code')
        project_title = self.kwargs.get('project_title')
        project_type = self.kwargs.get('project_type')
        project_description = self.kwargs.get("description")
        if not project_type:
            project_type = "simple"

        is_template = self.kwargs.get('is_template')
        project_theme = self.kwargs.get('project_theme')

        use_default_side_bar = self.kwargs.get('use_default_side_bar')
        if use_default_side_bar in [False, 'false']:
            use_default_side_bar = False
        else:
            use_default_side_bar = True


        assert project_code
        assert project_type
        if project_type:
            # check to see if it exists
            search = Search("sthpw/project_type")
            search.add_filter("code", project_type)
            project_type_sobj = search.get_sobject()
            if not project_type_sobj:

                # just create a default one in this case if it is named
                # after the project code
                if not is_template and project_type == project_code:
                    project_type = 'default'
                    
                # create a new project type
                search = Search("sthpw/project_type")
                search.add_filter("code", project_type)
                project_type_sobj = search.get_sobject()
                if not project_type_sobj:
                    project_type_sobj = SearchType.create("sthpw/project_type")
                    project_type_sobj.set_value("code", project_type)
                    project_type_sobj.set_value("type", "simple")

                    project_type_sobj.commit()

        # set the current project to Admin
        Project.set_project("admin")


        # create a new project sobject
        project = SearchType.create("sthpw/project")
        project.set_value("code", project_code)
        project.set_value("title", project_title)
        project.set_value("type", project_type)
        if project_description:
            project.set_value("description", project_description)
        # set the update of the database to current (this is obsolete)
        #project.set_value("last_db_update", "now()")
        project.set_value("last_version_update", "2.5.0.v01")

        if is_template in ['true', True, 'True']:
            project.set_value("is_template", True)
        else:
            project.set_value("is_template", False)


        if project_type != "default":
            category = Common.get_display_title(project_type)
            project.set_value("category", category)


        project.commit()
       
 

        # if there is an image, check it in
        upload_path = self.kwargs.get("project_image_path")
        if upload_path:
            if not os.path.exists(upload_path):
                raise TacticException("Cannot find upload image for project [%s]" % upload_path)
            file_type = 'main'

            file_paths = [upload_path]
            file_types = [file_type]

            source_paths = [upload_path]
            from pyasm.biz import IconCreator
            if os.path.isfile(upload_path):
                icon_creator = IconCreator(upload_path)
                icon_creator.execute()

                web_path = icon_creator.get_web_path()
                icon_path = icon_creator.get_icon_path()
                if web_path:
                    file_paths = [upload_path, web_path, icon_path]
                    file_types = [file_type, 'web', 'icon']

            from pyasm.checkin import FileCheckin
            checkin = FileCheckin(project, context='icon', file_paths=file_paths, file_types=file_types)
            checkin.execute()

        # find project's base_type
        base_type = project.get_base_type()

        if not base_type and project_type =='unittest':
            base_type = 'unittest'
        elif not base_type:
            base_type = 'simple'


        # get the database for this project
        db_resource = project.get_project_db_resource()

        database = db_resource.get_database_impl()
        #database = DatabaseImpl.get()
        database_type = database.get_database_type()
        if database_type == 'Oracle':
            raise TacticException("Creation of project is not supported. Please create manually")




        # creating project database
        print "Creating database '%s' ..." % project_code
        try:
            # create the datbase
            database.create_database(db_resource)
        except Exception as e:
            print str(e)
            print "WARNING: Error creating database [%s]" % project_code





        # import the appropriate schema with config first
        database.import_schema(db_resource, base_type)

        self.create_schema(project_code)

        # before we upgrade, we have to commit the transaction
        # This is because upgrade actually run as separate processes
        # so if not commit has been made, the tables from importing the
        # schema will not have existed yet
        DbContainer.commit_thread_sql()


        self.upgrade()

        # import the appropriate data
        database.import_default_data(db_resource, base_type)


        # import default links
        if use_default_side_bar:
            self.import_default_side_bar()


        # create specified stypes
        self.create_search_types()


        # create theme
        if project_theme:
            self.create_theme(project_theme)



        # set as main project
        is_main_project = self.kwargs.get("is_main_project")
        if is_main_project in [True,'true','on']:
            Config.set_value("install", "default_project", project_code)
            Config.save_config()
            Config.reload_config()

        # initiate the DbContainer
        DbContainer.get('sthpw')


        self.info['result'] = "Finished creating project [%s]."%project_code

        print "Done."
コード例 #12
0
    def execute(self):

        project_code = self.kwargs.get('project_code')
        project_title = self.kwargs.get('project_title')
        project_type = self.kwargs.get('project_type')
        project_description = self.kwargs.get("description")
        if not project_type:
            project_type = "simple"

        is_template = self.kwargs.get('is_template')
        project_theme = self.kwargs.get('project_theme')

        use_default_side_bar = self.kwargs.get('use_default_side_bar')
        if use_default_side_bar in [False, 'false']:
            use_default_side_bar = False
        else:
            use_default_side_bar = True

        assert project_code
        assert project_type
        if project_type:
            # check to see if it exists
            search = Search("sthpw/project_type")
            search.add_filter("code", project_type)
            project_type_sobj = search.get_sobject()
            if not project_type_sobj:

                # just create a default one in this case if it is named
                # after the project code
                if not is_template and project_type == project_code:
                    project_type = 'default'

                # create a new project type
                search = Search("sthpw/project_type")
                search.add_filter("code", project_type)
                project_type_sobj = search.get_sobject()
                if not project_type_sobj:
                    project_type_sobj = SearchType.create("sthpw/project_type")
                    project_type_sobj.set_value("code", project_type)
                    project_type_sobj.set_value("type", "simple")

                    project_type_sobj.commit()

        # set the current project to Admin
        Project.set_project("admin")

        # create a new project sobject
        project = SearchType.create("sthpw/project")
        project.set_value("code", project_code)
        project.set_value("title", project_title)
        project.set_value("type", project_type)
        if project_description:
            project.set_value("description", project_description)
        # set the update of the database to current (this is obsolete)
        #project.set_value("last_db_update", "now()")
        project.set_value("last_version_update", "2.5.0.v01")

        if is_template in ['true', True, 'True']:
            project.set_value("is_template", True)
        else:
            project.set_value("is_template", False)

        if project_type != "default":
            category = Common.get_display_title(project_type)
            project.set_value("category", category)

        project.commit()

        # if there is an image, check it in
        upload_path = self.kwargs.get("project_image_path")
        if upload_path:
            if not os.path.exists(upload_path):
                raise TacticException(
                    "Cannot find upload image for project [%s]" % upload_path)
            file_type = 'main'

            file_paths = [upload_path]
            file_types = [file_type]

            source_paths = [upload_path]
            from pyasm.biz import IconCreator
            if os.path.isfile(upload_path):
                icon_creator = IconCreator(upload_path)
                icon_creator.execute()

                web_path = icon_creator.get_web_path()
                icon_path = icon_creator.get_icon_path()
                if web_path:
                    file_paths = [upload_path, web_path, icon_path]
                    file_types = [file_type, 'web', 'icon']

            from pyasm.checkin import FileCheckin
            checkin = FileCheckin(project,
                                  context='icon',
                                  file_paths=file_paths,
                                  file_types=file_types)
            checkin.execute()

        # find project's base_type
        base_type = project.get_base_type()

        if not base_type and project_type == 'unittest':
            base_type = 'unittest'
        elif not base_type:
            base_type = 'simple'

        # get the database for this project
        db_resource = project.get_project_db_resource()

        database = db_resource.get_database_impl()
        #database = DatabaseImpl.get()
        database_type = database.get_database_type()
        if database_type == 'Oracle':
            raise TacticException(
                "Creation of project is not supported. Please create manually")

        # creating project database
        print "Creating database '%s' ..." % project_code
        try:
            # create the datbase
            database.create_database(db_resource)
        except Exception as e:
            print str(e)
            print "WARNING: Error creating database [%s]" % project_code

        # import the appropriate schema with config first
        database.import_schema(db_resource, base_type)

        self.create_schema(project_code)

        # before we upgrade, we have to commit the transaction
        # This is because upgrade actually run as separate processes
        # so if not commit has been made, the tables from importing the
        # schema will not have existed yet
        DbContainer.commit_thread_sql()

        self.upgrade()

        # import the appropriate data
        database.import_default_data(db_resource, base_type)

        # import default links
        if use_default_side_bar:
            self.import_default_side_bar()

        # create specified stypes
        self.create_search_types()

        # create theme
        if project_theme:
            self.create_theme(project_theme)

        # set as main project
        is_main_project = self.kwargs.get("is_main_project")
        if is_main_project in [True, 'true', 'on']:
            Config.set_value("install", "default_project", project_code)
            Config.save_config()
            Config.reload_config()

        # initiate the DbContainer
        DbContainer.get('sthpw')

        self.info['result'] = "Finished creating project [%s]." % project_code

        print "Done."