예제 #1
0
파일: cheat.py 프로젝트: fenollp/kaneton
def                     extract():
  student = None
  base = None

  # display a message.
  env.display(env.HEADER_OK,
              "extracting the students' snapshots",
              env.OPTION_NONE)

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

    env.mkdir(student["sources"], env.OPTION_NONE)

    if env.path(student["snapshot"], env.OPTION_EXIST):
      env.unpack(student["snapshot"],
                 student["sources"],
                 env.OPTION_QUIET)
    else:
      env.mkdir(student["sources"] + "/kaneton/", env.OPTION_NONE)

    # verify that the extracted snapshot has created a 'kaneton/' directory.
    if not (env.path(student["sources"] + "/kaneton/",
                     env.OPTION_EXIST)):
      env.display(env.HEADER_ERROR,
                  "the extracted student snapshot '" + student["name"] +
                  "' does not contain a 'kaneton/' directory",
                  env.OPTION_NONE)

    if len(env.list(student["sources"],
                    env.OPTION_FILE | env.OPTION_DIRECTORY)) != 1:
      env.display(env.HEADER_ERROR,
                  "the extracted student snapshot '" + student["name"] +
                  "' contains more than just the 'kaneton/' directory",
                  env.OPTION_NONE)

  # extract the bases.
  if g_base:
    env.unpack(g_base["snapshot"],
               g_base["path"],
                 env.OPTION_QUIET)

    # verify that the extracted snapshot has created a 'kaneton/' directory.
    if not (env.path(g_base["path"] + "/kaneton/",
                     env.OPTION_EXIST)):
      env.display(env.HEADER_ERROR,
                  "the extracted base snapshot '" + g_base["snapshot"] +
                  "' does not contain a 'kaneton/' directory",
                  env.OPTION_NONE)

    if len(env.list(g_base["path"],
                    env.OPTION_FILE | env.OPTION_DIRECTORY)) != 1:
      env.display(env.HEADER_ERROR,
                  "the extracted base snapshot '" + g_base["snapshot"] +
                  "' contains more than just the 'kaneton/' directory",
                  env.OPTION_NONE)
예제 #2
0
파일: cheat.py 프로젝트: bbycode/tinyOs
def extract():
    student = None
    base = None

    # display a message.
    env.display(env.HEADER_OK, "extracting the students' snapshots",
                env.OPTION_NONE)

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

        env.mkdir(student["sources"], env.OPTION_NONE)

        if env.path(student["snapshot"], env.OPTION_EXIST):
            env.unpack(student["snapshot"], student["sources"],
                       env.OPTION_QUIET)
        else:
            env.mkdir(student["sources"] + "/kaneton/", env.OPTION_NONE)

        # verify that the extracted snapshot has created a 'kaneton/' directory.
        if not (env.path(student["sources"] + "/kaneton/", env.OPTION_EXIST)):
            env.display(
                env.HEADER_ERROR, "the extracted student snapshot '" +
                student["name"] + "' does not contain a 'kaneton/' directory",
                env.OPTION_NONE)

        if len(
                env.list(student["sources"],
                         env.OPTION_FILE | env.OPTION_DIRECTORY)) != 1:
            env.display(
                env.HEADER_ERROR,
                "the extracted student snapshot '" + student["name"] +
                "' contains more than just the 'kaneton/' directory",
                env.OPTION_NONE)

    # extract the bases.
    if g_base:
        env.unpack(g_base["snapshot"], g_base["path"], env.OPTION_QUIET)

        # verify that the extracted snapshot has created a 'kaneton/' directory.
        if not (env.path(g_base["path"] + "/kaneton/", env.OPTION_EXIST)):
            env.display(
                env.HEADER_ERROR,
                "the extracted base snapshot '" + g_base["snapshot"] +
                "' does not contain a 'kaneton/' directory", env.OPTION_NONE)

        if len(env.list(g_base["path"],
                        env.OPTION_FILE | env.OPTION_DIRECTORY)) != 1:
            env.display(
                env.HEADER_ERROR,
                "the extracted base snapshot '" + g_base["snapshot"] +
                "' contains more than just the 'kaneton/' directory",
                env.OPTION_NONE)
