Returns an 'old-style' course id, represented as 'org/course/run
429572
def _to_deprecated_string(self):
        """'"""
        return u'/'.join([self.org, self.course, self.run])
658286
def _run_ids(runner, pcap):
    
    run = {'name': runner.conf.get('name'),
           'module': runner.conf.get('module'),
           'ruleset': runner.conf.get('ruleset', 'default'),
           'status': STATUS_FAILED,
           }
    try:
        run_start = datetime.now()
        version, alerts = runner.run(pcap)
        run['version'] = version or 'Unknown'
        run['status'] = STATUS_SUCCESS
        run['alerts'] = alerts
    except Exception as ex:
        run['error'] = str(ex)
    finally:
        run['duration'] = duration(run_start)
    return run
960135
def _get_history_id(self, connection, agent_id, instance_id):
        '''
        
        '''
        cache_key = (agent_id, instance_id, )
        if cache_key in self._history_id_cache:
            history_id = self._history_id_cache[cache_key]
            return history_id
        else:
            command = text_helper.format_block("""
            SELECT id FROM histories WHERE agent_id = ? AND instance_id = ?
            """)
            cursor = connection.cursor()
            cursor.execute(command, (agent_id, instance_id, ))
            res = cursor.fetchall()
            if res:
                history_id = res[0][0]
                self._history_id_cache[cache_key] = history_id
                return history_id
            else:
                command = 'INSERT INTO histories VALUES (NULL, ?, ?)'
                cursor.execute(command, (agent_id, instance_id, ))
                history_id = cursor.lastrowid
                self._history_id_cache[cache_key] = history_id
                return history_id
154708
def to_id(self):
        
        return "%s%s%s%s%s" % (TraceId.VERSION, TraceId.DELIMITER,
                               format(self.start_time, 'x'),
                               TraceId.DELIMITER, self.__number)
1028460
def offering(self):
        
        warnings.warn(
            "Offering is no longer a supported property of Locator. Please use the course and run properties.",
            DeprecationWarning,
            stacklevel=2
        )
        if not self.course and not self.run:
            return None
        elif not self.run and self.course:
            return self.course
        return "/".join([self.course, self.run])
1204578
def show_page_courses(self, url, course_id):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """ID"""
        path["course_id"] = course_id

        # REQUIRED - PATH - url
        """ID"""
        path["url"] = url

        self.logger.debug("GET /api/v1/courses/{course_id}/pages/{url} with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/courses/{course_id}/pages/{url}".format(**path), data=data, params=params, single_item=True)
