How to use the ipwb.replay.start function in ipwb

To help you get started, we’ve selected a few ipwb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oduwsdl / ipwb / tests / testUtil.py View on Github external
def startReplay(warcFilename):
    global p
    pathOfWARC = os.path.join(os.path.dirname(__file__) +
                              '/../samples/warcs/' + warcFilename)
    tempFilePath = tempfile.gettempdir() + '/' + ''.join(random.sample(
        string.ascii_uppercase + string.digits * 6, 12)) + '.cdxj'

    open(tempFilePath, 'a').close()  # Create placeholder file for replay

    p = Process(target=replay.start, args=[tempFilePath])
    p.start()
    sleep(5)

    cdxjList = indexer.indexFileAt(pathOfWARC, quiet=True)
    cdxj = '\n'.join(cdxjList)

    with open(tempFilePath, 'w') as f:
        f.write(cdxj)
github oduwsdl / ipwb / ipwb / __main__.py View on Github external
# Write data to temp file (sub-optimal)
        tempFilePath = tempfile.gettempdir() + '/' + ''.join(random.sample(
              string.ascii_uppercase + string.digits * 6, 12)) + '.cdxj'
        with open(tempFilePath, 'w') as f:
            f.write(cdxjIn)
        args.index = tempFilePath
        suppliedIndexParameter = True

    proxy = None
    if hasattr(args, 'proxy') and args.proxy is not None:
        print('Proxying to ' + args.proxy)
        proxy = args.proxy

    # TODO: add any other sub-arguments for replay here
    if suppliedIndexParameter:
        replay.start(cdxjFilePath=args.index, proxy=proxy)
    else:
        print('ERROR: An index file must be specified if not piping, e.g.,')
        print('> ipwb replay /path/to/your/index.cdxj\n')

        args.onError()
        sys.exit()