Ejemplo n.º 1
0
def module_action(export_dir, arg):
    strip = 0
    env.display(env.HEADER_OK, 'action breplace ' + arg['id'], env.OPTION_NONE)
    id = arg['id'].split('::', 1)
    filepath = id[0]
    label = id[1]
    tmpfilepath = env.temporary(env.OPTION_FILE)
    srcf = open(export_dir + '/' + filepath, 'r')
    dstf = open(tmpfilepath, 'w')
    line = srcf.readline()
    startpattern = re.compile(".*[[]block\:\:" + label + "[]].*")
    endpattern = re.compile(".*[[]/block\:\:" + label + "[]].*")
    while line != "":
        if strip == 0:
            if startpattern.match(line) != None:
                strip = 1
                dstf.write(arg['data'])
        if strip != 1:
            dstf.write(line)
        if strip == 1:
            if endpattern.match(line) != None:
                strip = 2
        line = srcf.readline()
    dstf.close()
    srcf.close()
    env.copy(tmpfilepath, export_dir + '/' + filepath, env.OPTION_NONE)
    env.remove(tmpfilepath, env.OPTION_NONE)
    if strip == 0:
        env.display(env.HEADER_ERROR, 'no block ' + label + ' in file ' + filepath, env.OPTION_NONE)
        return -1
    return 0
Ejemplo n.º 2
0
def main():
    directory = None

    # check the number of arguments.
    if len(sys.argv) != 2:
        usage()
        sys.exit(42)

    # set the global variables.
    directory = sys.argv[1]

    # display.
    env.display(env.HEADER_OK,
                "generating the inventory for '" + directory + "'",
                env.OPTION_NONE)

    # locate the tests.
    functions = locate(directory)

    # generate the inventory.
    generate(functions, directory + "/inventory.c")

    # display.
    env.display(env.HEADER_OK,
                "inventory generated in '" + directory + "/inventory.c" + "'",
                env.OPTION_NONE)
Ejemplo n.º 3
0
def                     contributor():
  configuration = None
  database = None

  # display message.
  env.display(env.HEADER_OK,
              "generating database for the contributor",
              env.OPTION_NONE)

  # load the configuration.
  configuration = ktp.configuration.Load(env._TEST_CONFIGURATION_DIR_ + \
                                           "/contributor" +             \
                                           ktp.configuration.Extension)

  # generate the database.
  database = ktp.database.Generate(configuration)

  # store the database.
  ktp.database.Store(database,
                     env._TEST_STORE_DATABASE_DIR_ + "/" + env._USER_ + \
                       ktp.database.Extension)

  # display message.
  env.display(env.HEADER_OK,
              "the contributor database has been generated for '" +     \
                env._USER_ + "'",
              env.OPTION_NONE)
Ejemplo n.º 4
0
def			prototypes():
  useless = None

  env.display(env.HEADER_OK,
              "generating the kaneton prototypes",
              env.OPTION_NONE)
  env.launch(env._SOURCE_DIR_ + "/Makefile", "prototypes", env.OPTION_QUIET)
Ejemplo n.º 5
0
def                     robot():
  configuration = None
  database = None

  # display message.
  env.display(env.HEADER_OK,
              "generating database for the robot",
              env.OPTION_NONE)

  # load the configuration.
  configuration = ktp.configuration.Load(env._TEST_CONFIGURATION_DIR_ + \
                                           "/robot" +                   \
                                           ktp.configuration.Extension)

  # generate the database.
  database = ktp.database.Generate(configuration)

  # store the database.
  ktp.database.Store(database,
                     env._TEST_STORE_DATABASE_DIR_ + "/robot" +         \
                       ktp.database.Extension)

  # display message.
  env.display(env.HEADER_OK,
              "the robot's database has been generated succesfully",
              env.OPTION_NONE)
Ejemplo n.º 6
0
def contributor():
    configuration = None
    database = None

    # display message.
    env.display(env.HEADER_OK, "generating database for the contributor",
                env.OPTION_NONE)

    # load the configuration.
    configuration = ktp.configuration.Load(env._TEST_CONFIGURATION_DIR_ + \
                                             "/contributor" +             \
                                             ktp.configuration.Extension)

    # generate the database.
    database = ktp.database.Generate(configuration)

    # store the database.
    ktp.database.Store(database,
                       env._TEST_STORE_DATABASE_DIR_ + "/" + env._USER_ + \
                         ktp.database.Extension)

    # display message.
    env.display(env.HEADER_OK,
                "the contributor database has been generated for '" +     \
                  env._USER_ + "'",
                env.OPTION_NONE)
Ejemplo n.º 7
0
def                     main():
  global g_component
  global g_path

  component = None

  # check the number of arguments.
  if len(sys.argv) != 2:
    usage()
    sys.exit(42)

  # retrieve the arguments.
  g_component = sys.argv[1].split("@")[0]

  if len(sys.argv[1].split("@")) > 1:
    g_path = sys.argv[1].split("@")[1].replace("::", "/")

  # trigger the appropriate function.
  for component in c_components:
    if g_component == component.split("@")[0]:
      c_components[component]()
      sys.exit(0)

  # wrong component.
  env.display(env.HEADER_ERROR,
              "unknown component '" + g_component + "'",
              env.OPTION_NONE)

  # display usage.
  usage()
Ejemplo n.º 8
0
def			main():
  # display some stuff.
  env.display(env.HEADER_OK,
              "cleaning the kaneton development environment",
              env.OPTION_NONE)

  # clear the kaneton development tree.
  clear()

  # remove the generated boot stuff.
  boot()

  # uninstall the chosen machine.
  machine()

  # generate the kaneton dependencies.
  dependencies()

  # remove the environment-specific files.
  clean()

  # display some stuff.
  env.display(env.HEADER_OK,
              "environment development cleaned successfully",
              env.OPTION_NONE)