153329
def get_single_submission_courses(self, user_id, course_id, assignment_id, include=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """ID"""
        path["course_id"] = course_id

        # REQUIRED - PATH - assignment_id
        """ID"""
        path["assignment_id"] = assignment_id

        # REQUIRED - PATH - user_id
        """ID"""
        path["user_id"] = user_id

        # OPTIONAL - include
        """Associations to include with the group."""
        if include is not None:
            self._validate_enum(include, ["submission_history", "submission_comments", "rubric_assessment", "visibility", "course", "user"])
            params["include"] = include

        self.logger.debug("GET /api/v1/courses/{course_id}/assignments/{assignment_id}/submissions/{user_id} with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/courses/{course_id}/assignments/{assignment_id}/submissions/{user_id}".format(**path), data=data, params=params, no_data=True)
568892
def _get_lecture_asset_ids(self, course_id, video_id):
        
        dom = get_page(self._session, OPENCOURSE_ONDEMAND_LECTURE_ASSETS_URL,
                       json=True, course_id=course_id, video_id=video_id)
        # Note that we extract here "id", not definition -> assetId, as it
        # be extracted later.
        return [asset['id']
                for asset in dom['linked']['openCourseAssets.v1']]
788215
def delete(self):
        

        params = {'wsfunction': 'core_course_delete_courses',
                  'courseids[0]': self.course_id}
        params.update(self.request_params)

        return requests.post(self.api_url, params=params, verify=False)
815243
def get_course(id, opts = {})
      data, _status_code, _headers = get_course_with_http_info(id, opts)
      return data
    end
628470
def get_course_aggregations(self, course):
        
        return natsorted(list(self._database.aggregations.find({"courseid": course.get_id()})), key=lambda x: x["description"])
1129079
def get_course_video_image_url(course_id, edx_video_id):
    
    try:
        video_image = CourseVideo.objects.select_related('video_image').get(
            course_id=course_id, video__edx_video_id=edx_video_id
        ).video_image
        return video_image.image_url()
    except ObjectDoesNotExist:
        return None
845498
def restore_course(self, courseid, backup):
        
        self.wipe_course(courseid)

        filepath = os.path.join(self.backup_dir, courseid, backup + ".zip")
        with zipfile.ZipFile(filepath, "r") as zipf:

            aggregations = bson.json_util.loads(zipf.read("aggregations.json").decode("utf-8"))
            if len(aggregations) > 0:
                self.database.aggregations.insert(aggregations)

            user_tasks = bson.json_util.loads(zipf.read("user_tasks.json").decode("utf-8"))
            if len(user_tasks) > 0:
                self.database.user_tasks.insert(user_tasks)

            submissions = bson.json_util.loads(zipf.read("submissions.json").decode("utf-8"))
            for submission in submissions:
                for key in ["input", "archive"]:
                    if key in submission and type(submission[key]) == bson.objectid.ObjectId:
                        submission[key] = self.submission_manager.get_gridfs().put(zipf.read(key + "/" + str(submission[key]) + ".data"))

            if len(submissions) > 0:
                self.database.submissions.insert(submissions)

        self._logger.info("Course %s restored from backup directory.", courseid)
633001
def user_courses(self):
        '''
            
        '''
        registered = self.courses.filter(active__exact=True).distinct()
        return (self.tutor_courses() | registered).distinct()
1263822
def myfoo(i,s, course=['s'],gg=2,fdf=3,**d):
    
    print ('data:',d)
    if course:
        print (course)
        return course.get('id')
    else:
        print("No Course!")
        return None
765690
def edit_section(self, id, course_section_end_at=None, course_section_name=None, course_section_restrict_enrollments_to_section_dates=None, course_section_sis_section_id=None, course_section_start_at=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - id
        """ID"""
        path["id"] = id

        # OPTIONAL - course_section[name]
        """The name of the section"""
        if course_section_name is not None:
            data["course_section[name]"] = course_section_name

        # OPTIONAL - course_section[sis_section_id]
        """The sis ID of the section"""
        if course_section_sis_section_id is not None:
            data["course_section[sis_section_id]"] = course_section_sis_section_id

        # OPTIONAL - course_section[start_at]
        """Section start date in ISO8601 format, e.g. 2011-01-01T01:00Z"""
        if course_section_start_at is not None:
            data["course_section[start_at]"] = course_section_start_at

        # OPTIONAL - course_section[end_at]
        """Section end date in ISO8601 format. e.g. 2011-01-01T01:00Z"""
        if course_section_end_at is not None:
            data["course_section[end_at]"] = course_section_end_at

        # OPTIONAL - course_section[restrict_enrollments_to_section_dates]
        """Set to true to restrict user enrollments to the start and end dates of the section."""
        if course_section_restrict_enrollments_to_section_dates is not None:
            data["course_section[restrict_enrollments_to_section_dates]"] = course_section_restrict_enrollments_to_section_dates

        self.logger.debug("PUT /api/v1/sections/{id} with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("PUT", "/api/v1/sections/{id}".format(**path), data=data, params=params, single_item=True)
920960
def update_course_descriptor_content(self, courseid, content):
        
        path = self._get_course_descriptor_path(courseid)
        self._filesystem.put(path, get_json_or_yaml(path, content))