def check(): # check the school directory. if not (env.path(env._HISTORY_DIR_ + "/" + g_school, env.OPTION_EXIST)): env.display(env.HEADER_ERROR, "the school '" + g_school + "' does not exist or is not a " + "directory", env.OPTION_NONE) sys.exit(42) # check the year directory. if not (env.path(env._HISTORY_DIR_ + "/" + g_school + "/" + g_year, env.OPTION_EXIST)): env.display(env.HEADER_ERROR, "the year '" + g_year + "' does not exist or is not a " + "directory", env.OPTION_NONE) sys.exit(42) # check the stage. if not (g_stage in g_stages): env.display(env.HEADER_ERROR, "the stage '" + g_stage + "' is invalid, should be one of " + "the following: " + str(g_stages), env.OPTION_NONE) sys.exit(42)
def extract(): student = None base = None # display a message. env.display(env.HEADER_OK, "extracting the students' snapshots", env.OPTION_NONE) # extract the history snapshots. for student in g_history: # message. env.display(env.HEADER_OK, " " + student["name"], env.OPTION_NONE) env.mkdir(student["sources"], env.OPTION_NONE) if env.path(student["snapshot"], env.OPTION_EXIST): env.unpack(student["snapshot"], student["sources"], env.OPTION_QUIET) else: env.mkdir(student["sources"] + "/kaneton/", env.OPTION_NONE) # verify that the extracted snapshot has created a 'kaneton/' directory. if not (env.path(student["sources"] + "/kaneton/", env.OPTION_EXIST)): env.display(env.HEADER_ERROR, "the extracted student snapshot '" + student["name"] + "' does not contain a 'kaneton/' directory", env.OPTION_NONE) if len(env.list(student["sources"], env.OPTION_FILE | env.OPTION_DIRECTORY)) != 1: env.display(env.HEADER_ERROR, "the extracted student snapshot '" + student["name"] + "' contains more than just the 'kaneton/' directory", env.OPTION_NONE) # extract the bases. if g_base: env.unpack(g_base["snapshot"], g_base["path"], env.OPTION_QUIET) # verify that the extracted snapshot has created a 'kaneton/' directory. if not (env.path(g_base["path"] + "/kaneton/", env.OPTION_EXIST)): env.display(env.HEADER_ERROR, "the extracted base snapshot '" + g_base["snapshot"] + "' does not contain a 'kaneton/' directory", env.OPTION_NONE) if len(env.list(g_base["path"], env.OPTION_FILE | env.OPTION_DIRECTORY)) != 1: env.display(env.HEADER_ERROR, "the extracted base snapshot '" + g_base["snapshot"] + "' contains more than just the 'kaneton/' directory", env.OPTION_NONE)
def extract(): student = None base = None # display a message. env.display(env.HEADER_OK, "extracting the students' snapshots", env.OPTION_NONE) # extract the history snapshots. for student in g_history: # message. env.display(env.HEADER_OK, " " + student["name"], env.OPTION_NONE) env.mkdir(student["sources"], env.OPTION_NONE) if env.path(student["snapshot"], env.OPTION_EXIST): env.unpack(student["snapshot"], student["sources"], env.OPTION_QUIET) else: env.mkdir(student["sources"] + "/kaneton/", env.OPTION_NONE) # verify that the extracted snapshot has created a 'kaneton/' directory. if not (env.path(student["sources"] + "/kaneton/", env.OPTION_EXIST)): env.display( env.HEADER_ERROR, "the extracted student snapshot '" + student["name"] + "' does not contain a 'kaneton/' directory", env.OPTION_NONE) if len( env.list(student["sources"], env.OPTION_FILE | env.OPTION_DIRECTORY)) != 1: env.display( env.HEADER_ERROR, "the extracted student snapshot '" + student["name"] + "' contains more than just the 'kaneton/' directory", env.OPTION_NONE) # extract the bases. if g_base: env.unpack(g_base["snapshot"], g_base["path"], env.OPTION_QUIET) # verify that the extracted snapshot has created a 'kaneton/' directory. if not (env.path(g_base["path"] + "/kaneton/", env.OPTION_EXIST)): env.display( env.HEADER_ERROR, "the extracted base snapshot '" + g_base["snapshot"] + "' does not contain a 'kaneton/' directory", env.OPTION_NONE) if len(env.list(g_base["path"], env.OPTION_FILE | env.OPTION_DIRECTORY)) != 1: env.display( env.HEADER_ERROR, "the extracted base snapshot '" + g_base["snapshot"] + "' contains more than just the 'kaneton/' directory", env.OPTION_NONE)
def reduce(student, reference): differences = None contents = None differ = None status = None line = None r = None s = None if not ((env.path(reference, env.OPTION_EXIST)) and \ (env.path(reference, env.OPTION_FILE))): return # load the reference and student files. r = env.pull(reference, env.OPTION_NONE).split("\n") s = env.pull(student, env.OPTION_NONE).split("\n") # build an differ object. differ = difflib.Differ() # look for the differences. differences = differ.compare(r, s) # only keep the added lines. status = STATUS_EQUAL contents="" # for each line. for line in differences: if line[len(line) - 1] == "\n": line = line[:len(line) - 1] # we insert a CTC-GATE token so that the CTC tool does not match code # regions including such a token. # this is done because code has been removed. therefore, a match has # no sense here. if (line[0] == STATUS_INSERT) and (line[0] != status): contents += "_____ctc_gate_____\n"; status = line[0] # add the line to the final file since we only keep added stuff. if line[0] == STATUS_INSERT: contents += line[2:] + "\n" # save the contents in the student file. env.push(student, contents, env.OPTION_NONE)
def reduce(student, reference): differences = None contents = None differ = None status = None line = None r = None s = None if not ((env.path(reference, env.OPTION_EXIST)) and \ (env.path(reference, env.OPTION_FILE))): return # load the reference and student files. r = env.pull(reference, env.OPTION_NONE).split("\n") s = env.pull(student, env.OPTION_NONE).split("\n") # build an differ object. differ = difflib.Differ() # look for the differences. differences = differ.compare(r, s) # only keep the added lines. status = STATUS_EQUAL contents = "" # for each line. for line in differences: if line[len(line) - 1] == "\n": line = line[:len(line) - 1] # we insert a CTC-GATE token so that the CTC tool does not match code # regions including such a token. # this is done because code has been removed. therefore, a match has # no sense here. if (line[0] == STATUS_INSERT) and (line[0] != status): contents += "_____ctc_gate_____\n" status = line[0] # add the line to the final file since we only keep added stuff. if line[0] == STATUS_INSERT: contents += line[2:] + "\n" # save the contents in the student file. env.push(student, contents, env.OPTION_NONE)
def region(file, start, end): handle = None line = None counter = None # open the file. if not env.path(file, env.OPTION_EXIST): return None try: handle = open(file, "r") except IOError: return None content = "" counter = 1 for line in handle.readlines(): # only keep the lines lying between start and end. if (counter >= start) and (counter <= end): content += line counter = counter + 1 handle.close() # convert. content = transform(content) # highlight C comments. content = highlight(content, r"(\/\*.*?\*\/)", "comment") # highlight C++ comments. content = highlight(content, r"(\/\/.*?)$", "comment") # hightlight pre-processor directives. content = highlight(content, r"^(#[A-Za-z0-9_]+).*?$", "preprocessor") # highlight strings. content = highlight(content, r"(\"(?:\\\"|.)*?\")", "string") # highlight characters. content = highlight(content, r"(\'.\')", "character") # highlight types. content = highlight(content, r"[^A-Za-z0-9](bool|char|double|float|int|long|" "short|signed|unsigned|void)[^A-Za-z0-9]", "type") # highlight keywords. content = highlight(content, r"[^A-Za-z0-9](break|case|continue|default|do|else|" "for|goto|if|return|switch|while|asm|const|enum|" "struct|extern|inline|sizeof|static|typedef|union|" "volatile)[^A-Za-z0-9]", "keyword") return content
def module_action(export_dir, arg): env.display(env.HEADER_OK, 'action tarball ' + arg['filename'], env.OPTION_NONE) directory = env.cwd(env.OPTION_NONE) env.cd(env.path(export_dir, env.OPTION_DIRECTORY), env.OPTION_NONE) env.remove(env._EXPORT_DIR_ + "/output/" + arg['filename'] + ".tar.bz2", env.OPTION_NONE) env.pack("kaneton", env._EXPORT_DIR_ + "/output/" + arg['filename'] + ".tar.bz2", env.OPTION_NONE) env.cd(directory, env.OPTION_NONE) return 0
def load(directories, pattern, option): content = "" directory = None includes = None include = None handle = None files = None line = None file = None cwd = None for directory in directories: files = env.list(directory, env.OPTION_FILE) for file in files: if not re.match(pattern, file): continue content += env.pull(directory + "/" + file, env.OPTION_NONE) + "\n" if (option & OPTION_COMMENTS): content = comments(content) if (option & OPTION_INCLUDES): includes = re.findall("(" \ "^" \ "include" \ "[ \t]*" \ "(.*)" \ "\n" \ ")", content, re.MULTILINE); for include in includes: content = content.replace(include[0], load([env.path(directory + "/" + include[1], env.OPTION_DIRECTORY)], "^" + env.path(directory + "/" + include[1], env.OPTION_FILE) + "$", OPTION_COMMENTS | OPTION_INCLUDES)) return content
def region(file, start, end): handle = None line = None counter = None # open the file. if not env.path(file, env.OPTION_EXIST): return None try: handle = open(file, "r") except IOError: return None content = "" counter = 1 for line in handle.readlines(): # only keep the lines lying between start and end. if (counter >= start) and (counter <= end): content += line counter = counter + 1 handle.close() # convert. content = transform(content) # highlight C comments. content = highlight(content, r"(\/\*.*?\*\/)", "comment") # highlight C++ comments. content = highlight(content, r"(\/\/.*?)$", "comment") # hightlight pre-processor directives. content = highlight(content, r"^(#[A-Za-z0-9_]+).*?$", "preprocessor") # highlight strings. content = highlight(content, r"(\"(?:\\\"|.)*?\")", "string") # highlight characters. content = highlight(content, r"(\'.\')", "character") # highlight types. content = highlight( content, r"[^A-Za-z0-9](bool|char|double|float|int|long|" "short|signed|unsigned|void)[^A-Za-z0-9]", "type") # highlight keywords. content = highlight( content, r"[^A-Za-z0-9](break|case|continue|default|do|else|" "for|goto|if|return|switch|while|asm|const|enum|" "struct|extern|inline|sizeof|static|typedef|union|" "volatile)[^A-Za-z0-9]", "keyword") return content
def modules_load(): global g_modules env.display(env.HEADER_OK, 'loading action modules', env.OPTION_NONE) if (env.path(sys.argv[0], env.OPTION_DIRECTORY) == ""): moduledir = './modules' else: moduledir = env.path(sys.argv[0], env.OPTION_DIRECTORY) + '/modules' sys.path.append(moduledir) for i in env.list(moduledir, env.OPTION_FILE): if i.endswith('.py'): mod = __import__(i[:-3]) try: init_str = mod.module_init() except AttributeError: sys.stderr.write('error: The module file ' + i + ' is missing the module_init function\n') sys.exit(1) g_modules[init_str[0]] = mod g_modules_parameters[init_str[0]] = init_str env.display(env.HEADER_OK, " loaded module " + init_str[0], env.OPTION_NONE)
def check(): # check the school directory. if not (env.path(env._HISTORY_DIR_ + "/" + g_school, env.OPTION_EXIST)): env.display( env.HEADER_ERROR, "the school '" + g_school + "' does not exist or is not a " + "directory", env.OPTION_NONE) sys.exit(42) # check the year directory. if not (env.path(env._HISTORY_DIR_ + "/" + g_school + "/" + g_year, env.OPTION_EXIST)): env.display( env.HEADER_ERROR, "the year '" + g_year + "' does not exist or is not a " + "directory", env.OPTION_NONE) sys.exit(42) # check the stage. if not (g_stage in g_stages): env.display( env.HEADER_ERROR, "the stage '" + g_stage + "' is invalid, should be one of " + "the following: " + str(g_stages), env.OPTION_NONE) sys.exit(42)
def locate(directories): locations = [] papers = None paper = None for directory in directories: store = {} papers = env.search(directory, "^.*\.tex$", env.OPTION_FILE | env.OPTION_RECURSIVE) for paper in papers: paper = env.path(paper, env.OPTION_DIRECTORY) store[paper.replace("/", "::")] = paper locations += [store] return locations
def Submit(server, capability, arguments): snapshot = None stage = None # warning Warning() # check the arguments if len(arguments) != 1: Usage() sys.exit(42) # retrieve the arguments. stage = arguments[0] # check if there is a 'snapshot.tar.bz2' in the client/ directory. if env.path(env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2", env.OPTION_EXIST): # display a message. env.display(env.HEADER_OK, "loading the snapshot '" + \ env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2'", env.OPTION_NONE) # read the snapshot. snapshot = env.pull(env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2", env.OPTION_NONE) # warn the user. env.display(env.HEADER_NONE, "", env.OPTION_NONE) env.display(env.HEADER_INTERACTIVE, "are you sure you want the local snapshot to be submitted?", env.OPTION_NONE) env.display(env.HEADER_INTERACTIVE, "press CTRL^C to stop the script, ENTER to continue...", env.OPTION_NONE) env.input(env.OPTION_NONE) else: # display a message. env.display(env.HEADER_OK, "generating the kaneton snapshot", env.OPTION_NONE) # export the current kaneton implementation. env.launch(env._EXPORT_SCRIPT_, "test:" + capability["type"], env.OPTION_QUIET) # display a message. env.display(env.HEADER_OK, "loading the kaneton snapshot", env.OPTION_NONE) # read the snapshot. snapshot = env.pull(env._EXPORT_DIR_ + "/output/" + \ "test:" + capability["type"] + ".tar.bz2", env.OPTION_NONE) # display a message. env.display(env.HEADER_OK, "requesting the server", env.OPTION_NONE) # submit the snapshot. ktp.xmlrpc.Call(server.Submit(capability, ktp.miscellaneous.Binary(snapshot), stage)) # display a message. env.display(env.HEADER_OK, "the snapshot has been submitted successfully", env.OPTION_NONE)
def prepare(): global g_history global g_directory global g_output global g_base years = None year = None stages = None stage = None base = None # a message. env.display(env.HEADER_OK, "preparing the verification process", env.OPTION_NONE) # create a temporary directory for holding unpacked snapshots. g_directory = env.temporary(env.OPTION_DIRECTORY) # set the output file path. g_output = env._HISTORY_DIR_ + "/" + g_school + "/" + g_year + "/" + \ g_stage + ".html" # build the CTC tool env.launch(env._CTC_DIR_ + "/Makefile", "", env.OPTION_QUIET) # look for a base snapshot. if env.path(env._HISTORY_DIR_ + "/" + g_school + "/" + g_year + \ "/snapshot.tar.bz2", env.OPTION_EXIST): g_base = { "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + \ g_year + "/snapshot.tar.bz2", "path": g_directory + "/snapshot" } env.mkdir(g_base["path"], env.OPTION_NONE) else: g_base = None # retreive the list of other snapshots to compare. neighbours are the # students in the same year while alumni are old students. years = sorted(env.list(env._HISTORY_DIR_ + "/" + g_school, env.OPTION_DIRECTORY)) for year in years: # skip the younger works. if year > g_year: continue # for the work from the same year, simply compare the same stages. if year == g_year: # retrieve the students in this year. students = sorted(env.list(env._HISTORY_DIR_ + "/" + \ g_school + "/" + year, env.OPTION_DIRECTORY)) # for every student. for student in students: # add the student to the list. g_history += [ \ { "name": year + "/" + student + "/" + g_stage, "year": year, "student": student, "stage": g_stage, "people": transform(env.pull(env._HISTORY_DIR_ + "/" + \ g_school + "/" + year + "/" + \ student + "/people", env.OPTION_NONE)), "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + year + "/" + student + "/sources/" + g_stage + ".tar.bz2", "sources": g_directory + "/" + year + "/" + \ student + "/" + g_stage, "fingerprint": g_directory + "/" + year + "/" + student + "/" + g_stage + ".ctf", "base": base, "database": g_directory + "/" + year + "/" + student + "/tokens", "trace": g_directory + "/" + year + "/" + student + "/trace" } ] # for older work, take the most recent work from every older student. # XXX this feature has been disabled because it generates too much code to process. if (year < g_year) and (0 == 1): # retrieve the students in this year. students = sorted(env.list(env._HISTORY_DIR_ + "/" + g_school + "/" + year, env.OPTION_DIRECTORY)) # for every student. for student in students: # find the works for this student. stages = sorted(env.list(env._HISTORY_DIR_ + "/" + g_school + "/" + year + "/" + student + "/sources/", env.OPTION_FILE)) # ignore students that skipped the project. if len(stages) == 0: continue # find the most recent work. match = re.match("^(.*)\.tar\.bz2$", stages[len(stages) - 1]) if not match: continue # retrieve the stage name. stage = match.group(1) # add the last student's work to the list. g_history += [ \ { "name": year + "/" + student + "/" + stage, "year": year, "student": student, "stage": stage, "people": transform(env.pull(env._HISTORY_DIR_ + "/" + \ g_school + "/" + year + "/" + \ student + "/people", env.OPTION_NONE)), "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + year + "/" + student + "/sources/" + stage + ".tar.bz2", "sources": g_directory + "/" + year + "/" + student + "/" + stage, "fingerprint": g_directory + "/" + year + "/" + student + "/" + stage + ".ctf", "base": base } ]
def Test(server, capability, arguments): snapshot = None suite = None environment = None identifier = None # warning Warning() # check the arguments if len(arguments) != 2: Usage() sys.exit(42) # retrieve the arguments. environment = arguments[0] suite = arguments[1] # check if there is a 'snapshot.tar.bz2' in the client/ directory. if env.path(env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2", env.OPTION_EXIST): # display a message. env.display(env.HEADER_OK, "loading the snapshot '" + \ env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2'", env.OPTION_NONE) # read the snapshot. snapshot = env.pull(env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2", env.OPTION_NONE) # warn the user. env.display(env.HEADER_NONE, "", env.OPTION_NONE) env.display( env.HEADER_INTERACTIVE, "are you sure you want the local snapshot to be submitted?", env.OPTION_NONE) env.display(env.HEADER_INTERACTIVE, "press CTRL^C to stop the script, ENTER to continue...", env.OPTION_NONE) env.input(env.OPTION_NONE) else: # display a message. env.display(env.HEADER_OK, "generating the kaneton snapshot", env.OPTION_NONE) # export the current kaneton implementation. env.launch(env._EXPORT_SCRIPT_, "test:" + capability["type"], env.OPTION_QUIET) # display a message. env.display(env.HEADER_OK, "loading the kaneton snapshot", env.OPTION_NONE) # read the snapshot. snapshot = env.pull(env._EXPORT_DIR_ + "/output/" + \ "test:" + capability["type"] + ".tar.bz2", env.OPTION_NONE) # display a message. env.display(env.HEADER_OK, "requesting the server", env.OPTION_NONE) # trigger a test. identifier = ktp.xmlrpc.Call( server.Test(capability, ktp.miscellaneous.Binary(snapshot), g_platform, g_architecture, environment, suite)) # display the received report. env.display(env.HEADER_OK, "the snapshot has been scheduled for testing under the " \ "identifier: " + identifier, env.OPTION_NONE)
def install(): component = None # warn the user before performing any action. warning() # display some stuff. env.display(env.HEADER_NONE, "", env.OPTION_NONE) env.display(env.HEADER_OK, "installing kaneton binaries on the boot device", env.OPTION_NONE) # generates the grub menu file. menu() # depending on the boot mode and boot device, install the kaneton binaries # and the grub menu file. if env._BOOT_MODE_ == "peripheral": if env.load(g_menu, env._MDEVICE_, "/boot/grub/menu.lst", env.OPTION_DEVICE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: if env.load(component, env._MDEVICE_, "/modules/", env.OPTION_DEVICE) != 0: env.display(env.HEADER_ERROR, "unable to load the component '" + component + "'", env.OPTION_NONE) sys.exit(42) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) elif env._BOOT_MODE_ == "network": if env.load(g_menu, env._MDEVICE_, "/boot/grub/menu.lst", env.OPTION_DEVICE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: env.copy(component, env._TFTP_DIRECTORY_, env.OPTION_NONE) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) elif env._BOOT_MODE_ == "image": if env.load(g_menu, env._IMAGE_, "/boot/grub/menu.lst", env.OPTION_IMAGE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: if env.load(component, env._IMAGE_, "/modules/", env.OPTION_IMAGE) != 0: env.display(env.HEADER_ERROR, "unable to load the component '" + component + "'", env.OPTION_NONE) sys.exit(42) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) else: env.display(env.HEADER_ERROR, "unknown boot mode '" + env._BOOT_MODE_ + "'", env.OPTION_NONE) sys.exit(42)
def boot(): if env.path(env._IMAGE_, env.OPTION_EXIST): env.remove(env._IMAGE_, env.OPTION_NONE)
def install(): component = None # warn the user before performing any action. warning() # display some stuff. env.display(env.HEADER_NONE, "", env.OPTION_NONE) env.display(env.HEADER_OK, "installing kaneton binaries on the boot device", env.OPTION_NONE) # generates the grub menu file. menu() # depending on the boot mode and boot device, install the kaneton binaries # and the grub menu file. if env._BOOT_MODE_ == "peripheral": if env.load(g_menu, env._MDEVICE_, "/boot/grub/menu.lst", env.OPTION_DEVICE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: if env.load(component, env._MDEVICE_, "/modules/", env.OPTION_DEVICE) != 0: env.display( env.HEADER_ERROR, "unable to load the component '" + component + "'", env.OPTION_NONE) sys.exit(42) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) elif env._BOOT_MODE_ == "network": if env.load(g_menu, env._MDEVICE_, "/boot/grub/menu.lst", env.OPTION_DEVICE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: env.copy(component, env._TFTP_DIRECTORY_, env.OPTION_NONE) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) elif env._BOOT_MODE_ == "image": if env.load(g_menu, env._IMAGE_, "/boot/grub/menu.lst", env.OPTION_IMAGE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: if env.load(component, env._IMAGE_, "/modules/", env.OPTION_IMAGE) != 0: env.display( env.HEADER_ERROR, "unable to load the component '" + component + "'", env.OPTION_NONE) sys.exit(42) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) else: env.display(env.HEADER_ERROR, "unknown boot mode '" + env._BOOT_MODE_ + "'", env.OPTION_NONE) sys.exit(42)
def Test(server, capability, arguments): snapshot = None suite = None environment = None identifier = None # warning Warning() # check the arguments if len(arguments) != 2: Usage() sys.exit(42) # retrieve the arguments. environment = arguments[0] suite = arguments[1] # check if there is a 'snapshot.tar.bz2' in the client/ directory. if env.path(env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2", env.OPTION_EXIST): # display a message. env.display(env.HEADER_OK, "loading the snapshot '" + \ env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2'", env.OPTION_NONE) # read the snapshot. snapshot = env.pull(env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2", env.OPTION_NONE) # warn the user. env.display(env.HEADER_NONE, "", env.OPTION_NONE) env.display(env.HEADER_INTERACTIVE, "are you sure you want the local snapshot to be submitted?", env.OPTION_NONE) env.display(env.HEADER_INTERACTIVE, "press CTRL^C to stop the script, ENTER to continue...", env.OPTION_NONE) env.input(env.OPTION_NONE) else: # display a message. env.display(env.HEADER_OK, "generating the kaneton snapshot", env.OPTION_NONE) # export the current kaneton implementation. env.launch(env._EXPORT_SCRIPT_, "test:" + capability["type"], env.OPTION_QUIET) # display a message. env.display(env.HEADER_OK, "loading the kaneton snapshot", env.OPTION_NONE) # read the snapshot. snapshot = env.pull(env._EXPORT_DIR_ + "/output/" + \ "test:" + capability["type"] + ".tar.bz2", env.OPTION_NONE) # display a message. env.display(env.HEADER_OK, "requesting the server", env.OPTION_NONE) # trigger a test. identifier = ktp.xmlrpc.Call(server.Test(capability, ktp.miscellaneous.Binary(snapshot), g_platform, g_architecture, environment, suite)) # display the received report. env.display(env.HEADER_OK, "the snapshot has been scheduled for testing under the " \ "identifier: " + identifier, env.OPTION_NONE)
def Submit(server, capability, arguments): snapshot = None stage = None # warning Warning() # check the arguments if len(arguments) != 1: Usage() sys.exit(42) # retrieve the arguments. stage = arguments[0] # check if there is a 'snapshot.tar.bz2' in the client/ directory. if env.path(env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2", env.OPTION_EXIST): # display a message. env.display(env.HEADER_OK, "loading the snapshot '" + \ env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2'", env.OPTION_NONE) # read the snapshot. snapshot = env.pull(env._TEST_CLIENT_DIR_ + "/snapshot.tar.bz2", env.OPTION_NONE) # warn the user. env.display(env.HEADER_NONE, "", env.OPTION_NONE) env.display( env.HEADER_INTERACTIVE, "are you sure you want the local snapshot to be submitted?", env.OPTION_NONE) env.display(env.HEADER_INTERACTIVE, "press CTRL^C to stop the script, ENTER to continue...", env.OPTION_NONE) env.input(env.OPTION_NONE) else: # display a message. env.display(env.HEADER_OK, "generating the kaneton snapshot", env.OPTION_NONE) # export the current kaneton implementation. env.launch(env._EXPORT_SCRIPT_, "test:" + capability["type"], env.OPTION_QUIET) # display a message. env.display(env.HEADER_OK, "loading the kaneton snapshot", env.OPTION_NONE) # read the snapshot. snapshot = env.pull(env._EXPORT_DIR_ + "/output/" + \ "test:" + capability["type"] + ".tar.bz2", env.OPTION_NONE) # display a message. env.display(env.HEADER_OK, "requesting the server", env.OPTION_NONE) # submit the snapshot. ktp.xmlrpc.Call( server.Submit(capability, ktp.miscellaneous.Binary(snapshot), stage)) # display a message. env.display(env.HEADER_OK, "the snapshot has been submitted successfully", env.OPTION_NONE)
def prepare(): global g_history global g_directory global g_output global g_base years = None year = None stages = None stage = None base = None # a message. env.display(env.HEADER_OK, "preparing the verification process", env.OPTION_NONE) # create a temporary directory for holding unpacked snapshots. g_directory = env.temporary(env.OPTION_DIRECTORY) # set the output file path. g_output = env._HISTORY_DIR_ + "/" + g_school + "/" + g_year + "/" + \ g_stage + ".html" # build the CTC tool env.launch(env._CTC_DIR_ + "/Makefile", "", env.OPTION_QUIET) # look for a base snapshot. if env.path(env._HISTORY_DIR_ + "/" + g_school + "/" + g_year + \ "/snapshot.tar.bz2", env.OPTION_EXIST): g_base = { "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + \ g_year + "/snapshot.tar.bz2", "path": g_directory + "/snapshot" } env.mkdir(g_base["path"], env.OPTION_NONE) else: g_base = None # retreive the list of other snapshots to compare. neighbours are the # students in the same year while alumni are old students. years = sorted( env.list(env._HISTORY_DIR_ + "/" + g_school, env.OPTION_DIRECTORY)) for year in years: # skip the younger works. if year > g_year: continue # for the work from the same year, simply compare the same stages. if year == g_year: # retrieve the students in this year. students = sorted(env.list(env._HISTORY_DIR_ + "/" + \ g_school + "/" + year, env.OPTION_DIRECTORY)) # for every student. for student in students: # add the student to the list. g_history += [ \ { "name": year + "/" + student + "/" + g_stage, "year": year, "student": student, "stage": g_stage, "people": transform(env.pull(env._HISTORY_DIR_ + "/" + \ g_school + "/" + year + "/" + \ student + "/people", env.OPTION_NONE)), "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + year + "/" + student + "/sources/" + g_stage + ".tar.bz2", "sources": g_directory + "/" + year + "/" + \ student + "/" + g_stage, "fingerprint": g_directory + "/" + year + "/" + student + "/" + g_stage + ".ctf", "base": base, "database": g_directory + "/" + year + "/" + student + "/tokens", "trace": g_directory + "/" + year + "/" + student + "/trace" } ] # for older work, take the most recent work from every older student. # XXX this feature has been disabled because it generates too much code to process. if (year < g_year) and (0 == 1): # retrieve the students in this year. students = sorted( env.list(env._HISTORY_DIR_ + "/" + g_school + "/" + year, env.OPTION_DIRECTORY)) # for every student. for student in students: # find the works for this student. stages = sorted( env.list( env._HISTORY_DIR_ + "/" + g_school + "/" + year + "/" + student + "/sources/", env.OPTION_FILE)) # ignore students that skipped the project. if len(stages) == 0: continue # find the most recent work. match = re.match("^(.*)\.tar\.bz2$", stages[len(stages) - 1]) if not match: continue # retrieve the stage name. stage = match.group(1) # add the last student's work to the list. g_history += [ \ { "name": year + "/" + student + "/" + stage, "year": year, "student": student, "stage": stage, "people": transform(env.pull(env._HISTORY_DIR_ + "/" + \ g_school + "/" + year + "/" + \ student + "/people", env.OPTION_NONE)), "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + year + "/" + student + "/sources/" + stage + ".tar.bz2", "sources": g_directory + "/" + year + "/" + student + "/" + stage, "fingerprint": g_directory + "/" + year + "/" + student + "/" + stage + ".ctf", "base": base } ]