Ejemplo n.º 9
0
def			main():
  global g_transcript
  global g_path
  global g_store
  transcript = None

  # find out the locations of the transcripts.
  g_store = locate(g_directories)

  # check the number of arguments.
  if len(sys.argv) != 2:
    usage()
    sys.exit(42)

  # display a message.
  env.display(env.HEADER_OK,
              "looking for the transcript in the transripts database",
              env.OPTION_NONE)

  # set the transcript name looked for.
  g_transcript = sys.argv[1]
  g_path = g_transcript.replace("::", "/")

  # display the transcript name and ask the user to continue.
  warning()

  # launch the recording.
  launch()

  # a final message.
  env.display(env.HEADER_OK, "session successfully transcripted",
              env.OPTION_NONE)
Ejemplo n.º 10
0
def                     Retest(server, capability, arguments):
  snapshot = None
  identifier = None

  # warning
  Warning()

  # check the arguments
  if len(arguments) != 1:
    Usage()
    sys.exit(42)

  # retrieve the arguments.
  identifier = arguments[0]

  # display a message.
  env.display(env.HEADER_OK,
              "requesting the server",
              env.OPTION_NONE)

  # trigger a test.
  ktp.xmlrpc.Call(server.Retest(capability,
                                identifier))

  # display a message.
  env.display(env.HEADER_OK,
              "the snapshot has been re-tested successfully",
              env.OPTION_NONE)
Ejemplo n.º 11
0
def module_action(export_dir, arg):
    strip = 0
    env.display(env.HEADER_OK, 'action breplace ' + arg['id'], env.OPTION_NONE)
    id = arg['id'].split('::', 1)
    filepath = id[0]
    label = id[1]
    tmpfilepath = env.temporary(env.OPTION_FILE)
    srcf = open(export_dir + '/' + filepath, 'r')
    dstf = open(tmpfilepath, 'w')
    line = srcf.readline()
    startpattern = re.compile(".*[[]block\:\:" + label + "[]].*")
    endpattern = re.compile(".*[[]/block\:\:" + label + "[]].*")
    while line != "":
        if strip == 0:
            if startpattern.match(line) != None:
                strip = 1
                dstf.write(arg['data'])
        if strip != 1:
            dstf.write(line)
        if strip == 1:
            if endpattern.match(line) != None:
                strip = 2
        line = srcf.readline()
    dstf.close()
    srcf.close()
    env.copy(tmpfilepath, export_dir + '/' + filepath, env.OPTION_NONE)
    env.remove(tmpfilepath, env.OPTION_NONE)
    if strip == 0:
        env.display(env.HEADER_ERROR,
                    'no block ' + label + ' in file ' + filepath,
                    env.OPTION_NONE)
        return -1
    return 0
Ejemplo n.º 12
0
def main():
    global g_transcript
    global g_path
    global g_store
    transcript = None

    # find out the locations of the transcripts.
    g_store = locate(g_directories)

    # check the number of arguments.
    if len(sys.argv) != 2:
        usage()
        sys.exit(42)

    # display a message.
    env.display(env.HEADER_OK,
                "looking for the transcript in the transripts database",
                env.OPTION_NONE)

    # set the transcript name looked for.
    g_transcript = sys.argv[1]
    g_path = g_transcript.replace("::", "/")

    # display the transcript name and ask the user to continue.
    warning()

    # launch the recording.
    launch()

    # a final message.
    env.display(env.HEADER_OK, "session successfully transcripted",
                env.OPTION_NONE)
Ejemplo n.º 13
0
def			build():
  # warn the user before performing any action.
  warning()

  # display some stuff.
  env.display(env.HEADER_ERROR, "nothing to build for this architecture",
              env.OPTION_NONE)
Ejemplo n.º 14
0
def			main():
  # display some stuff.
  env.display(env.HEADER_OK,
              "installing the kaneton development environment",
              env.OPTION_NONE)

  # display the current configuration and ask the user to continue.
  warning()

  # install the chosen machine: platform/architecture.
  machine()

  # check the presence of the binaries used by the behaviour profile.
  check()

  # generate the kaneton prototypes.
  prototypes()

  # generate the kaneton headers.
  headers()

  # display some stuff.
  env.display(env.HEADER_OK,
              "environment development installed successfully",
              env.OPTION_NONE)
Ejemplo n.º 15
0
def main():
    global g_component
    global g_path

    component = None

    # check the number of arguments.
    if len(sys.argv) != 2:
        usage()
        sys.exit(42)

    # retrieve the arguments.
    g_component = sys.argv[1].split("@")[0]

    if len(sys.argv[1].split("@")) > 1:
        g_path = sys.argv[1].split("@")[1].replace("::", "/")

    # trigger the appropriate function.
    for component in c_components:
        if g_component == component.split("@")[0]:
            c_components[component]()
            sys.exit(0)

    # wrong component.
    env.display(env.HEADER_ERROR, "unknown component '" + g_component + "'",
                env.OPTION_NONE)

    # display usage.
    Usage()
Ejemplo n.º 16
0
def main():
    # display some stuff.
    env.display(env.HEADER_OK,
                "installing the kaneton development environment",
                env.OPTION_NONE)

    # display the current configuration and ask the user to continue.
    warning()

    # install the chosen machine: platform/architecture.
    machine()

    # check the presence of the binaries used by the behaviour profile.
    check()

    # generate the kaneton prototypes.
    prototypes()

    # generate the kaneton headers.
    headers()

    # display some stuff.
    env.display(env.HEADER_OK,
                "environment development installed successfully",
                env.OPTION_NONE)
