コード例 #1
0
ファイル: proph.py プロジェクト: paulhauner/prophessor
 def create_diff_and_revision(self, diff_file, project_part):
     callsign_mappings = phab_diff.get_callsign_mapping()
     group_number = submitted_diffs.get_diff_group_number(
         diff_file, callsign_mappings=callsign_mappings)
     if not group_number:
         print('Error: Could not determine group number from filename: %s' %
               diff_file)
         return -1
     project_name = group_translator.build_project_name(
         group_num=group_number,
         project_part=project_part,
         is_marking_group=False)
     marking_project_name = group_translator.build_project_name(
         group_num=group_number,
         project_part=project_part,
         is_marking_group=True)
     # this code will only run if we know a group to which we should assign this diff to
     marking_project_phid = phab_project.get_phid_from_name(
         marking_project_name)
     if not marking_project_phid:
         print("Error: could not find project PHID for diff: %s" %
               diff_file)
         return -1
     # this code will only run if we have a valid phid for the project
     diff_id = self.create_diff_from_file(diff_file)
     if diff_id < 0:
         print('Error: Could not create differential with file: %s' %
               diff_file)
         return -1
     # this code will only run if we successfully created a diff
     revision_id = phab_diff.create_revision(diff_id=diff_id,
                                             title=project_name)
     if not revision_id:
         print('Error: Unable to create revision for diff file: %s' %
               diff_file)
     # this code will only run if we have successfully created a diff & revision
     policy_phid = phab_policy.create_project_policy([marking_project_phid])
     if not policy_phid:
         print("Error: unable to create policy")
         return -1
     # this code will only run if we have a policy to add to our new revision
     phab_diff.set_revision_policy(revision_id=revision_id,
                                   view_policy=policy_phid,
                                   edit_policy=policy_phid)
     revision_phid = phab_diff.get_phid_from_id(revision_id)
     if not revision_phid:
         print("Error: unable to obtain phid for revision")
         return -1
     # this code will only run if we know our marking project and revision phids
     self.assign_project_users_to_diff_revision_as_reviewers(
         revision_phid, marking_project_phid)
     print("Success for project: %s" % (project_name))
     '''
コード例 #2
0
ファイル: proph.py プロジェクト: paulhauner/prophessor
 def create_diff_and_revision(self, diff_file, project_part):
     callsign_mappings = phab_diff.get_callsign_mapping()
     group_number = submitted_diffs.get_diff_group_number(diff_file, callsign_mappings=callsign_mappings)
     if not group_number:
         print('Error: Could not determine group number from filename: %s' % diff_file)
         return -1
     project_name = group_translator.build_project_name(
         group_num=group_number,
         project_part=project_part,
         is_marking_group=False
     )
     marking_project_name = group_translator.build_project_name(
         group_num=group_number,
         project_part=project_part,
         is_marking_group=True
     )
     # this code will only run if we know a group to which we should assign this diff to
     marking_project_phid = phab_project.get_phid_from_name(marking_project_name)
     if not marking_project_phid:
         print("Error: could not find project PHID for diff: %s" % diff_file)
         return -1
     # this code will only run if we have a valid phid for the project
     diff_id = self.create_diff_from_file(diff_file)
     if diff_id < 0:
         print('Error: Could not create differential with file: %s' % diff_file)
         return -1
     # this code will only run if we successfully created a diff
     revision_id = phab_diff.create_revision(
         diff_id=diff_id,
         title=project_name
     )
     if not revision_id:
         print('Error: Unable to create revision for diff file: %s' % diff_file)
     # this code will only run if we have successfully created a diff & revision
     policy_phid = phab_policy.create_project_policy([marking_project_phid])
     if not policy_phid:
         print("Error: unable to create policy")
         return -1
     # this code will only run if we have a policy to add to our new revision
     phab_diff.set_revision_policy(
         revision_id=revision_id,
         view_policy=policy_phid,
         edit_policy=policy_phid
     )
     revision_phid = phab_diff.get_phid_from_id(revision_id)
     if not revision_phid:
         print("Error: unable to obtain phid for revision")
         return -1
     # this code will only run if we know our marking project and revision phids
     self.assign_project_users_to_diff_revision_as_reviewers(revision_phid , marking_project_phid)
     print("Success for project: %s" % (project_name))
     '''
コード例 #3
0
ファイル: proph.py プロジェクト: ejwmoreau/prophessor
    def lockdown_repos(self, csv):
        """
        lockdown_repos sets custom policies on the repositories, such that only
        project members can view, edit, and push their repository.
        :param csv: csv entries of each student and their group.
        :return: None.
        """
        groups = load_group_membership.unique_groups(csv)
        for group_code in groups:
            group_num = group_translator.get_group_number_from_group_code(group_code)

            if group_num:
                student_project_name = group_translator.build_project_name(group_num, 1, False)
                student_project_phid = phab_project.get_phid_from_name(student_project_name)

                if student_project_phid is not None:
                    callsign = repos_util.callsign_from_group_num(group_num)

                    # Sets the repository policy to only the Project members.
                    policy = phab_policy.create_project_policy([student_project_phid])
                    phab_repo.set_repository_policy(callsign, policy, policy, policy)

                    print("Repo %s was assigned policy %s (View,Edit,Push) allowing access from student group %s" % (
                        callsign,
                        policy,
                        student_project_name,
                    ))
                else:
                    print("ERROR: Unable to determine student groups for group %s" % (group_num,))
            else:
                print("Skipped: %s" % (group_code,))
