I am writing to network share and this is the piece of code which writes
while not created:
fileName = ''.join(random.choice(CANDIDATE_CHARS) for x in range(len))
fullPath = os.path.join(base, fileName)
if not os.path.exists(fullPath):
filesize = random.randint(fileSizeLowerLim, fileSizeUpperLim)
logger.info("Creating file %s, with size %d" %(fullPath, filesize))
with open(fullPath, 'wb') as fout:
if filesize > 0:
fout.write(os.urandom(filesize * 1048576))
sizeLimit -= filesize
allFiles.append(fullPath)
created = True
logger.info("Created file %s, now limit is %d" %(fullPath, sizeLimit))
And I get this error:
fout.write(os.urandom(filesize * 1048576))
IOError: [Errno 22] Invalid argument
job remoteMachine finished ended with rc = 1
remoteMachine finished and it failed
And when I looked at file it was generated but had no data. Is there something I missed in python?
I am running the script on windows 7 using 32 bit python.