Ejemplo n.º 17
0
def robot():
    configuration = None
    database = None

    # display message.
    env.display(env.HEADER_OK, "generating database for the robot",
                env.OPTION_NONE)

    # load the configuration.
    configuration = ktp.configuration.Load(env._TEST_CONFIGURATION_DIR_ + \
                                             "/robot" +                   \
                                             ktp.configuration.Extension)

    # generate the database.
    database = ktp.database.Generate(configuration)

    # store the database.
    ktp.database.Store(database,
                       env._TEST_STORE_DATABASE_DIR_ + "/robot" +         \
                         ktp.database.Extension)

    # display message.
    env.display(env.HEADER_OK,
                "the robot's database has been generated succesfully",
                env.OPTION_NONE)
Ejemplo n.º 18
0
def                     server(ca_key, ca_certificate):
  key = None
  request = None
  certificate = None

  # generate a cryptographic key.
  key = ktp.key.Generate()

  # generate a certificate request.
  request = ktp.certificate.Request(key,
                                    CN = "test.opaak.org",
                                    emailAddress = "*****@*****.**")

  # finally, build a valid, self-certified certificate
  certificate = ktp.certificate.Create(request,
                                       (ca_certificate, ca_key),
                                       0,
                                       (0, 60 * 60 * 24 * 365 * 5))

  # display
  env.display(env.HEADER_OK,
              "server key/certificate generated",
              env.OPTION_NONE)

  return (key, certificate)
Ejemplo n.º 19
0
def module_action(export_dir, arg):
    env.display(env.HEADER_OK, 'action svnexport', env.OPTION_NONE)
    env.launch(
        "svn",
        "export svn+ssh://[email protected]/kaneton " +
        export_dir, env.OPTION_NONE)

    return 0
Ejemplo n.º 20
0
def			machine():
  env.display(env.HEADER_OK,
              "removing links to machine-dependent directories",
              env.OPTION_NONE)

  env.remove(env._GLUE_CURRENT_, env.OPTION_NONE)
  env.remove(env._ARCHITECTURE_CURRENT_, env.OPTION_NONE)
  env.remove(env._PLATFORM_CURRENT_, env.OPTION_NONE)
Ejemplo n.º 21
0
def module_action(export_dir, arg):
    env.display(env.HEADER_OK, 'action fremovepattern ' + arg['pattern'],
                env.OPTION_NONE)
    for d in env.search(
            export_dir, arg['pattern'],
            env.OPTION_RECURSIVE | env.OPTION_DIRECTORY | env.OPTION_FILE):
        env.remove(d, env.OPTION_NONE)
    return 0
Ejemplo n.º 22
0
def usage():
    env.display(env.HEADER_ERROR, "usage: grub.py [action]", env.OPTION_NONE)

    env.display(env.HEADER_NONE, "", env.OPTION_NONE)

    env.display(env.HEADER_ERROR, "actions:", env.OPTION_NONE)
    env.display(env.HEADER_ERROR, "  build", env.OPTION_NONE)
    env.display(env.HEADER_ERROR, "  install", env.OPTION_NONE)
Ejemplo n.º 23
0
def			usage():
  env.display(env.HEADER_ERROR, "usage: grub.py [action]", env.OPTION_NONE)

  env.display(env.HEADER_NONE, "", env.OPTION_NONE)

  env.display(env.HEADER_ERROR, "actions:", env.OPTION_NONE)
  env.display(env.HEADER_ERROR, "  build", env.OPTION_NONE)
  env.display(env.HEADER_ERROR, "  install", env.OPTION_NONE)
Ejemplo n.º 24
0
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
Ejemplo n.º 25
0
def			main():
  global g_school
  global g_year
  global g_stage
  args = None

  # check the number of arguments.
  if len(sys.argv) != 2:
    usage()
    sys.exit(42)

  # retrive the actual arguments.
  args = sys.argv[1].split("::")

  # check the number of arguments.
  if len(args) != 3:
    usage()
    sys.exit(42)

  # set the global variables.
  g_school = args[0]
  g_year = args[1]
  g_stage = args[2]

  # check that the school and year are valid.
  check()

  # warn the user about what is about to happen.
  warning()

  # prepare the process.
  prepare()

  # extract all the student snapshots in a temporary directory so that
  # the CTC tool can access the sources.
  extract()

  # shear the snapshots according to the year's base snapshot.
  shear()

  # generate the token files and the database.
  generate()

  # compare the given snapshots with the other ones, generating cheat
  # traces.
  compare()

  # generate the HTML output.
  output()

  # clear the temporary files and directories.
  clear()

  # final message.
  env.display(env.HEADER_OK,
              "cheating verification processed successfully",
              env.OPTION_NONE)
Ejemplo n.º 26
0
def	reference() :

	env.display(env.HEADER_OK, "generating reference output...",
		    env.OPTION_NONE)
	os.mkdir(OUT_PATH + "/" + REF_PATH)
	check_tarball(OUT_PATH + "/" + REF_PATH, REF_PATH)
	env.display(env.HEADER_NONE, "", env.OPTION_NONE)

	return
Ejemplo n.º 27
0
def main():
    global g_school
    global g_year
    global g_stage
    args = None

    # check the number of arguments.
    if len(sys.argv) != 2:
        usage()
        sys.exit(42)

    # retrive the actual arguments.
    args = sys.argv[1].split("::")

    # check the number of arguments.
    if len(args) != 3:
        usage()
        sys.exit(42)

    # set the global variables.
    g_school = args[0]
    g_year = args[1]
    g_stage = args[2]

    # check that the school and year are valid.
    check()

    # warn the user about what is about to happen.
    warning()

    # prepare the process.
    prepare()

    # extract all the student snapshots in a temporary directory so that
    # the CTC tool can access the sources.
    extract()

    # shear the snapshots according to the year's base snapshot.
    shear()

    # generate the token files and the database.
    generate()

    # compare the given snapshots with the other ones, generating cheat
    # traces.
    compare()

    # generate the HTML output.
    output()

    # clear the temporary files and directories.
    clear()

    # final message.
    env.display(env.HEADER_OK, "cheating verification processed successfully",
                env.OPTION_NONE)
