Exemple #1
0
def delete_step_on_disc(**kwargs: dict) -> True | False:
    folder = kwargs["folder_path"]
    data = kwargs["data"]
    f_course = folder + "/" + translate_non_alphanumerics(data["Course"].name)
    f_c_lesson = f_course + "/" + translate_non_alphanumerics(
        data["Lesson"].name)
    f_c_l_step = f_c_lesson + "/" + translate_non_alphanumerics(
        data["Step"].name)
    return delete_files_on_server(f_c_l_step)
Exemple #2
0
def delete_substep_on_disc(**kwargs: dict) -> True | False:
    folder = kwargs["folder_path"]
    data = kwargs["data"]
    f_course = folder + "/" + translate_non_alphanumerics(data["Course"].name)
    f_c_lesson = f_course + "/" + translate_non_alphanumerics(
        data["Lesson"].name)
    f_c_l_step = f_c_lesson + "/" + translate_non_alphanumerics(
        data["Step"].name)
    f_c_l_s_substep = f_c_l_step + "/" + translate_non_alphanumerics(
        data["currSubStep"].name)
    if not os.path.isdir(f_c_l_s_substep):
        return False
    else:
        shutil.rmtree(f_c_l_s_substep)
        while os.path.exists(f_c_l_s_substep):
            pass
        return True
Exemple #3
0
    def os_path(self):
        user_id = self.editors
        user_folder = UserProfile \
            .objects \
            .get(user_id=user_id) \
            .serverFilesFolder \
            .replace('/', os.sep)  # DB may contain path with bad separators

        return os.path.join(user_folder,
                            translate_non_alphanumerics(self.name) + os.sep)
Exemple #4
0
def search_as_files_and_update_info(args: dict) -> dict:
    folder = args['user_profile'].serverFilesFolder
    course = args['Course']
    file_status = [False] * (len(args['all_steps']))
    for index, step in enumerate(args['all_steps']):
        for l in args['all_course_lessons']:
            if step.from_lesson == l.pk and l.from_course == course.pk:
                path = folder + '/' + translate_non_alphanumerics(course.name)
                path += '/' + translate_non_alphanumerics(l.name)
                path += '/' + translate_non_alphanumerics(step.name)
                if os.path.exists(path):
                    file_status[index] = True
                    if not step.is_fresh:
                        step.duration = calculate_folder_duration_in_sec(path)
                        step.is_fresh = True
                        step.save()
                else:
                    pass
    ziped_list = zip(args['all_steps'], file_status)
    ziped_list = list(ziped_list)
    args.update({'all_steps': ziped_list})
    return args
Exemple #5
0
def export_obj_to_prproj(db_object,
                         files_extractor) -> InternalOperationResult:
    """Creates PPro project in .prproj format using ExtendScript script.
    Project includes video files of each subitem of corresponding object.
    Screencasts and camera recordings puts on different tracks of single sequence.
    :param files_extractor: function for extracting target filenames from db_object;
    :param db_object: db single object.
    """

    ppro_dir = os.path.dirname(settings.ADOBE_PPRO_PATH)
    if not os.path.isfile(os.path.join(ppro_dir, PRPROJ_REQUIRED_FILE)):
        return InternalOperationResult(
            ExecutionStatus.FATAL_ERROR,
            '\'{0}\' is missing. Please, place \'{0}\' empty file to \n\'{1}\'.'
            .format(PRPROJ_REQUIRED_FILE, ppro_dir))

    if FileSystemClient().process_with_name_exists(PPRO_WIN_PROCESS_NAME):
        return InternalOperationResult(
            ExecutionStatus.FATAL_ERROR,
            'Only one instance of PPro may exist. Please, close PPro and try again.'
        )

    screen_files, prof_files, marker_times, sync_offsets = files_extractor(
        db_object)

    if not screen_files or not prof_files:
        return InternalOperationResult(
            ExecutionStatus.FATAL_ERROR,
            'Object is empty or subitems are broken.')

    try:
        ppro_command = build_ppro_command(
            db_object.os_path, PRPROJ_TEMPLATES_PATH, screen_files, prof_files,
            marker_times, sync_offsets,
            translate_non_alphanumerics(db_object.name))
    except Exception as e:
        return InternalOperationResult(ExecutionStatus.FATAL_ERROR, e)

    exec_status = FileSystemClient().execute_command_sync(
        ppro_command, allowable_code=1)  # may return 1 - it's OK

    if exec_status.status is not ExecutionStatus.SUCCESS:
        logger.error('Cannot execute PPro command: %s \n PPro command: %s',
                     exec_status.message, ppro_command)
        return InternalOperationResult(
            ExecutionStatus.FATAL_ERROR,
            'Cannot execute PPro command. Check PPro configuration.')

    logger.info('Execution of PPro command started; \n PPro command: %s',
                ppro_command)
    return InternalOperationResult(ExecutionStatus.SUCCESS)
