Example #1
0
            sys.exit(0)

        sys.stdout.write("%s/*.pdf  -->  %s/*.swf\n\n" % (dirin, dirout))

        try:
            fdone = open(os.path.join(dirout, "done.txt"), 'a+')
            ferr = open(os.path.join(dirout, "error.txt"), 'a')
        except IOError as e:
            sys.stderr.write("parser done file error: %s\n" % e)
        else:
            completed = set()
            fdone.seek(0)
            for line in fdone:
                completed.add(line.rstrip())

            pdfs = scandir(dirin)

            for pdf in pdfs:

                if pdf.name in completed:
                    sys.stdout.write("skipping: %s\n" % pdf.name)
                    continue

                sys.stdout.write("%s\n" % pdf.name)

                try:
                    parsed = FrankenParser(pdf.path)
                except Exception as e:
                    try:
                        ferr.write("%s:%s\n" % (pdf.name, str(e)))
                    except Exception:
Example #2
0
            sys.exit(0)

        sys.stdout.write("%s/*.pdf  -->  %s/*.swf\n\n" % (dirin, dirout))

        try:
            fdone = open(os.path.join(dirout, "done.txt"), 'a+')
            ferr = open(os.path.join(dirout, "error.txt"), 'a')
        except IOError as e:
            sys.stderr.write("parser done file error: %s\n" % e)
        else:
            completed = set()
            fdone.seek(0)
            for line in fdone:
                completed.add(line.rstrip())

            pdfs = scandir(dirin)

            for pdf in pdfs:

                if pdf.name in completed:
                    sys.stdout.write("skipping: %s\n" % pdf.name)
                    continue

                sys.stdout.write("%s\n" % pdf.name)

                try:
                    parsed = FrankenParser(pdf.path)
                except Exception as e:
                    try:
                        ferr.write("%s:%s\n" % (pdf.name, str(e)))
                    except Exception:
Example #3
0
    with LOCK:
        sys.stdout.write(msg)
        sys.stdout.flush()


if __name__ == '__main__':
    pdfs = []
    args = ParserFactory().new_parser().parse()
    num_procs = multiprocessing.cpu_count() / 2 - 3
    num_procs = num_procs if num_procs > 0 else 1
    print('Running on %d processes' % num_procs)

    if os.path.isdir(args.pdf_in):
        dir_name = os.path.join(args.pdf_in, '*')
        print('Examining directory %s' % dir_name)
        pdfs = scandir(args.pdf_in)
    elif os.path.exists(args.pdf_in):
        print('Analyzing file: %s' % args.pdf_in)
        fin = ''
        try:
            fin = open(args.pdf_in, 'r')
        except IOError as e:
            print("%s" % e)
            sys.exit(0)
        else:
            pdfs = [line.rstrip() for line in fin.readlines()]
            fin.close()
        print('Found %d jobs in file' % len(pdfs))
    else:
        print('Unable to find PDF file/directory: %s' % args.pdf_in)
        sys.exit(1)
Example #4
0
    with LOCK:
        sys.stdout.write(msg)
        sys.stdout.flush()


if __name__ == '__main__':
    pdfs = []
    args = ParserFactory().new_parser().parse()
    num_procs = multiprocessing.cpu_count() / 2 - 3
    num_procs = num_procs if num_procs > 0 else 1
    print('Running on %d processes' % num_procs)

    if os.path.isdir(args.pdf_in):
        dir_name = os.path.join(args.pdf_in, '*')
        print('Examining directory %s' % dir_name)
        pdfs = scandir(args.pdf_in)
    elif os.path.exists(args.pdf_in):
        print('Analyzing file: %s' % args.pdf_in)
        fin = ''
        try:
            fin = open(args.pdf_in, 'r')
        except IOError as e:
            print("%s" % e)
            sys.exit(0)
        else:
            pdfs = [line.rstrip() for line in fin.readlines()]
            fin.close()
        print('Found %d jobs in file' % len(pdfs))
    else:
        print('Unable to find PDF file/directory: %s' % args.pdf_in)
        sys.exit(1)