Ejemplo n.º 28
0
def                     robot():
  path = None
  link = None
  name = None

  # display.
  env.display(env.HEADER_OK,
              "generating the robot's capability",
              env.OPTION_NONE)

  # retrieve the server's code.
  code = ktp.code.Load(env._TEST_STORE_CODE_DIR_ + "/server" +          \
                         ktp.code.Extension)

  # compute the name.
  name = "robot"

  # compute the file name.
  path = env._TEST_STORE_CAPABILITY_DIR_ + "/" +                        \
    name + ktp.capability.Extension

  # compute the link.
  link = env._PROFILE_DIR_ + "/user/robot/robot" + ktp.capability.Extension

  # create the capability.
  capability = ktp.capability.Create(code,
                                     name,
                                     ktp.capability.TypeStudent,
                                     {},
                                     [ { "name":
                                           "Robot",
                                         "email":
                                           "*****@*****.**",
                                         "login":
                                           "******"
                                         } ])

  # store it.
  ktp.capability.Store(path,
                       capability)

  # remove the previous link.
  env.remove(link, env.OPTION_NONE)

  # create a link from the profile. XXX[this could probably be improved]
  env.link(link,
           "../../../../test/store/capability/" + name +                
             ktp.capability.Extension,
           env.OPTION_NONE)

  # display.
  env.display(env.HEADER_OK,
              "the robot's capability has been generated succesfully",
              env.OPTION_NONE)
Ejemplo n.º 29
0
def			install():
  input = None

  # warn the user before performing any action.
  warning()

  # display some stuff.
  env.display(env.HEADER_OK,
              "installing kaneton binaries on the boot device",
              env.OPTION_NONE)

  env.copy(env._KANETON_, env._IMAGE_, env.OPTION_NONE)
Ejemplo n.º 30
0
def                     contributor():
  path = None
  link = None
  name = None

  # display.
  env.display(env.HEADER_OK,
              "generating a contributor's capability",
              env.OPTION_NONE)

  # retrieve the server's code.
  code = ktp.code.Load(env._TEST_STORE_CODE_DIR_ + "/server" +          \
                         ktp.code.Extension)

  # compute the name.
  name = env._USER_

  # compute the file name.
  path = env._TEST_STORE_CAPABILITY_DIR_ + "/" +                        \
    name + ktp.capability.Extension

  # compute the link.
  link = env._TEST_CAPABILITY_

  # create the capability.
  capability = ktp.capability.Create(code,
                                     name,
                                     ktp.capability.TypeContributor,
                                     {},
                                     [ { "name": env._TEST_NAME_,
                                         "email": env._TEST_EMAIL_,
                                         "login":
                                           env._TEST_NAME_.lower().
                                             replace(" ", ".") } ])

  # store it.
  ktp.capability.Store(path,
                       capability)

  # remove the previous link.
  env.remove(link, env.OPTION_NONE)

  # create a link from the profile. XXX[this could probably be improved]
  env.link(link,
           "../../../../test/store/capability/" + name +                
             ktp.capability.Extension,
           env.OPTION_NONE)

  # display.
  env.display(env.HEADER_OK,
              "the contributor capability has been generated " +        \
              "succesfully for '" + name + "'",
              env.OPTION_NONE)
Ejemplo n.º 31
0
def                     Main():
  global g_server
  global g_capability
  global g_platform
  global g_architecture

  server = None
  capability = None
  command = None
  arguments = None

  # retrieve the command.
  if len(sys.argv) != 2:
    Usage()
    sys.exit(42)

  # set the command.
  command = sys.argv[1].split("-")[0]

  # set the variables.
  g_server = env._TEST_SERVER_
  g_capability = env._TEST_CAPABILITY_
  g_platform = env._TEST_PLATFORM_
  g_architecture = env._TEST_ARCHITECTURE_

  # connect to the server.
  server = ktp.xmlrpc.Connect(g_server)

  # load the student capability.
  capability = ktp.capability.Load(g_capability)

  # trigger the appropriate command.
  for name in c_commands:
    if command == name.split("-")[0]:
      # set the arguments.
      if len(sys.argv[1].split("-")) > 1:
        arguments = sys.argv[1].split("-")[1].split("::")
      else:
        arguments = []

      c_commands[name](server, capability, arguments)

      sys.exit(0)

  # wrong command.
  env.display(env.HEADER_ERROR,
              "unknown command '" + arguments[0] + "'",
              env.OPTION_NONE)

  # display usage.
  Usage()
Ejemplo n.º 32
0
def			dependencies():
  dependencies = None
  dep = None

  env.display(env.HEADER_OK,
              "removing the kaneton header dependencies",
              env.OPTION_NONE)

  dependencies = env.search(env._SOURCE_DIR_,
                            env._DEPENDENCY_MK_,
                            env.OPTION_FILE | env.OPTION_RECURSIVE)

  for dep in dependencies:
    env.remove(dep, env.OPTION_NONE)
Ejemplo n.º 33
0
def			warning():
  env.display(env.HEADER_NONE, "", env.OPTION_NONE)
  env.display(env.HEADER_OK, "configuration:", env.OPTION_NONE)
  env.display(env.HEADER_OK,
              "  transcript:             " + g_transcript,
              env.OPTION_NONE)
  env.display(env.HEADER_NONE, "", env.OPTION_NONE)
