Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
# 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()