def _submit(self):
        schedule_file = StringIO(self.input_area.toPlainText())
        try:
            graph = generate_serializability_graph(schedule_file)
        except ParseError as error:
            QtGui.QMessageBox(QtGui.QMessageBox.Warning, 'Parse error',
                              str(error)).exec_()
            return
        finally:
            schedule_file.close()

        is_conflict_serializable = (
            networkx.algorithms.simple_cycles(
                networkx.from_pydot(graph)) == [])
        self.conflict_serializable_label.setText(
            'This schedule is{0} conflict serializable.'.format(
                '' if is_conflict_serializable else ' not'))

        self.output_area.load(QtCore.QByteArray(
            graph.create(prog='dot',  # default
                         format='svg')))
def main(argv):
    # Parse arguments.
    arg_parser = argparse.ArgumentParser(
        description='Generate serializabilty graphs.')
    arg_parser.add_argument(
        'input_file', metavar='INPUT_FILE', help='File containing schedule.',
        type=argparse.FileType('r'))
    arg_parser.add_argument(
        'output_file', metavar='OUTPUT_FILE',
        help='Output image file to contain the graph.')
    args = arg_parser.parse_args()

    graph = generate_serializability_graph(args.input_file)

    # Done with the input file.
    args.input_file.close()

    # Get format based upon extension.
    extension = os.path.splitext(args.output_file)[1][1:]
    graph.write(args.output_file,
                prog='dot',  # default
                format=extension)