Ejemplo n.º 34
0
def Main():
    global g_server
    global g_capability
    global g_platform
    global g_architecture

    server = None
    capability = None
    command = None
    arguments = None

    # retrieve the command.
    if len(sys.argv) != 2:
        Usage()
        sys.exit(42)

    # set the command.
    command = sys.argv[1].split("-")[0]

    # set the variables.
    g_server = env._TEST_SERVER_
    g_capability = env._TEST_CAPABILITY_
    g_platform = env._TEST_PLATFORM_
    g_architecture = env._TEST_ARCHITECTURE_

    # connect to the server.
    server = ktp.xmlrpc.Connect(g_server)

    # load the student capability.
    capability = ktp.capability.Load(g_capability)

    # trigger the appropriate command.
    for name in c_commands:
        if command == name.split("-")[0]:
            # set the arguments.
            if len(sys.argv[1].split("-")) > 1:
                arguments = sys.argv[1].split("-")[1].split("::")
            else:
                arguments = []

            c_commands[name](server, capability, arguments)

            sys.exit(0)

    # wrong command.
    env.display(env.HEADER_ERROR, "unknown command '" + arguments[0] + "'",
                env.OPTION_NONE)

    # display usage.
    Usage()
Ejemplo n.º 35
0
def			warning():
  env.display(env.HEADER_NONE, "", env.OPTION_NONE)
  env.display(env.HEADER_OK, "configuration:", env.OPTION_NONE)
  env.display(env.HEADER_OK,
              "  document:               " + g_document,
              env.OPTION_NONE)
  env.display(env.HEADER_NONE, "", env.OPTION_NONE)
Ejemplo n.º 36
0
def machine():
    env.display(env.HEADER_OK,
                "installing links to machine-dependent directories",
                env.OPTION_NONE)

    env.remove(env._GLUE_CURRENT_, env.OPTION_NONE)
    env.link(env._GLUE_CURRENT_, env._GLUE_DIR_, env.OPTION_NONE)

    env.remove(env._PLATFORM_CURRENT_, env.OPTION_NONE)
    env.link(env._PLATFORM_CURRENT_, env._PLATFORM_DIR_, env.OPTION_NONE)

    env.remove(env._ARCHITECTURE_CURRENT_, env.OPTION_NONE)
    env.link(env._ARCHITECTURE_CURRENT_, env._ARCHITECTURE_DIR_,
             env.OPTION_NONE)
Ejemplo n.º 37
0
def contributor():
    path = None
    link = None
    name = None

    # display.
    env.display(env.HEADER_OK, "generating a contributor's capability",
                env.OPTION_NONE)

    # retrieve the server's code.
    code = ktp.code.Load(env._TEST_STORE_CODE_DIR_ + "/server" +          \
                           ktp.code.Extension)

    # compute the name.
    name = env._USER_

    # compute the file name.
    path = env._TEST_STORE_CAPABILITY_DIR_ + "/" +                        \
      name + ktp.capability.Extension

    # compute the link.
    link = env._TEST_CAPABILITY_

    # create the capability.
    capability = ktp.capability.Create(
        code, name, ktp.capability.TypeContributor, {},
        [{
            "name": env._TEST_NAME_,
            "email": env._TEST_EMAIL_,
            "login": env._TEST_NAME_.lower().replace(" ", ".")
        }])

    # store it.
    ktp.capability.Store(path, capability)

    # remove the previous link.
    env.remove(link, env.OPTION_NONE)

    # create a link from the profile. XXX[this could probably be improved]
    env.link(
        link,
        "../../../../test/store/capability/" + name + ktp.capability.Extension,
        env.OPTION_NONE)

    # display.
    env.display(env.HEADER_OK,
                "the contributor capability has been generated " +        \
                "succesfully for '" + name + "'",
                env.OPTION_NONE)
Ejemplo n.º 38
0
def main():
    code = None

    # display.
    env.display(env.HEADER_OK, "generating the server's code", env.OPTION_NONE)

    # generate a code.
    code = ktp.code.Generate()

    # store the code.
    ktp.code.Store(env._TEST_STORE_CODE_DIR_ + "/server" + ktp.code.Extension,
                   code)

    # display.
    env.display(env.HEADER_OK, "server code successfuly generated and stored",
                env.OPTION_NONE)
Ejemplo n.º 39
0
def	clean() :

	devnull = open("/dev/null", 'w+')

	env.display(env.HEADER_OK, "cleaning temporary files", env.OPTION_NONE)
#	p = subprocess.Popen(["rm", "-rf", TMP_PATH])
#	p.wait()

	# Elf
	p = subprocess.Popen(["make", "-C", "tests/elf_binary", "clean"],
			     stdout=devnull, stderr=devnull)
	p.wait()

	devnull.close()

	return
Ejemplo n.º 40
0
def robot():
    path = None
    link = None
    name = None

    # display.
    env.display(env.HEADER_OK, "generating the robot's capability",
                env.OPTION_NONE)

    # retrieve the server's code.
    code = ktp.code.Load(env._TEST_STORE_CODE_DIR_ + "/server" +          \
                           ktp.code.Extension)

    # compute the name.
    name = "robot"

    # compute the file name.
    path = env._TEST_STORE_CAPABILITY_DIR_ + "/" +                        \
      name + ktp.capability.Extension

    # compute the link.
    link = env._PROFILE_DIR_ + "/user/robot/robot" + ktp.capability.Extension

    # create the capability.
    capability = ktp.capability.Create(
        code, name, ktp.capability.TypeStudent, {}, [{
            "name": "Robot",
            "email": "*****@*****.**",
            "login": "******"
        }])

    # store it.
    ktp.capability.Store(path, capability)

    # remove the previous link.
    env.remove(link, env.OPTION_NONE)

    # create a link from the profile. XXX[this could probably be improved]
    env.link(
        link,
        "../../../../test/store/capability/" + name + ktp.capability.Extension,
        env.OPTION_NONE)

    # display.
    env.display(env.HEADER_OK,
                "the robot's capability has been generated succesfully",
                env.OPTION_NONE)
