Example #1
0
def update_database(iface):
    from datetime import datetime
    iface.info(
        u"Actualizando base de datos de módulos y funcionalidades . . . ")
    KnownObjects.delete().execute()  # -- Borrar todos los objetos
    module_root = {}
    for path in cfg.module.modulefolders:
        if not os.path.exists(path):
            iface.debug(u"Se ignora directorio inexistente %s" % repr(path))
            continue
        modules = find_files(path, "*.mod", True)
        if not modules:
            iface.warn(u"Directorio no contiene módulos %s" % repr(path))
            continue
        iface.info(u"Se encontraron %d modulos en la carpeta %s" %
                   (len(modules), repr(path)))
        for module in modules:
            iface.debug(u"Módulo %s" % module)
            mtime = get_max_mtime(path, module)
            dmtime = datetime.fromtimestamp(mtime)
            obj = KnownObjects()
            obj.objtype = "module"
            obj.abspath = path
            obj.relpath = os.path.dirname(module)
            obj.filename = os.path.basename(module)
            obj.timestamp = int(mtime)
            obj.extradata = ""
            obj.save()

            # print dmtime.strftime("%a %d %B %Y @ %H:%M:%S %z")
        module_root[path] = modules

    feature_root = {}
    for path in cfg.module.featurefolders:
        if not os.path.exists(path):
            iface.debug(u"Se ignora directorio inexistente %s" % repr(path))
            continue
        features = find_files(path, "*.feature.ini", True)
        if not features:
            iface.warn("Directorio no contiene funcionalidades %s" %
                       repr(path))
            continue
        iface.info(u"Se encontraron %d funcionalidades en la carpeta %s" %
                   (len(features), repr(path)))
        for feature in features:
            iface.debug(u"Funcionalidad %s" % feature)
            mtime = get_max_mtime(path, feature)
            dmtime = datetime.fromtimestamp(mtime)
            # print dmtime.strftime("%a %d %B %Y @ %H:%M:%S %z")
            obj = KnownObjects()
            obj.objtype = "feature"
            obj.abspath = path
            obj.relpath = os.path.dirname(feature)
            obj.filename = os.path.basename(feature)
            obj.timestamp = int(mtime)
            obj.extradata = ""
            obj.save()

        feature_root[path] = features
Example #2
0
def update_database(iface):
    from datetime import datetime
    iface.info(u"Actualizando base de datos de módulos y funcionalidades . . . ")
    KnownObjects.delete().execute() # -- Borrar todos los objetos
    module_root = {}
    for path in cfg.module.modulefolders:
        if not os.path.exists(path):
            iface.debug(u"Se ignora directorio inexistente %s" % repr(path))
            continue
        modules = find_files(path,"*.mod", True)
        if not modules:
            iface.warn(u"Directorio no contiene módulos %s" % repr(path))
            continue
        iface.info(u"Se encontraron %d modulos en la carpeta %s" % (len(modules), repr(path)))
        for module in modules:
            iface.debug(u"Módulo %s" % module)
            mtime = get_max_mtime(path,module)
            dmtime = datetime.fromtimestamp(mtime)
            obj = KnownObjects()
            obj.objtype = "module"
            obj.abspath = path
            obj.relpath = os.path.dirname(module)
            obj.filename = os.path.basename(module)
            obj.timestamp = int(mtime)
            obj.extradata = ""
            obj.save()
            
            # print dmtime.strftime("%a %d %B %Y @ %H:%M:%S %z")
        module_root[path] = modules

    feature_root = {}
    for path in cfg.module.featurefolders:
        if not os.path.exists(path):
            iface.debug(u"Se ignora directorio inexistente %s" % repr(path))
            continue
        features = find_files(path,"*.feature.ini", True)
        if not features:
            iface.warn("Directorio no contiene funcionalidades %s" % repr(path))
            continue
        iface.info(u"Se encontraron %d funcionalidades en la carpeta %s" % (len(features), repr(path)))
        for feature in features:
            iface.debug(u"Funcionalidad %s" % feature)
            mtime = get_max_mtime(path,feature)
            dmtime = datetime.fromtimestamp(mtime)
            # print dmtime.strftime("%a %d %B %Y @ %H:%M:%S %z")
            obj = KnownObjects()
            obj.objtype = "feature"
            obj.abspath = path
            obj.relpath = os.path.dirname(feature)
            obj.filename = os.path.basename(feature)
            obj.timestamp = int(mtime)
            obj.extradata = ""
            obj.save()
        
        feature_root[path] = features
Example #3
0
    def get_info(self):
        if self.info: return self.info
        self.info = {
            "provides": [
                os.path.normpath(os.path.join(self.obj.relpath, x))
                for x in find_files(self.fullpath)
            ],
            "requires": []
        }

        return self.info
Example #4
0
 def get_info(self):
     if self.info: return self.info
     self.info = {"provides" : [ os.path.normpath(os.path.join(self.obj.relpath, x)) for x in find_files(self.fullpath)], "requires" : []}
     
     return self.info
