Esempio n. 1
0
    def verify_dir(my, base):

        # ignore transactions that a derived from this server
        server_code = Config.get_value("install", "server")
        if base.startswith("%sTRANSACTION" % server_code):
            return False

        if base.find("TRANSACTION") == -1:
            return False

        if not os.path.isdir(base):
            if base.endswith(".zip.enc"):
                return True
            elif base.endswith(".zip"):
                return True
            else:
                return False

        asset_dir = Environment.get_asset_dir()

        transaction_path = "%s/_transaction.xml" % base
        if not os.path.exists(transaction_path):
            return False

        xml = Xml()
        xml.read_file(transaction_path)

        nodes = xml.get_nodes("transaction/file")

        # verify that all the files are present
        for node in nodes:

            code = xml.get_attribute(node, "code")

            file_sobj = Search.get_by_code("sthpw/file", code)

            src = xml.get_attribute(node, "src")
            rel_path = xml.get_attribute(node, "rel_path")

            src_path = "%s/%s" % (base, rel_path)
            if not os.path.exists(src_path):
                print "[%s] has not arrived" % src_path
                return False

            st_size = xml.get_attribute(node, "size")
            if st_size:
                st_size = int(st_size)
            else:
                st_size = -1
            md5 = xml.get_attribute(node, "md5")

            if st_size != -1:
                # check that the size is the same
                if st_size != os.path.getsize(src_path):
                    print "[%s] size does not match" % src_path
                    return False

        # all the tests have passed
        return True
Esempio n. 2
0
    def get_plugin_data(self, reldir):

        manifest_path = "%s/%s/manifest.xml" % (self.base_dir, reldir)
        xml = Xml()
        xml.read_file(manifest_path)
        node = xml.get_node("manifest/data")
        data = xml.get_node_values_of_children(node)

        return data
Esempio n. 3
0
    def get_plugin_data(my, reldir):

        manifest_path = "%s/%s/manifest.xml" % (my.base_dir, reldir)
        xml = Xml()
        xml.read_file(manifest_path)
        node = xml.get_node("manifest/data")
        data = xml.get_node_values_of_children(node)

        return data
Esempio n. 4
0
    def _read_ref_file(my):
        '''read the reference file containing extra node information'''
        dir = my.get_upload_dir()
        xml = Xml()
        key = my.sobject.get_code()

        # make this filename good for the file system
        filename = File.get_filesystem_name(key)
        xml.read_file("%s/%s-ref.xml" % (dir, filename))
        return xml
Esempio n. 5
0
    def _read_ref_file(my):
        '''read the reference file containing extra node information'''
        dir = my.get_upload_dir()
        xml = Xml()
        key = my.sobject.get_code()

        # make this filename good for the file system
        filename = File.get_filesystem_name(key)
        xml.read_file( "%s/%s-ref.xml" % (dir,filename) )
        return xml
Esempio n. 6
0
def import_schema(plugin_code):
    from pyasm.search import Transaction
    transaction = Transaction.get(create=True)

    install_dir = Environment.get_install_dir()
    base_dir = Environment.get_plugin_dir()
    template_dir = "%s/%s" % (base_dir, plugin_code)
    manifest_path = "%s/manifest.xml" % (template_dir)
    print "Reading manifest: ", manifest_path

    xml = Xml()
    xml.read_file(manifest_path)

    # create a new project
    installer = PluginInstaller(base_dir=base_dir, manifest=xml.to_string() )
    installer.execute()
Esempio n. 7
0
def import_schema(plugin_code):
    from pyasm.search import Transaction
    transaction = Transaction.get(create=True)

    install_dir = Environment.get_install_dir()
    base_dir = Environment.get_plugin_dir()
    template_dir = "%s/%s" % (base_dir, plugin_code)
    manifest_path = "%s/manifest.xml" % (template_dir)
    print "Reading manifest: ", manifest_path

    xml = Xml()
    xml.read_file(manifest_path)

    # create a new project
    installer = PluginInstaller(base_dir=base_dir, manifest=xml.to_string())
    installer.execute()