Ejemplo n.º 41
0
def                     group():
  components = None
  school = None
  year = None
  group = None
  name = None
  path = None
  configuration = None
  database = None

  # display.
  env.display(env.HEADER_OK,
              "generating database for the group '" + g_path + "'",
              env.OPTION_NONE)

  # retrieve the components.
  components = g_path.strip("/").split("/")

  # compute the school, year and group.
  school = components[0]
  year = components[1]
  group = components[2]

  # compute the name.
  name = school + "::" + year + "::" + group

  # compute the file name.
  path = env._TEST_STORE_DATABASE_DIR_ + "/" + name + ktp.database.Extension

  # load the configuration.
  configuration = ktp.configuration.Load(env._TEST_CONFIGURATION_DIR_ + \
                                           "/" + school + "::" +        \
                                           year + "#group" +            \
                                           ktp.configuration.Extension)

  # generate the database.
  database = ktp.database.Generate(configuration)

  # store the database.
  ktp.database.Store(database, path)

  # display message.
  env.display(env.HEADER_OK,
              "the group database '" + name + "' has been " +           \
                "generated succesfully",
              env.OPTION_NONE)
Ejemplo n.º 42
0
def group():
    components = None
    school = None
    year = None
    group = None
    name = None
    path = None
    configuration = None
    database = None

    # display.
    env.display(env.HEADER_OK,
                "generating database for the group '" + g_path + "'",
                env.OPTION_NONE)

    # retrieve the components.
    components = g_path.strip("/").split("/")

    # compute the school, year and group.
    school = components[0]
    year = components[1]
    group = components[2]

    # compute the name.
    name = school + "::" + year + "::" + group

    # compute the file name.
    path = env._TEST_STORE_DATABASE_DIR_ + "/" + name + ktp.database.Extension

    # load the configuration.
    configuration = ktp.configuration.Load(env._TEST_CONFIGURATION_DIR_ + \
                                             "/" + school + "::" +        \
                                             year + "#group" +            \
                                             ktp.configuration.Extension)

    # generate the database.
    database = ktp.database.Generate(configuration)

    # store the database.
    ktp.database.Store(database, path)

    # display message.
    env.display(env.HEADER_OK,
                "the group database '" + name + "' has been " +           \
                  "generated succesfully",
                env.OPTION_NONE)
Ejemplo n.º 43
0
def                     compare():
  student = None
  target = None

  # display a message.
  env.display(env.HEADER_OK,
              "comparing the snapshots with each others",
              env.OPTION_NONE)

  # for every snapshot to test, generate the trace of comparisons against
  # other snapshots.
  if g_targets: 
    for target in g_targets:
      print target

      student = None

      # retrieve the student structure.
      for student in g_history:
        if target == student["student"]:
          break

      if not student:
        env.display(env.HEADER_ERROR,
                    "the student '" + target + "' does not seem to exist",
                    env.OPTION_NONE)
        sys.exit(42)

      print student

      if (student["year"] == g_year) and                     \
         (student["stage"] == g_stage):
        # message.
        env.display(env.HEADER_OK,
                    "  " + student["name"],
                    env.OPTION_NONE)

        # launch the program.
        env.launch(env._CTC_COMPARE_TOOL_,
                   student["trace"] + " " + student["database"] + " -r " +
                   student["fingerprint"],
                   env.OPTION_QUIET)
  else:
    for student in g_history:
      if (student["year"] == g_year) and                     \
         (student["stage"] == g_stage):
        # message.
        env.display(env.HEADER_OK,
                    "  " + student["name"],
                    env.OPTION_NONE)

        # launch the program.
        env.launch(env._CTC_COMPARE_TOOL_,
                   student["trace"] + " " + student["database"] + " -r " +
                   student["fingerprint"],
                   env.OPTION_QUIET)
Ejemplo n.º 44
0
def menu():
    global g_components
    global g_menu
    content = None
    component = None

    # initialize the file content.
    content = "timeout 0\n" +						\
              "title kaneton\n"

    # add information about how to boot.
    if (env._BOOT_MODE_ == "peripheral") or (env._BOOT_MODE_ == "image"):
        if env._BOOT_DEVICE_ == "floppy":
            content += "root (fd0)\n"
        elif env._BOOT_DEVICE_ == "hard-drive":
            content += "root (hd0)\n"
        else:
            env.display(env.HEADER_ERROR,
                        "unknown boot device '" + env._BOOT_DEVICE_ + "'",
                        env.OPTION_NONE)
            sys.exit(42)
    elif env._BOOT_MODE_ == "network":
        content += "ifconfig --address=" + env._ADDRESS_ + " --server=" +	\
                     env._TFTP_ADDRESS_ + "\n" +				\
                   "root (nd)\n"
    else:
        env.display(env.HEADER_ERROR,
                    "unknown boot mode '" + env._BOOT_MODE_ + "'",
                    env.OPTION_NONE)
        sys.exit(42)

    # retrieve the grub modules from the _COMPONENTS_ environment variables.
    g_components = re.split("[ \t]+", env._COMPONENTS_.strip())

    # set the first component as the grub kernel.
    content += re.sub("^.*\/", "kernel /modules/", g_components[0]) + "\n"

    # set the other components as grub modules.
    for component in g_components[1:]:
        content += re.sub("^.*\/", "module /modules/", component) + "\n"

    # create the temporary file and fill it.
    g_menu = env.temporary(env.OPTION_FILE)

    env.push(g_menu, content, env.OPTION_NONE)
