<commit_before>import os
import ssh
import argparse

# Parse known parameters
parser = argparse.ArgumentParser(description='Run recipe')
parser.add_argument('name',   action='store', help="Virtual Machine's name")
parser.add_argument('recipe', action='store', help="Recipe name")
args,vargs = parser.parse_known_args()

# Recipe
recipe_fp = os.path.join (os.path.dirname(__file__), "recipes", "%s.py"%(args.recipe))

# Execute recipe
ssh.execute_file_over_ssh(args.name, recipe_fp, ' '.join(vargs))<commit_msg>Fixes how recipes are executed<commit_after>import os
import cmd
import ssh
import util
import stat
import network
import argparse

REMOTE_TMP = "/var/tmp/recipes"

# Parse known parameters
parser = argparse.ArgumentParser(description='Run recipe')
parser.add_argument('name',   action='store', help="Virtual Machine's name")
parser.add_argument('recipe', action='store', help="Recipe name")
args,vargs = parser.parse_known_args()

# Recipe
recipe_dir = os.path.join (os.path.dirname(__file__), "recipes")

# Copy recipes
g = util.get_guestfs_vm_handler (args.name)
g.mkdir_p (REMOTE_TMP)

for filename in os.listdir(recipe_dir):
	if filename.endswith(".py"):
		fp_local = os.path.join (recipe_dir, filename)
		fp_vm    = os.path.join (REMOTE_TMP, filename)
		print "+ cp %s %s:%s" % (fp_local, args.name, fp_vm)
		g.upload (fp_local, fp_vm)
		g.chmod (stat.S_IMODE(os.stat(fp_local).st_mode), fp_vm)

g.sync()
g.umount_all()
g.close()

# Execute recipe
cmd.run("qvm start %s"%(args.name))
network.wait_vm_net_service (args.name, 22)
ssh.run (args.name, os.path.join(REMOTE_TMP, '%s.py'%(args.recipe)), ' '.join(vargs))
{'fraction_non_alphanumeric': 0.15224063842848373, 'fraction_numerical': 0.0012277470841006752, 'mean_word_length': 6.149122807017544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1828152', 'n_tokens_mistral': 612, 'n_tokens_neox': 590, 'n_words': 125}