コード例 #1
0
ファイル: breplace.py プロジェクト: Jupotter/kaneton
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
コード例 #2
0
ファイル: inventory.py プロジェクト: bbycode/tinyOs
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)
コード例 #3
0
ファイル: database.py プロジェクト: fenollp/kaneton
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)
コード例 #4
0
ファイル: initialize.py プロジェクト: Jupotter/kaneton
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)
コード例 #5
0
ファイル: database.py プロジェクト: fenollp/kaneton
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)
コード例 #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)
コード例 #7
0
ファイル: capability.py プロジェクト: fenollp/kaneton
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()
コード例 #8
0
ファイル: clean.py プロジェクト: Jupotter/kaneton
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)
コード例 #9
0
ファイル: record.py プロジェクト: fenollp/kaneton
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)
コード例 #10
0
ファイル: client.py プロジェクト: Jupotter/kaneton
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)
コード例 #11
0
ファイル: breplace.py プロジェクト: bbycode/tinyOs
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
コード例 #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)
コード例 #13
0
ファイル: octaneload.py プロジェクト: bbycode/tinyOs
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)
コード例 #14
0
ファイル: initialize.py プロジェクト: Jupotter/kaneton
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)
コード例 #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()
コード例 #16
0
ファイル: initialize.py プロジェクト: bbycode/tinyOs
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)
コード例 #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)
コード例 #18
0
ファイル: certificate.py プロジェクト: fenollp/kaneton
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)
コード例 #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
コード例 #20
0
ファイル: clean.py プロジェクト: Jupotter/kaneton
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)
コード例 #21
0
ファイル: fremovepattern.py プロジェクト: bbycode/tinyOs
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
コード例 #22
0
ファイル: grub.py プロジェクト: bbycode/tinyOs
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)
コード例 #23
0
ファイル: grub.py プロジェクト: Jupotter/kaneton
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)
コード例 #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
コード例 #25
0
ファイル: cheat.py プロジェクト: fenollp/kaneton
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)
コード例 #26
0
ファイル: check.py プロジェクト: fenollp/kaneton
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
コード例 #27
0
ファイル: cheat.py プロジェクト: bbycode/tinyOs
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)
コード例 #28
0
ファイル: capability.py プロジェクト: fenollp/kaneton
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)
コード例 #29
0
ファイル: octaneload.py プロジェクト: bbycode/tinyOs
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)
コード例 #30
0
ファイル: capability.py プロジェクト: fenollp/kaneton
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)
コード例 #31
0
ファイル: client.py プロジェクト: Jupotter/kaneton
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()
コード例 #32
0
ファイル: clean.py プロジェクト: Jupotter/kaneton
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)
コード例 #33
0
ファイル: record.py プロジェクト: fenollp/kaneton
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)
コード例 #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()
コード例 #35
0
ファイル: view.py プロジェクト: fenollp/kaneton
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)
コード例 #36
0
ファイル: initialize.py プロジェクト: bbycode/tinyOs
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)
コード例 #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)
コード例 #38
0
ファイル: code.py プロジェクト: bbycode/tinyOs
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)
コード例 #39
0
ファイル: check.py プロジェクト: fenollp/kaneton
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
コード例 #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)
コード例 #41
0
ファイル: database.py プロジェクト: fenollp/kaneton
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)
コード例 #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)
コード例 #43
0
ファイル: cheat.py プロジェクト: fenollp/kaneton
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)
コード例 #44
0
ファイル: grub.py プロジェクト: bbycode/tinyOs
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)
コード例 #45
0
ファイル: cheat.py プロジェクト: fenollp/kaneton
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)
コード例 #46
0
ファイル: export.py プロジェクト: Jupotter/kaneton
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)
コード例 #47
0
ファイル: grub.py プロジェクト: Jupotter/kaneton
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)
コード例 #48
0
ファイル: cheat.py プロジェクト: bbycode/tinyOs
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)
コード例 #49
0
ファイル: code.py プロジェクト: fenollp/kaneton
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)
コード例 #50
0
ファイル: cheat.py プロジェクト: bbycode/tinyOs
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)
コード例 #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)
コード例 #52
0
ファイル: client.py プロジェクト: Jupotter/kaneton
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)
コード例 #53
0
ファイル: export.py プロジェクト: bbycode/tinyOs
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)
コード例 #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)
コード例 #55
0
ファイル: view.py プロジェクト: bbycode/tinyOs
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)
コード例 #56
0
ファイル: view.py プロジェクト: fenollp/kaneton
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)
コード例 #57
0
ファイル: inventory.py プロジェクト: bbycode/tinyOs
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
コード例 #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, "  ")
コード例 #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)