Ejemplo n.º 45
0
def                     generate():
  snapshot = None
  student = None
  file = None

  # display a message.
  env.display(env.HEADER_OK,
              "generating the snapshots' fingerprints",
              env.OPTION_NONE)

  # generate the token files.
  for student in g_history:
    # message.
    env.display(env.HEADER_OK,
                "  " + student["name"],
                env.OPTION_NONE)

    # create the token file
    env.launch(env._CTC_BUILD_TOOL_,
               "'" + student["sources"] + "/kaneton/'" + " " +
               "'" + student["fingerprint"] + "'",
               env.OPTION_QUIET)

  # display a message.
  env.display(env.HEADER_OK,
              "generating the snapshots' tokens database",
              env.OPTION_NONE)

  # generate the database file.
  for student in g_history:
    # if this student is part of the ones to test, continue.
    if (student["year"] == g_year) and                          \
       (student["stage"] == g_stage):
      fingerprints = []

      # message.
      env.display(env.HEADER_OK,
                  "  " + student["name"],
                  env.OPTION_NONE)

      # find the list of student snaphosts that will be tested against it.
      for snapshot in g_history:
        # skip the previous stages of the same user.
        if (student["year"] == snapshot["year"]) and            \
           (student["student"] == snapshot["student"]) and      \
           (student["stage"] != snapshot["stage"]):
          continue

        # add the fingerprint to the list.
        fingerprints += [ snapshot["fingerprint"] ]

      # finally, gather the information into a single database.
      env.launch(env._CTC_GATHER_TOOL_,
                 student["database"] + " " + " ".join(fingerprints),
                 env.OPTION_QUIET)
Ejemplo n.º 46
0
def parse_data_file(filename):
  global g_action_data
  global g_modules
  global g_export_dir
  global g_modules_parameters

  g_action_data = action_data_load(filename)
  for i in g_action_data:
    if i['operation'] == 'import':
      env.display(env.HEADER_OK, 'action import ' + i['filename'], env.OPTION_NONE)
      parse_data_file("behaviours/" + i['filename'])
    else:   
      arg = {}
      for j in range(1, len(g_modules_parameters[i['operation']])):
        arg[g_modules_parameters[i['operation']][j]] = i[g_modules_parameters[
            i['operation']][j]];
      if g_modules[i['operation']].module_action(g_export_dir, arg) != 0:
        sys.exit(1)
Ejemplo n.º 47
0
def			menu():
  global g_components
  global g_menu
  content = None
  component = None

  # initialize the file content.
  content = "timeout 0\n" +						\
            "title kaneton\n"

  # add information about how to boot.
  if (env._BOOT_MODE_ == "peripheral") or (env._BOOT_MODE_ == "image"):
    if env._BOOT_DEVICE_ == "floppy":
      content += "root (fd0)\n"
    elif env._BOOT_DEVICE_ == "hard-drive":
      content += "root (hd0)\n"
    else:
      env.display(env.HEADER_ERROR,
                  "unknown boot device '" + env._BOOT_DEVICE_ + "'",
                  env.OPTION_NONE)
      sys.exit(42)
  elif env._BOOT_MODE_ == "network":
    content += "ifconfig --address=" + env._ADDRESS_ + " --server=" +	\
                 env._TFTP_ADDRESS_ + "\n" +				\
               "root (nd)\n"
  else:
    env.display(env.HEADER_ERROR, "unknown boot mode '" + env._BOOT_MODE_ +
                "'", env.OPTION_NONE)
    sys.exit(42)

  # retrieve the grub modules from the _COMPONENTS_ environment variables.
  g_components = re.split("[ \t]+", env._COMPONENTS_.strip())

  # set the first component as the grub kernel.
  content += re.sub("^.*\/", "kernel /modules/", g_components[0]) + "\n"

  # set the other components as grub modules.
  for component in g_components[1:]:
    content += re.sub("^.*\/", "module /modules/", component) + "\n"

  # create the temporary file and fill it.
  g_menu = env.temporary(env.OPTION_FILE)

  env.push(g_menu, content, env.OPTION_NONE)
Ejemplo n.º 48
0
def compare():
    student = None
    target = None

    # display a message.
    env.display(env.HEADER_OK, "comparing the snapshots with each others",
                env.OPTION_NONE)

    # for every snapshot to test, generate the trace of comparisons against
    # other snapshots.
    if g_targets:
        for target in g_targets:
            print target

            student = None

            # retrieve the student structure.
            for student in g_history:
                if target == student["student"]:
                    break

            if not student:
                env.display(
                    env.HEADER_ERROR,
                    "the student '" + target + "' does not seem to exist",
                    env.OPTION_NONE)
                sys.exit(42)

            print student

            if (student["year"] == g_year) and                     \
               (student["stage"] == g_stage):
                # message.
                env.display(env.HEADER_OK, "  " + student["name"],
                            env.OPTION_NONE)

                # launch the program.
                env.launch(
                    env._CTC_COMPARE_TOOL_, student["trace"] + " " +
                    student["database"] + " -r " + student["fingerprint"],
                    env.OPTION_QUIET)
    else:
        for student in g_history:
            if (student["year"] == g_year) and                     \
               (student["stage"] == g_stage):
                # message.
                env.display(env.HEADER_OK, "  " + student["name"],
                            env.OPTION_NONE)

                # launch the program.
                env.launch(
                    env._CTC_COMPARE_TOOL_, student["trace"] + " " +
                    student["database"] + " -r " + student["fingerprint"],
                    env.OPTION_QUIET)
