Ejemplo n.º 1
0
def main():
    """
    Test Cohen-Sadeh algorithm

    Arguments:
        infile - project file
    """
    # Parse arguments and options
    parser = argparse.ArgumentParser()
    parser.add_argument('infile')
    args = parser.parse_args()

    # Open the input file collecting the required information.
    activities, _, _, _ = fileFormats.load_with_some_format(args.infile, [fileFormats.PPCProjectFileFormat(),
                                                                          fileFormats.PSPProjectFileFormat()])
    successors = dict(((act[1], act[2]) for act in activities))

    gg1 = cohen_sadeh(graph.successors2precedents(successors))
    #subgraph = gg1.focus(787, 875) # Error en Large Tavares

    window = graph.Test()
    window.add_image(graph.pert2image(gg1))
    graph.gtk.main()
    print gg1
    print validation.check_validation(successors, gg1)
    return 0
Ejemplo n.º 2
0
def main():
    """
    Test Mouhoub algorithm

    Arguments:
        infile - project file
    """
    # Parse arguments and options
    parser = argparse.ArgumentParser()
    parser.add_argument('infile')
    args = parser.parse_args()

    # Open the input file collecting the required information.
    activities, _, _, _ = fileFormats.load_with_some_format(args.infile, [fileFormats.PPCProjectFileFormat(),
                                                                          fileFormats.PSPProjectFileFormat()])
    successors = dict(((act[1], act[2]) for act in activities))
    
    pert_graph = mouhoub(graph.successors2precedents(successors))
    
    window = graph.Test()
    window.add_image(graph.pert2image(pert_graph))
    graph.gtk.main()
    print pert_graph
    print validation.check_validation(successors, pert_graph)
    return 0   
Ejemplo n.º 3
0
def openProject(filename):
    """
    Open filename as a project and return activities data

    if error or format not recognized returns None
    """
    fileFormat = [
        fileFormats.PPCProjectFileFormat(),
        fileFormats.PSPProjectFileFormat(),
    ]
    activities = None
    extension = filename[filename.rfind('.') + 1:]
    # Tries to load file with formats that match its extension in format order
    try:
        for format in fileFormat:
            if extension in format.filenameExtensions:
                try:
                    activities, _, _, _ = format.load(filename)
                    break
                except fileFormats.InvalidFileFormatException:
                    pass

        return activities

    except IOError:
        return None
Ejemplo n.º 4
0
def load(filename):
    """
    Load ppcproject-compatible files (.ppc files & .sm files)

    filename (name of the file to load)

    return: data (file info)
    """
    #XXX NO USAR ESTA FUNCION (ver la generica en fileFormats)
    formatos = [
        fileFormats.PPCProjectFileFormat(),
        fileFormats.PSPProjectFileFormat()
    ]
    try:
        # Tries to load file with formats that match its extension in format order
        data = None
        extension = filename[filename.rfind('.') + 1:]

        for format in formatos:
            if extension in format.filenameExtensions:
                try:
                    data = format.load(filename)
                    break
                except fileFormats.InvalidFileFormatException:
                    pass

        # If load by extension failed, try to load files in any format independently of their extension
        if not data:
            for format in formatos:
                try:
                    data = format.load(filename)
                    break
                except fileFormats.InvalidFileFormatException:
                    pass

        #Data successfully loaded
        if data:
            return data
        else:
            raise Exception('ERROR: Formato del archivo origen no reconocido')

    except IOError:
        print 'ERROR: leyendo el archivo origen', '\n'
Ejemplo n.º 5
0
def openProject(filename):
    """
    Open a project file given by filename
    """
    try:
        actividad = []
        recurso = []
        asignacion = []
        schedules = []
        fileFormat = [
            fileFormats.PPCProjectFileFormat(),
            fileFormats.PPCProjectOLDFileFormat(),
            fileFormats.PSPProjectFileFormat(),
        ]

        # Tries to load file with formats that match its extension in format order
        data = None
        extension = filename[filename.rfind('.') + 1:]

        for format in fileFormat:
            if extension in format.filenameExtensions:
                try:
                    data = format.load(filename)
                    break
                except fileFormats.InvalidFileFormatException:
                    pass

        if not data:
            print 'Can not understand file'
            sys.exit(1)

        actividad, schedules, recurso, asignacion = data
        return data[0]
    except IOError:
        print 'Error reading file:', filename
        sys.exit(1)