Exemple #6
0
def substep_server_path(**kwargs: dict) -> (str, str):
    folder = kwargs["folder_path"]
    data = kwargs["data"]
    if not os.path.isdir(folder):
        os.makedirs(folder)

    f_course = folder + "/" + translate_non_alphanumerics(data["Course"].name)
    if not os.path.isdir(f_course):
        os.makedirs(f_course)

    f_c_lesson = f_course + "/" + translate_non_alphanumerics(
        data["Lesson"].name)

    if not os.path.isdir(f_c_lesson):
        os.makedirs(f_c_lesson)

    f_c_l_step = f_c_lesson + "/" + translate_non_alphanumerics(
        data["Step"].name)
    if not os.path.isdir(f_c_l_step):
        os.makedirs(f_c_l_step)

    f_c_l_s_substep = f_c_l_step + "/" + translate_non_alphanumerics(
        data["currSubStep"].name)
    return f_c_l_s_substep, f_c_l_step
Exemple #7
0
    def clean(self):
        if not self.cleaned_data.get('name'):
            return

        if Step.objects.filter(from_lesson=self.lesson_id,
                               name=self.cleaned_data.get('name')).exists():
            raise ValidationError(
                'Name \'{}\' already exists. Please, use another name for step.'
                .format(self.cleaned_data.get('name')))

        lesson = Lesson.objects.get(id=self.lesson_id)
        new_step_path = lesson.os_path + translate_non_alphanumerics(
            self.cleaned_data.get('name')) + '/'

        if os.path.isdir(new_step_path):
            raise ValidationError(
                'OS already contains directory for step \'{}\'. Please, use another name for step.'
                .format(self.cleaned_data.get('name')))
Exemple #8
0
    def clean(self):
        if not self.cleaned_data.get('name'):
            return

        if Lesson.objects.filter(from_course=self.from_course,
                                 name=self.cleaned_data.get('name')).exists():
            raise ValidationError(
                'Name \'{}\' already exists. Please, use another name for lesson.'
                .format(self.cleaned_data.get('name')))

        course = Course.objects.get(id=self.from_course)
        new_lesson_path = course.os_path + translate_non_alphanumerics(
            self.cleaned_data.get('name')) + '/'

        if os.path.isdir(new_lesson_path):
            raise ValidationError(
                'OS already contains directory for lesson \'{}\'. '
                'Please, use another name for lesson.'.format(
                    self.cleaned_data.get('name')))
Exemple #9
0
 def tablet_path(self):
     course = Course.objects.get(id=self.from_course)
     return course.tablet_path + translate_non_alphanumerics(
         self.name) + '/'
Exemple #10
0
 def tablet_path(self):
     lesson = Lesson.objects.get(id=self.from_lesson)
     return lesson.tablet_path + translate_non_alphanumerics(
         self.name) + '/'
Exemple #11
0
 def os_automontage_path(self):
     lesson = Lesson.objects.get(id=self.from_lesson)
     return lesson.os_automontage_path + translate_non_alphanumerics(
         self.name) + os.sep
Exemple #12
0
 def os_path_v1(self):
     step = Step.objects.all().get(id=self.from_step)
     return step.os_path + translate_non_alphanumerics(
         self.name) + "/" + SUBSTEP_PROFESSOR_v1
Exemple #13
0
 def os_path_old(self):
     step = Step.objects.get(id=self.from_step)
     return os.path.join(
         step.os_path + translate_non_alphanumerics(self.name),
         self.camera_recording_name)
Exemple #14
0
 def os_path(self):
     course = Course.objects.all().get(id=self.from_course)
     return course.os_path + translate_non_alphanumerics(self.name) + "/"
Exemple #15
0
 def os_path(self):
     lesson = Lesson.objects.all().get(id=self.from_lesson)
     return lesson.os_path + translate_non_alphanumerics(self.name) + "/"
Exemple #16
0
 def os_automontage_path(self):
     step = Step.objects.all().get(id=self.from_step)
     return step.os_path + translate_non_alphanumerics(
         self.name) + "/" + self.name + FAST_MONTAGE
Exemple #17
0
 def os_path(self):
     user_id = self.editors
     user_folder = UserProfile.objects.all().get(
         user_id=user_id).serverFilesFolder
     return user_folder + "/" + translate_non_alphanumerics(self.name) + "/"
Exemple #18
0
 def os_screencast_path_v1(self):
     step = Step.objects.all().get(id=self.from_step)
     return step.os_path + translate_non_alphanumerics(
         self.name) + "/" + SUBSTEP_SCREEN_v1
Exemple #19
0
 def os_screencast_path_old(self):
     step = Step.objects.get(id=self.from_step)
     return os.path.join(
         step.os_path + translate_non_alphanumerics(self.name),
         self.screencast_name)
Exemple #20
0
 def os_automontage_path(self):
     course = Course.objects.get(id=self.from_course)
     return course.os_automontage_path + translate_non_alphanumerics(
         self.name) + os.sep
Exemple #21
0
 def tablet_path(self):
     user_id = self.editors
     username = User.objects.get(id=user_id).username
     return settings.LINUX_DIR + username + '/' + translate_non_alphanumerics(
         self.name) + '/'
Exemple #22
0
 def os_automontage_path(self):
     user_id = self.editors
     user_folder = UserProfile.objects.get(
         user_id=user_id).serverFilesFolder
     return os.path.join(user_folder, RAW_CUT_FOLDER_NAME,
                         translate_non_alphanumerics(self.name) + os.sep)