Ejemplo n.º 49
0
def                     main():
  code = None

  # display.
  env.display(env.HEADER_OK,
              "generating the server's code",
              env.OPTION_NONE)

  # generate a code.
  code = ktp.code.Generate()

  # store the code.
  ktp.code.Store(env._TEST_STORE_CODE_DIR_ + "/server" + ktp.code.Extension,
                 code)

  # display.
  env.display(env.HEADER_OK,
              "server code successfuly generated and stored",
              env.OPTION_NONE)
Ejemplo n.º 50
0
def shear():
    # display a message.
    env.display(env.HEADER_OK, "shearing the students' snaphosts",
                env.OPTION_NONE)

    # for each student.
    for student in g_history:
        # message.
        env.display(env.HEADER_OK, "  " + student["name"], env.OPTION_NONE)

        # remove the extra useless stuff.
        filter(student)

        # continue only if the student is part of the given year
        # and if a base snapshot is provided for that year.
        if (student["year"] == g_year) and g_base:
            # remove the common parts.
            walk(student["sources"] + "/kaneton", g_base["path"] + "/kaneton",
                 None)
Ejemplo n.º 51
0
def Usage():
    command = None

    env.display(env.HEADER_ERROR, "usage: client.py [command]",
                env.OPTION_NONE)

    env.display(env.HEADER_NONE, "", env.OPTION_NONE)

    env.display(env.HEADER_ERROR, "commands:", env.OPTION_NONE)

    for command in c_commands:
        env.display(env.HEADER_ERROR, "  " + command, env.OPTION_NONE)
Ejemplo n.º 52
0
def			Usage():
  command = None

  env.display(env.HEADER_ERROR, "usage: client.py [command]",
              env.OPTION_NONE)

  env.display(env.HEADER_NONE, "", env.OPTION_NONE)

  env.display(env.HEADER_ERROR, "commands:", env.OPTION_NONE)

  for command in c_commands:
    env.display(env.HEADER_ERROR, "  " + command, env.OPTION_NONE)
Ejemplo n.º 53
0
def parse_data_file(filename):
    global g_action_data
    global g_modules
    global g_export_dir
    global g_modules_parameters

    g_action_data = action_data_load(filename)
    for i in g_action_data:
        if i['operation'] == 'import':
            env.display(env.HEADER_OK, 'action import ' + i['filename'],
                        env.OPTION_NONE)
            parse_data_file("behaviours/" + i['filename'])
        else:
            arg = {}
            for j in range(1, len(g_modules_parameters[i['operation']])):
                arg[g_modules_parameters[i['operation']][j]] = i[
                    g_modules_parameters[i['operation']][j]]
            if g_modules[i['operation']].module_action(g_export_dir, arg) != 0:
                sys.exit(1)
Ejemplo n.º 54
0
def usage():
    component = None

    env.display(env.HEADER_ERROR, "usage: database.py [component]",
                env.OPTION_NONE)

    env.display(env.HEADER_NONE, "", env.OPTION_NONE)

    env.display(env.HEADER_ERROR, "components:", env.OPTION_NONE)

    for component in c_components:
        env.display(env.HEADER_ERROR, "  " + component, env.OPTION_NONE)
Ejemplo n.º 55
0
def usage():
    location = None
    store = None

    env.display(env.HEADER_ERROR, "usage: view.py [document]", env.OPTION_NONE)

    env.display(env.HEADER_NONE, "", env.OPTION_NONE)

    env.display(env.HEADER_ERROR, "documents:", env.OPTION_NONE)

    for store in g_store:
        for location in store:
            env.display(env.HEADER_ERROR, "  " + location, env.OPTION_NONE)
Ejemplo n.º 56
0
def			usage():
  location = None
  store = None

  env.display(env.HEADER_ERROR, "usage: view.py [document]", env.OPTION_NONE)

  env.display(env.HEADER_NONE, "", env.OPTION_NONE)

  env.display(env.HEADER_ERROR, "documents:", env.OPTION_NONE)

  for store in g_store:
    for location in store:
      env.display(env.HEADER_ERROR, "  " + location, env.OPTION_NONE)
Ejemplo n.º 57
0
def locate(directory):
    functions = []
    manifest = None

    # display.
    env.display(env.HEADER_OK, "locating the test manifests", env.OPTION_NONE)

    # retrieve the list of tests.
    manifests = env.search(directory, "^.*.mnf$",
                           env.OPTION_FILE | env.OPTION_RECURSIVE)

    # load the manifests.
    for manifest in manifests:
        # read the file.
        stream = ktp.manifest.Load(manifest)

        # record the function symbol.
        functions += [stream["symbol"]]

    return functions
Ejemplo n.º 58
0
def Information(server, capability, arguments):
    information = None
    item = None

    # check the arguments
    if len(arguments) != 0:
        Usage()
        sys.exit(42)

    # warning
    Warning()

    # retrieve the information.
    information = ktp.xmlrpc.Call(server.Information(capability))

    # display a message.
    env.display(env.HEADER_OK, "information:", env.OPTION_NONE)

    # dump the information dictionary.
    Dump(information, "  ")
Ejemplo n.º 59
0
def ca():
    key = None
    request = None
    certificate = None

    # generate a cryptographic key.
    key = ktp.key.Generate()

    # generate a certificate request.
    request = ktp.certificate.Request(key,
                                      CN="test.opaak.org",
                                      emailAddress="*****@*****.**")

    # finally, build a valid, self-certified certificate
    certificate = ktp.certificate.Create(request, (request, key), 0,
                                         (0, 60 * 60 * 24 * 365 * 10))

    # display
    env.display(env.HEADER_OK, "CA key/certificate generated", env.OPTION_NONE)

    return (key, certificate)