コード例 #1
0
 def __init__(self, question, request):
     self.question = question
     self.given_answer = request.GET.get('answer', '').strip()
     self.given_result = request.GET.get('result', '').strip()
     self.correct = self.given_result == self.question.result and\
         (self.question.result != 'OK' or self.given_answer == self.question.answer.strip())
     self.ip = get_client_ip(request)
コード例 #2
0
ファイル: answer.py プロジェクト: CloudyTrees/cppquiz
 def __init__(self, question, request):
     self.question = question
     self.given_answer = request.REQUEST.get('answer', '').strip()
     self.given_result = request.REQUEST.get('result', '').strip()
     self.correct = self.given_result == self.question.result and\
         (self.question.result != 'OK' or self.given_answer == self.question.answer.strip())
     self.ip = get_client_ip(request)
コード例 #3
0
ファイル: SinaVendor.py プロジェクト: rlcjj/sinalevel2
 def __init__(self, username=None, pwd=None):
     Vendor.__init__(self)
     if (username is None):
         if "sinaUsername" in config.keys():
             self.username = config["sinaUsername"]
         else:
             self.username = input(u'请输入新浪登录帐号:')
     else:
         self.username = username
     if (pwd is None):
         if "sinaPassword" in config.keys():
             self.pwd = config["sinaPassword"]
         else:
             self.pwd = getpass.getpass(u"输入登录密码(密码不会显示在屏幕上,输入后按回车确定):")
     else:
         self.pwd = pwd
     self.rsa_pubkey = '10001'
     self.ip = util.get_client_ip()
     self.session = requests.Session()
     self.quote = None
     self.is_login = False
     self.logger.info(u"正在从新浪获取全市场代码")
     try:
         self.symbols = self.get_symbols()
     except Exception as e:
         self.logger.warning(e)
コード例 #4
0
 def __init__(self, request: request, action: str):
     payload = request.form.get("__payload")
     self.args = dict(request.args)
     self.headers = request.headers
     self.json: dict = loads(payload) if payload is not None else {}
     self.action = action or ""
     self.client_ip = get_client_ip(request.headers, request.remote_addr)
     self.method = request.method
     self.origin = request.form.get("x-halocrypt-origin")
コード例 #5
0
ファイル: app.py プロジェクト: PalD777/halocrypt-core
def ip_addr():
    return json_response({
        "inferred_ip":
        get_client_ip(request.headers, request.remote_addr),
        "remote_addr":
        request.remote_addr,
        "x-fwd":
        request.headers.get("x-forwarded-for"),
    })
コード例 #6
0
ファイル: quiz_in_progress.py プロジェクト: knatten/cppquiz
 def answer(self, request):
     debug_string = "IP:%s, quiz:%s, result:%s, answer:%s, answers:%d" %\
         (util.get_client_ip(request), self.quiz.key, request.GET.get('result', ''), request.GET.get('answer', ''), len(self.answers))
     logging.getLogger('quiz').debug(debug_string)
     answer = Answer(self.get_current_question(), request)
     answer.register_given_answer()
     if answer.correct:
         self.answers.append(QuestionStats(attempts=self.attempts, used_hint=self.used_hint))
         self._reset_question_state()
         self.previous_result = 'correct'
         self.previous_explanation = answer.question.explanation
     else:
         self.previous_result = 'incorrect'
         self.attempts += 1
     debug_string = "IP:%s, quiz:%s, question:#%d (%d/%d), given_result:%s, given_answer:%s, correct:%s" % \
         (answer.ip, self.quiz.key, answer.question.pk, len(self.answers), self.quiz.questions.count(), answer.given_result, answer.given_answer, answer.correct)
     logging.getLogger('quiz').debug(debug_string)
     return
コード例 #7
0
 def answer(self, request):
     debug_string = "IP:%s, quiz:%s, result:%s, answer:%s, answers:%d" %\
         (util.get_client_ip(request), self.quiz.key, request.GET.get('result', ''), request.GET.get('answer', ''), len(self.answers))
     logging.getLogger('quiz').debug(debug_string)
     answer = Answer(self.get_current_question(), request)
     answer.register_given_answer()
     if answer.correct:
         self.answers.append(
             QuestionStats(attempts=self.attempts,
                           used_hint=self.used_hint))
         self._reset_question_state()
         self.previous_result = 'correct'
         self.previous_explanation = answer.question.explanation
     else:
         self.previous_result = 'incorrect'
         self.attempts += 1
     debug_string = "IP:%s, quiz:%s, question:#%d (%d/%d), given_result:%s, given_answer:%s, correct:%s" % \
         (answer.ip, self.quiz.key, answer.question.pk, len(self.answers), self.quiz.questions.count(), answer.given_result, answer.given_answer, answer.correct)
     logging.getLogger('quiz').debug(debug_string)
     return
コード例 #8
0
    def user_details(*args,**kwargs):
        # Before
        request = args[0]
        url = request.build_absolute_uri()
        ip = util.get_client_ip(request)
        log = "#"*100 + "\n"
        log += "From => " + str(ip) + "\n"
        log += "URL => " + str(url)
        log += '\nRequest Params => '
        for key,value in request.POST.items():
            log += key + " : " + value + ", "

        # Main
        response = func(*args,**kwargs)

        # After
        log += "\nResponse => " + str(response)
        log += "\n" + "#" * 100
        util.init_logger()
        util.logger.info(log)
        return response
コード例 #9
0
 def __init__(self,
              name=None,
              username=None,
              pwd=None,
              symbols=None,
              hq='hq_pjb',
              query=['quotation', 'orders', 'deal', 'info'],
              **kwargs):
     Producer.__init__(self, name=name, **kwargs)
     self.ip = util.get_client_ip()
     self.hq = hq
     self.query = query
     # 登录模块在V('Sina')中
     self.sina = V('Sina')
     self.is_login = self.login()
     if not self.is_login:
         self.logger.error(u'登录失败,请核对账号和密码')
         sys.exit(-1)
     if symbols is None:
         self.symbols = self.sina.get_symbols()
     else:
         self.symbols = symbols
     self.websockets = dict()
コード例 #10
0
ファイル: quiz_in_progress.py プロジェクト: knatten/cppquiz
 def is_finished(self, request):
     debug_string = "IP:%s, quiz:%s, is finished? (%d/%d/%d)" % \
         (util.get_client_ip(request), self.quiz.key, self.nof_answered_questions(), len(self.answers), self.quiz.questions.count())
     logging.getLogger('quiz').debug(debug_string)
     return self.quiz.questions.count() == self.nof_answered_questions()
コード例 #11
0
 def is_finished(self, request):
     debug_string = "IP:%s, quiz:%s, is finished? (%d/%d/%d)" % \
         (util.get_client_ip(request), self.quiz.key, self.nof_answered_questions(), len(self.answers), self.quiz.questions.count())
     logging.getLogger('quiz').debug(debug_string)
     return self.quiz.questions.count() == self.nof_answered_questions()