Esempio n. 1
0
def main():
    # Setup argument parser
    parser = ArgumentParser()
    parser.add_argument('pdfs', 
                        help='Input PDFs (directory or file with path list)')
    parser.add_argument('--with-unknown', action='store_true', default=False, 
                        help='Display queries for unknown files')
    parser.add_argument('--with-waiting', action='store_true', default=False, 
                        help='Display pending queries')
    
    # Process arguments
    args = parser.parse_args()
    
    pdfs = sorted(utility.get_pdfs(args.pdfs))
    handler = PdfrateQueryHandler()
    for pdf in pdfs:
        report = handler.poll(pdf)
        if not args.with_unknown and report['status'] == 'unknown':
            continue
        if not args.with_waiting and report['status'] == 'waiting':
            continue
        sys.stdout.write('{}: {}'.format(report['filename'], report['status']))
        if report['status'] in ['success', 'nometadata']:
            r = max(report['results'].keys())
            sys.stdout.write(' [{}%]'.format(report['results'][r]
                                             ['contagio_bm']))
        sys.stdout.write('\n')
    return 0
Esempio n. 2
0
def main():
    # Setup argument parser
    parser = ArgumentParser()
    parser.add_argument('pdfs', 
                        help='Input PDFs (directory or file with path list)')
    parser.add_argument('--priority', type=int, default=0, 
                        help='Submission priority')
    
    # Process arguments
    args = parser.parse_args()
    
    pdfs = sorted(utility.get_pdfs(args.pdfs))
    sys.stdout.write("Submitting files to PDFrate:\n\n")
    handler = PdfrateQueryHandler()
    for i, pdf in enumerate(pdfs):
        handler.submit_query(pdf, get_metadata=True, priority=args.priority)
        sys.stderr.write('{d} File {i}/{n}: {f} {d}\n'
                         .format(d='-'*10, i=i+1, n=len(pdfs), f=pdf))
    return 0