Skip to content
Snippets Groups Projects
prep_env 1.49 KiB
Newer Older
import argparse
import random, string

def create_testdir():
	current_directory = os.getcwd()
	final_directory = os.path.join(current_directory, r'test_dir')
	if not os.path.exists(final_directory):
		os.makedirs(final_directory)
	return final_directory
def create_testfiles_seq(dir):
	for x in range(1, 6):
		filename = 'test' + str(x)
		with open(os.path.join(dir, filename), 'w'):
			pass
def create_testfiles_rand(dir):
        for x in range(1, 6):
                filename = ''.join(random.sample((string.ascii_uppercase+string.digits),6))
                with open(os.path.join(dir, filename), 'w'):
                        pass

def create_testfiles_diff(dir):
        for x in range(1, 6):
		dir1 = ''.join(random.sample((string.ascii_uppercase+string.digits),6))
                finaldir = os.path.join(dir, dir1)
		if not os.path.exists(finaldir):
                	os.makedirs(finaldir)
		filename = 'test'
                with open(os.path.join(finaldir, filename), 'w'):
	parser = argparse.ArgumentParser(description='Create a test environment to run parallelism.')
	parser.add_argument('type', choices=['seq', 'rand', 'diff'],  help='Type of test directory to create')
	args = parser.parse_args()
	testdir = create_testdir()
	if args.type == 'seq':
		create_testfiles_seq(testdir)
	if args.type == 'rand':
                create_testfiles_rand(testdir)
	if args.type == 'diff':
                create_testfiles_diff(testdir)