Esempio n. 8
0
    def postprocess(my):
        super(FlashAssetPublishCmd, my).postprocess()

        # parse the introspect file
        code = my.sobject.get_code()

        upload_dir = my.get_upload_dir()
        introspect_path = "%s/%s.xml" % (upload_dir, code)

        xml = Xml()
        xml.read_file(introspect_path)

        flash_layer_names = xml.get_values("introspect/layers/layer/@name")
        if not flash_layer_names:
            return

        # extract the layers from the flash layer_names
        layer_names = []
        for flash_layer_name in flash_layer_names:
            if flash_layer_name.find(":") == -1:
                continue
            layer_name, instance_name = flash_layer_name.split(":")

            # make sure it is unique
            if layer_name not in layer_names:
                layer_names.append(layer_name)

        base_key = my.sobject.get_search_type_obj().get_base_key()

        # TODO: make the flash shot tab run FlashShotPublishCmd instead
        # and move this postprocess there
        # this is not meant for flash/asset, but for flash/shot
        if base_key == 'flash/asset' or not layer_names:
            return

        # get all of the layers in this shot and compare to the session
        existing_layers = my.sobject.get_all_children("prod/layer")
        existing_layer_names = SObject.get_values(existing_layers, "name")
        for layer_name in layer_names:
            if layer_name not in existing_layer_names:
                print "creating ", layer_name
                Layer.create(layer_name, code)
Esempio n. 9
0
    def postprocess(my):
        super(FlashAssetPublishCmd, my).postprocess()

        # parse the introspect file
        code = my.sobject.get_code()
       
        upload_dir = my.get_upload_dir()
        introspect_path = "%s/%s.xml" % (upload_dir, code)

        xml = Xml()
        xml.read_file(introspect_path)

        flash_layer_names = xml.get_values("introspect/layers/layer/@name")
        if not flash_layer_names:
            return

        # extract the layers from the flash layer_names
        layer_names = []
        for flash_layer_name in flash_layer_names:
            if flash_layer_name.find(":") == -1:
                continue
            layer_name, instance_name = flash_layer_name.split(":")

            # make sure it is unique
            if layer_name not in layer_names:
                layer_names.append(layer_name)

        base_key = my.sobject.get_search_type_obj().get_base_key()

        # TODO: make the flash shot tab run FlashShotPublishCmd instead
        # and move this postprocess there
        # this is not meant for flash/asset, but for flash/shot
        if base_key == 'flash/asset' or not layer_names:
            return

        # get all of the layers in this shot and compare to the session
        existing_layers = my.sobject.get_all_children("prod/layer")
        existing_layer_names = SObject.get_values(existing_layers,"name")
        for layer_name in layer_names:
            if layer_name not in existing_layer_names:
                print "creating ", layer_name
                Layer.create(layer_name, code)
Esempio n. 10
0
    def get_plugins_data(self, plugin_type=None):

        plugins_data = {}
        for root, dirnames, basenames in os.walk(self.base_dir):
            # for windows
            root = root.replace("\\", "/")
            reldir = root.replace(self.base_dir + "/", "")
            if "manifest.xml" in basenames:

                manifest_path = "%s/manifest.xml" % root
                xml = Xml()
                xml.read_file(manifest_path)

                node = xml.get_node("manifest/data")
                data = xml.get_node_values_of_children(node)

                if plugin_type and not data.get("type") == plugin_type:
                    continue

                plugins_data[reldir] = data

        return plugins_data
Esempio n. 11
0
    def get_plugins_data(my, plugin_type=None):

        plugins_data = {}
        for root, dirnames, basenames in os.walk(my.base_dir):

            reldir = root.replace(my.base_dir + "/", "")

            if "manifest.xml" in basenames:

                manifest_path = "%s/manifest.xml" % root
                xml = Xml()
                xml.read_file(manifest_path)

                node = xml.get_node("manifest/data")
                data = xml.get_node_values_of_children(node)

                if plugin_type and not data.get("type") == plugin_type:
                    continue

                plugins_data[reldir] = data


        return plugins_data