Exemple #1
0
    def add_default_ending(my, parts, auto_version=True, is_sequence=True):

        context = my.snapshot.get_value("context")
        filename = my.file_object.get_full_file_name()

        # make sure that the version in the file name does not yet exist
        version = my.get_version_from_file_name(filename)
        if not auto_version and version:

            # if the file version is not the same as the snapshot version
            # then check to see if the snapshot already exists
            if version != my.snapshot.get_value("version"):
                existing_snap = Snapshot.get_by_version(my.snapshot.get_value("search_type"),\
                    my.snapshot.get_value("search_id"), context, version)
                if existing_snap:
                    raise TacticException('A snapshot with context "%s" and version "%s" already exists.' % (context, version) )


            my.snapshot.set_value("version", version)
            my.snapshot.commit()
        else:
            version = my.snapshot.get_value("version")


        if version == 0:
            version = "CURRENT"
        elif version == -1:
            version = "LATEST"
        else:

            if version == "":
                version = 1


            # pad the version by by the global setting
            padding = Config.get_value("checkin", "version_padding")
            if not padding:
                padding = 3
            else:
                padding = int(padding)
            expr = "v%%0.%sd" % padding
            version = expr % version

        revision = my.snapshot.get_value("revision", no_exception=True)
        if revision:
            revision = "r%0.2d" % revision

        ext = my.get_ext()

        # by default publish is not put into the file name
        if context != "publish":
            parts.append(context.replace("/", "_"))


        # add the server location
        #value = ProdSetting.get_value_by_key("naming/add_server")
        server = Config.get_value("install", "server")
        if server:
            parts.append(server)


        if my.is_tactic_repo():
            parts.append(version)
            if revision:
                parts.append(revision)

        from pyasm.prod.biz import ProdSetting
        value = ProdSetting.get_value_by_key("naming/add_initials")
        if value == "false":
            project = Project.get()
            initials = Project.get().get_initials()
            parts.append(initials)

        filename = "_".join(parts)
        if is_sequence:
            filename = "%s.####.%s" % (filename, ext)
        elif ext: # dir don't need extension
            filename = "%s%s" % (filename, ext)

        return filename
Exemple #2
0
    def add_default_ending(my, parts, auto_version=True, is_sequence=True):

        context = my.snapshot.get_value("context")
        filename = my.file_object.get_full_file_name()

        # make sure that the version in the file name does not yet exist
        version = my.get_version_from_file_name(filename)
        if not auto_version and version:

            # if the file version is not the same as the snapshot version
            # then check to see if the snapshot already exists
            if version != my.snapshot.get_value("version"):
                existing_snap = Snapshot.get_by_version(my.snapshot.get_value("search_type"),\
                    my.snapshot.get_value("search_id"), context, version)
                if existing_snap:
                    raise TacticException(
                        'A snapshot with context "%s" and version "%s" already exists.'
                        % (context, version))

            my.snapshot.set_value("version", version)
            my.snapshot.commit()
        else:
            version = my.snapshot.get_value("version")

        if version == 0:
            version = "CURRENT"
        elif version == -1:
            version = "LATEST"
        else:

            if version == "":
                version = 1

            # pad the version by by the global setting
            padding = Config.get_value("checkin", "version_padding")
            if not padding:
                padding = 3
            else:
                padding = int(padding)
            expr = "v%%0.%sd" % padding
            version = expr % version

        revision = my.snapshot.get_value("revision", no_exception=True)
        if revision:
            revision = "r%0.2d" % revision

        ext = my.get_ext()

        # by default publish is not put into the file name
        if context != "publish":
            parts.append(context.replace("/", "_"))

        # add the server location
        #value = ProdSetting.get_value_by_key("naming/add_server")
        server = Config.get_value("install", "server")
        if server:
            parts.append(server)

        if my.is_tactic_repo():
            parts.append(version)
            if revision:
                parts.append(revision)

        from pyasm.prod.biz import ProdSetting
        value = ProdSetting.get_value_by_key("naming/add_initials")
        if value == "false":
            project = Project.get()
            initials = Project.get().get_initials()
            parts.append(initials)

        filename = "_".join(parts)
        if is_sequence:
            filename = "%s.####.%s" % (filename, ext)
        elif ext:  # dir don't need extension
            filename = "%s%s" % (filename, ext)

        return filename