예제 #3
0
파일: cheat.py 프로젝트: fenollp/kaneton
def                     prepare():
  global g_history
  global g_directory
  global g_output
  global g_base
  years = None
  year = None
  stages = None
  stage = None
  base = None

  # a message.
  env.display(env.HEADER_OK,
              "preparing the verification process",
              env.OPTION_NONE)

  # create a temporary directory for holding unpacked snapshots.
  g_directory = env.temporary(env.OPTION_DIRECTORY)

  # set the output file path.
  g_output = env._HISTORY_DIR_ + "/" + g_school + "/" + g_year + "/" +  \
             g_stage + ".html"

  # build the CTC tool
  env.launch(env._CTC_DIR_ + "/Makefile", "", env.OPTION_QUIET)

  # look for a base snapshot.
  if env.path(env._HISTORY_DIR_ + "/" + g_school + "/" + g_year +       \
              "/snapshot.tar.bz2", env.OPTION_EXIST):
    g_base = { "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + \
                 g_year + "/snapshot.tar.bz2",
               "path": g_directory + "/snapshot" }

    env.mkdir(g_base["path"], env.OPTION_NONE)
  else:
    g_base = None

  # retreive the list of other snapshots to compare. neighbours are the
  # students in the same year while alumni are old students.
  years = sorted(env.list(env._HISTORY_DIR_ + "/" + g_school,
                          env.OPTION_DIRECTORY))

  for year in years:
    # skip the younger works.
    if year > g_year:
      continue

    # for the work from the same year, simply compare the same stages.
    if year == g_year:
      # retrieve the students in this year.
      students = sorted(env.list(env._HISTORY_DIR_ + "/" +              \
                                   g_school + "/" + year,
                                 env.OPTION_DIRECTORY))

      # for every student.
      for student in students:
        # add the student to the list.
        g_history += [                                                  \
          {
            "name": year + "/" + student + "/" + g_stage,
            "year": year,
            "student": student,
            "stage": g_stage,
            "people": transform(env.pull(env._HISTORY_DIR_ + "/" +      \
                                         g_school + "/" + year + "/" +  \
                                         student + "/people",
                                         env.OPTION_NONE)),
            "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + year + "/" +
                        student + "/sources/" + g_stage + ".tar.bz2",
            "sources": g_directory + "/" + year + "/" +                 \
                       student + "/" + g_stage,
            "fingerprint": g_directory + "/" + year + "/" + student + "/" +
                           g_stage + ".ctf",
            "base": base,
            "database": g_directory + "/" + year + "/" + student + "/tokens",
            "trace": g_directory + "/" + year + "/" + student + "/trace"
          } ]

    # for older work, take the most recent work from every older student.
# XXX this feature has been disabled because it generates too much code to process.
    if (year < g_year) and (0 == 1):
      # retrieve the students in this year.
      students = sorted(env.list(env._HISTORY_DIR_ + "/" + g_school + "/" + year,
                                 env.OPTION_DIRECTORY))

      # for every student.
      for student in students:
        # find the works for this student.
        stages = sorted(env.list(env._HISTORY_DIR_ + "/" + g_school + "/" +
                                 year + "/" + student + "/sources/",
                                 env.OPTION_FILE))

        # ignore students that skipped the project.
        if len(stages) == 0:
          continue

        # find the most recent work.
        match = re.match("^(.*)\.tar\.bz2$", stages[len(stages) - 1])

        if not match:
          continue

        # retrieve the stage name.
        stage = match.group(1)

        # add the last student's work to the list.
        g_history += [                                                  \
          {
            "name": year + "/" + student + "/" + stage,
            "year": year,
            "student": student,
            "stage": stage,
            "people": transform(env.pull(env._HISTORY_DIR_ + "/" +      \
                                         g_school + "/" + year + "/" +  \
                                         student + "/people",
                                         env.OPTION_NONE)),
            "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + year + "/" +
                        student + "/sources/" + stage + ".tar.bz2",
            "sources": g_directory + "/" + year + "/" + student + "/" + stage,
            "fingerprint": g_directory + "/" + year + "/" + student + "/" +
                           stage + ".ctf",
            "base": base
          } ]
