This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf-8 | |
import sys | |
from django.conf import settings | |
from django.conf.urls import patterns | |
from django.http import HttpResponse | |
from django.core.management import execute_from_command_line | |
settings.configure( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" > | |
<link href="http://libs.baidu.com/bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet"> | |
<link href="http://cdn.bootcss.com/bootstrap/2.3.2/css/bootstrap-responsive.min.css" rel="stylesheet"> | |
<script src="http://libs.baidu.com/jquery/1.8.2/jquery.min.js"></script> | |
<script src="http://libs.baidu.com/bootstrap/2.3.2/js/bootstrap.min.js"></script> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UpdateTime = urllib2.urlopen(u"http://zhihuhelpbyyzy-zhihu.stor.sinaapp.com/ZhihuHelpUpdateTime.txt",timeout=10) #线上总部 | |
import webbrowser | |
webbrowser.open_new_tab(url) #调用浏览器 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
#django test 中模拟登录的request | |
from django.contrib.sessions.middleware import SessionMiddleware | |
from django.test.client import RequestFactory | |
def add_session_to_request(request): | |
"""Annotate a request object with a session""" | |
middleware = SessionMiddleware() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Settings that can be used when running inside of a docker container | |
[hive] | |
release = apache | |
database = default | |
warehouse_path = hdfs://hadoop:9000/edx-analytics-pipeline/warehouse/ | |
[database-export] | |
database = analytics | |
#credentials = hdfs://hadoop:9000/edx-analytics-pipeline/output/local.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _update_with_kwargs(data_dict, **kwargs): | |
"""Updates a dict from kwargs only if it modifies a top-level value.""" | |
for key, value in kwargs.iteritems(): | |
if key in data_dict: | |
data_dict[key] = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#views.py | |
from opaque_keys.edx.locations import SlashSeparatedCourseKey | |
from courseware.courses import get_course_by_id | |
from .models import Addition | |
from rest_framework.response import Response | |
from rest_framework.decorators import api_view,permission_classes,authentication_classes | |
from rest_framework.authentication import SessionAuthentication,OAuth2Authentication | |
from django.core.exceptions import ObjectDoesNotExist | |
from django.conf import settings | |
from student.models import CourseEnrollment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
import logging | |
LOG_FILE = "log_file.log" | |
#logging.basicConfig(filename=LOG_FILE,level=logging.DEBUG) | |
logger = logging.getLogger(__name__) | |
handler=logging.FileHandler(LOG_FILE) | |
logger.addHandler(handler) | |
logger.setLevel(logging.DEBUG) | |
logger.debug("this is an debug message") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def login(email, password, base_url='https://courses.edx.org'): | |
"""Login via HTTP and parse sessionid from the cookie.""" | |
r = requests.get('{}/login'.format(base_url)) | |
csrf = r.cookies['csrftoken'] | |
payload = {'email': email, 'password': password} | |
cookies = {'csrftoken': csrf} | |
headers = {'referer': '{}/login'.format(base_url), 'X-CSRFToken': csrf} | |
r = requests.post('{}/user_api/v1/account/login_session/'.format(base_url), | |
data=payload, cookies=cookies, headers=headers) | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
from student.models import UserProfile | |
profileless = [user for user in User.objects.all() if not UserProfile.objects.filter(user=user).count()] |
OlderNewer