コード例 #4
0
ファイル: proph.py プロジェクト: paulhauner/prophessor
    def lockdown_repos(self, csv, projectPhid=False):
        """
        lockdown_repos sets custom policies on the repositories, such that only
        project members can view, edit, and push their repository.
        :param csv: csv entries of each student and their group.
        :return: None.
        """
        groups = load_group_membership.unique_groups(csv)
        for group_code in groups:
            group_num = group_translator.get_group_number_from_group_code(
                group_code)

            if not group_num is None:
                student_project_name = group_translator.build_project_name(
                    group_num, 1, False)
                student_project_phid = phab_project.get_phid_from_name(
                    student_project_name)

                if student_project_phid is not None:
                    callsign = repos_util.callsign_from_group_num(group_num)

                    if projectPhid == False:
                        # Sets the repository policy to only the Project members.
                        policy = phab_policy.create_project_policy(
                            [student_project_phid])
                        phab_repo.set_repository_policy(
                            callsign, policy, policy, policy)
                    else:
                        policy = student_project_phid
                        phab_repo.set_repository_policy(
                            callsign, policy, policy, policy)

                    print(
                        "Repo %s was assigned policy %s (View,Edit,Push) allowing access from student group %s"
                        % (
                            callsign,
                            policy,
                            student_project_name,
                        ))
                else:
                    print(
                        "ERROR: Unable to determine student groups for group %s"
                        % (group_num, ))
            else:
                print("Skipped: %s" % (group_code, ))
コード例 #5
0
ファイル: proph.py プロジェクト: paulhauner/prophessor
    action.print_callsign_mappings()
    thanks()

elif arg_task == 'grant-student-diff-access':
    # python proph.py grant-student-diff-access students.csv 1234
    part = int(sys.argv[2])
    all_diffs = phab_diff.get_all_diffs()
    for diff in all_diffs:
        group_number = group_translator.get_group_number_from_project_name(
            diff['title'])
        project_number = group_translator.get_project_number_from_project_name(
            diff['title'])
        if project_number == part:
            # note: if your student groups differ from marking groups, you can use the commented out line below
            # make sure you change the number (1) to the student group you want to use.
            student_project_name = group_translator.build_project_name(
                group_number, 1, False)
            # student_project_name = group_translator.build_project_name(group_number, project_number, False)
            marking_project_name = group_translator.build_project_name(
                group_number, project_number, True)
            student_project_phid = phab_project.get_phid_from_name(
                student_project_name)
            marking_project_phid = phab_project.get_phid_from_name(
                marking_project_name)
            if marking_project_phid is not None and student_project_phid is not None:
                policy = phab_policy.create_project_policy(
                    [student_project_phid, marking_project_phid])
                phab_diff.set_revision_policy(diff['id'], policy, policy)
                print(
                    'Diff %s was assigned policy %s (View,Edit) allowing access from student group %s and marking group %s'
                    % (
                        diff['title'],
コード例 #6
0
ファイル: proph.py プロジェクト: paulhauner/prophessor
    # python proph.py print-callsign-mappings
    action = LoadRawDiffs()
    action.print_callsign_mappings()
    thanks()

elif arg_task == 'grant-student-diff-access':
    # python proph.py grant-student-diff-access students.csv 1234
    part = int(sys.argv[2])
    all_diffs = phab_diff.get_all_diffs()
    for diff in all_diffs:
        group_number = group_translator.get_group_number_from_project_name(diff['title'])
        project_number = group_translator.get_project_number_from_project_name(diff['title'])
        if project_number == part:
            # note: if your student groups differ from marking groups, you can use the commented out line below
            # make sure you change the number (1) to the student group you want to use.
            student_project_name = group_translator.build_project_name(group_number, 1, False)
            # student_project_name = group_translator.build_project_name(group_number, project_number, False)
            marking_project_name = group_translator.build_project_name(group_number, project_number, True)
            student_project_phid = phab_project.get_phid_from_name(student_project_name)
            marking_project_phid = phab_project.get_phid_from_name(marking_project_name)
            if marking_project_phid is not None and student_project_phid is not None:
                policy = phab_policy.create_project_policy([student_project_phid, marking_project_phid])
                phab_diff.set_revision_policy(diff['id'], policy, policy)
                print('Diff %s was assigned policy %s (View,Edit) allowing access from student group %s and marking group %s' % (
                    diff['title'],
                    policy,
                    student_project_name,
                    marking_project_name,
                ))
            else:
                print('ERROR: Unable to determine student and/or marking groups for %s' % diff['title'])