Example #5
0
def createpkg(iface, modulefolder):
    if modulefolder.endswith("/"): modulefolder=modulefolder[:-1]
    if modulefolder.endswith("\\"): modulefolder=modulefolder[:-1]
    iface.info2("Creando paquete de módulos de %s . . ." % modulefolder)
    outputfile = modulefolder + ".eneboopkg"
    
    f1 = open(outputfile, "w")
    # VERSION
    write_string(f1,__package_header__)
    
    # RESERVADO 1
    write_string(f1,"")

    # RESERVADO 2
    write_string(f1,"")
    
    # RESERVADO 3
    write_string(f1,"")

    # MODULES
    modules = find_files(modulefolder, "*.mod", True)
    file_folders = []
    modnames = []
    modlines = []
    for module in sorted(modules):
        file_folders.append(os.path.dirname(module))
        modnames.append(os.path.basename(module))
        # comentado para evitar posibles fallos:
        #modlines.append("<!-- Module %s -->\n" % module)
        inittag = False
        for line_iso in open(os.path.join(modulefolder, module)):
            line_unicode = unicode(line_iso, "ISO-8859-15", "replace")
            line = line_unicode.encode("UTF-8")
            if line.find("<MODULE>") != -1: inittag = True
            if inittag: modlines.append(line)
            if line.find("</MODULE>") != -1: inittag = False
    
    write_compressed(f1, """<!DOCTYPE modules_def>
<modules>
%s
</modules>""" % (''.join(modlines)))
    # FILES XML
    file_list = []
    filelines = []
    shasum = ""
    ignored_ext = set([])
    load_ext = set(['.qs', '.mtd', '.ts', '.ar', '.kut', '.qry', '.ui', '.xml', '.xpm'])
    for folder, module in zip(file_folders,modnames):
        fpath = os.path.join(modulefolder,folder)
        files = find_files(fpath)
        modulename = re.search("^\w+",module).group(0)
        print fpath, modulename
        for filename in files:
            bname, ext = os.path.splitext( filename )
            if ext not in load_ext: 
                ignored_ext.add(ext)
                continue
            
            file_basename = os.path.basename(filename)
            filepath = os.path.join(fpath,filename)
            sha1text = hashlib.sha1(open(filepath).read()).hexdigest()
            sha1text = sha1text.upper()
            shasum+= sha1text
            file_list.append(filepath)
            filelines.append("""  <file>
    <module>%s</module>
    <name>%s</name>
    <text>%s</text>
    <shatext>%s</shatext>
  </file>
""" % (modulename, file_basename, file_basename, sha1text))

    write_compressed(f1, """<!DOCTYPE files_def>
<files>
%s  <shasum>%s</shasum>
</files>
""" % (''.join(filelines), hashlib.sha1(shasum).hexdigest().upper()))
    
    # FILE CONTENTS
    for filepath in file_list:
        sys.stdout.write(".")
        sys.stdout.flush()
        write_compressed(f1, open(filepath).read())
    print
    # CLOSE
    f1.close()
    print "Paquete creado. Extensiones ignoradas:", ignored_ext    
Example #6
0
def createpkg(iface, modulefolder):
    if modulefolder.endswith("/"): modulefolder = modulefolder[:-1]
    if modulefolder.endswith("\\"): modulefolder = modulefolder[:-1]
    iface.info2("Creando paquete de módulos de %s . . ." % modulefolder)
    outputfile = modulefolder + ".eneboopkg"

    f1 = open(outputfile, "w")
    # VERSION
    write_string(f1, __package_header__)

    # RESERVADO 1
    write_string(f1, "")

    # RESERVADO 2
    write_string(f1, "")

    # RESERVADO 3
    write_string(f1, "")

    # MODULES
    modules = find_files(modulefolder, "*.mod", True)
    file_folders = []
    modnames = []
    modlines = []
    for module in sorted(modules):
        file_folders.append(os.path.dirname(module))
        modnames.append(os.path.basename(module))
        # comentado para evitar posibles fallos:
        #modlines.append("<!-- Module %s -->\n" % module)
        inittag = False
        for line_iso in open(os.path.join(modulefolder, module)):
            line_unicode = unicode(line_iso, "ISO-8859-15", "replace")
            line = line_unicode.encode("UTF-8")
            if line.find("<MODULE>") != -1: inittag = True
            if inittag: modlines.append(line)
            if line.find("</MODULE>") != -1: inittag = False

    write_compressed(
        f1, """<!DOCTYPE modules_def>
<modules>
%s
</modules>""" % (''.join(modlines)))
    # FILES XML
    file_list = []
    filelines = []
    shasum = ""
    ignored_ext = set([])
    load_ext = set(
        ['.qs', '.mtd', '.ts', '.ar', '.kut', '.qry', '.ui', '.xml', '.xpm'])
    for folder, module in zip(file_folders, modnames):
        fpath = os.path.join(modulefolder, folder)
        files = find_files(fpath)
        modulename = re.search("^\w+", module).group(0)
        print fpath, modulename
        for filename in files:
            bname, ext = os.path.splitext(filename)
            if ext not in load_ext:
                ignored_ext.add(ext)
                continue

            file_basename = os.path.basename(filename)
            filepath = os.path.join(fpath, filename)
            sha1text = hashlib.sha1(open(filepath).read()).hexdigest()
            sha1text = sha1text.upper()
            shasum += sha1text
            file_list.append(filepath)
            filelines.append("""  <file>
    <module>%s</module>
    <name>%s</name>
    <text>%s</text>
    <shatext>%s</shatext>
  </file>
""" % (modulename, file_basename, file_basename, sha1text))

    write_compressed(
        f1, """<!DOCTYPE files_def>
<files>
%s  <shasum>%s</shasum>
</files>
""" % (''.join(filelines), hashlib.sha1(shasum).hexdigest().upper()))

    # FILE CONTENTS
    for filepath in file_list:
        sys.stdout.write(".")
        sys.stdout.flush()
        write_compressed(f1, open(filepath).read())
    print
    # CLOSE
    f1.close()
    print "Paquete creado. Extensiones ignoradas:", ignored_ext