예제 #4
0
파일: cheat.py 프로젝트: bbycode/tinyOs
def prepare():
    global g_history
    global g_directory
    global g_output
    global g_base
    years = None
    year = None
    stages = None
    stage = None
    base = None

    # a message.
    env.display(env.HEADER_OK, "preparing the verification process",
                env.OPTION_NONE)

    # create a temporary directory for holding unpacked snapshots.
    g_directory = env.temporary(env.OPTION_DIRECTORY)

    # set the output file path.
    g_output = env._HISTORY_DIR_ + "/" + g_school + "/" + g_year + "/" +  \
               g_stage + ".html"

    # build the CTC tool
    env.launch(env._CTC_DIR_ + "/Makefile", "", env.OPTION_QUIET)

    # look for a base snapshot.
    if env.path(env._HISTORY_DIR_ + "/" + g_school + "/" + g_year +       \
                "/snapshot.tar.bz2", env.OPTION_EXIST):
        g_base = { "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + \
                     g_year + "/snapshot.tar.bz2",
                   "path": g_directory + "/snapshot" }

        env.mkdir(g_base["path"], env.OPTION_NONE)
    else:
        g_base = None

    # retreive the list of other snapshots to compare. neighbours are the
    # students in the same year while alumni are old students.
    years = sorted(
        env.list(env._HISTORY_DIR_ + "/" + g_school, env.OPTION_DIRECTORY))

    for year in years:
        # skip the younger works.
        if year > g_year:
            continue

        # for the work from the same year, simply compare the same stages.
        if year == g_year:
            # retrieve the students in this year.
            students = sorted(env.list(env._HISTORY_DIR_ + "/" +              \
                                         g_school + "/" + year,
                                       env.OPTION_DIRECTORY))

            # for every student.
            for student in students:
                # add the student to the list.
                g_history += [                                                  \
                  {
                    "name": year + "/" + student + "/" + g_stage,
                    "year": year,
                    "student": student,
                    "stage": g_stage,
                    "people": transform(env.pull(env._HISTORY_DIR_ + "/" +      \
                                                 g_school + "/" + year + "/" +  \
                                                 student + "/people",
                                                 env.OPTION_NONE)),
                    "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + year + "/" +
                                student + "/sources/" + g_stage + ".tar.bz2",
                    "sources": g_directory + "/" + year + "/" +                 \
                               student + "/" + g_stage,
                    "fingerprint": g_directory + "/" + year + "/" + student + "/" +
                                   g_stage + ".ctf",
                    "base": base,
                    "database": g_directory + "/" + year + "/" + student + "/tokens",
                    "trace": g_directory + "/" + year + "/" + student + "/trace"
                  } ]

        # for older work, take the most recent work from every older student.
# XXX this feature has been disabled because it generates too much code to process.
        if (year < g_year) and (0 == 1):
            # retrieve the students in this year.
            students = sorted(
                env.list(env._HISTORY_DIR_ + "/" + g_school + "/" + year,
                         env.OPTION_DIRECTORY))

            # for every student.
            for student in students:
                # find the works for this student.
                stages = sorted(
                    env.list(
                        env._HISTORY_DIR_ + "/" + g_school + "/" + year + "/" +
                        student + "/sources/", env.OPTION_FILE))

                # ignore students that skipped the project.
                if len(stages) == 0:
                    continue

                # find the most recent work.
                match = re.match("^(.*)\.tar\.bz2$", stages[len(stages) - 1])

                if not match:
                    continue

                # retrieve the stage name.
                stage = match.group(1)

                # add the last student's work to the list.
                g_history += [                                                  \
                  {
                    "name": year + "/" + student + "/" + stage,
                    "year": year,
                    "student": student,
                    "stage": stage,
                    "people": transform(env.pull(env._HISTORY_DIR_ + "/" +      \
                                                 g_school + "/" + year + "/" +  \
                                                 student + "/people",
                                                 env.OPTION_NONE)),
                    "snapshot": env._HISTORY_DIR_ + "/" + g_school + "/" + year + "/" +
                                student + "/sources/" + stage + ".tar.bz2",
                    "sources": g_directory + "/" + year + "/" + student + "/" + stage,
                    "fingerprint": g_directory + "/" + year + "/" + student + "/" +
                                   stage + ".ctf",
                    "base": base
                  } ]
예제 #5
0
파일: mkdir.py 프로젝트: bbycode/tinyOs
def module_action(export_dir, arg):
    env.display(env.HEADER_OK, 'action mkdir ' + arg['path'], env.OPTION_NONE)
    env.mkdir(export_dir + '/' + arg['path'], env.OPTION_NONE)
    return 0
예제 #6
0
파일: mkdir.py 프로젝트: Jupotter/kaneton
def module_action(export_dir, arg):
    env.display(env.HEADER_OK, 'action mkdir ' + arg['path'], env.OPTION_NONE)
    env.mkdir(export_dir + '/' + arg['path'], env.OPTION_NONE)
    return 0