当前位置: 首页>>代码示例>>Python>>正文


Python web.input方法代码示例

本文整理汇总了Python中web.input方法的典型用法代码示例。如果您正苦于以下问题:Python web.input方法的具体用法?Python web.input怎么用?Python web.input使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在web的用法示例。


在下文中一共展示了web.input方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: POST

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def POST(self):

        if not EXTRA_MODULES['onelogin']:
            header('X-Rucio-Auth-Token', None)
            return "SAML not configured on the server side."

        SAML_PATH = config_get('saml', 'config_path')
        request = ctx.env
        data = dict(param_input())
        req = prepare_webpy_request(request, data)
        auth = OneLogin_Saml2_Auth(req, custom_base_path=SAML_PATH)

        auth.process_response()
        errors = auth.get_errors()
        if not errors:
            if auth.is_authenticated():
                setcookie('saml-nameid', value=auth.get_nameid(), path='/') 
开发者ID:rucio,项目名称:rucio,代码行数:19,代码来源:authentication.py

示例2: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def GET(self):
        try:
            data = param_input()
            response = get(str(data.file_location), cert=config_get('webui', 'usercert'), verify=False)
            if not response.ok:
                response.raise_for_status()
            cont = response.content
            file_like_object = BytesIO(cont)
            tar = open(mode='r:gz', fileobj=file_like_object)
            jsonResponse = {}
            for member in tar.getmembers():
                jsonResponse[member.name] = member.size
            header('Content-Type', 'application/json')
            return dumps(jsonResponse)
        except ConnectionError as err:
            raise generate_http_error(503, str(type(err)), str(err))
        except TarError as err:
            raise generate_http_error(415, str(type(err)), str(err))
        except IOError as err:
            raise generate_http_error(422, str(type(err)), str(err))
        except Exception as err:
            raise generate_http_error(500, str(type(err)), str(err)) 
开发者ID:rucio,项目名称:rucio,代码行数:24,代码来源:main.py

示例3: userpass_auth

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def userpass_auth(data, rendered_tpl):
    """
    Manages login via Rucio USERPASS method.
    :param data: data object containing account, username and password string
    :param rendered_tpl: rendered page template
    :returns: final page or a page with an error message
    """
    if not data:
        return RENDERER.problem("No input credentials were provided.")
    else:
        # if user tries to access a page through URL without logging in, then redirect to login page.
        if rendered_tpl:
            return RENDERER.login(None)
        if hasattr(data, 'account') and data.account:
            ui_account = data.account
        else:
            ui_account = select_account_name(data.username, 'userpass')
        if not ui_account:
            return RENDERER.problem(('Cannot get find any account associated with %s identity.' % (html_escape(data.username))))
        token = get_token(auth.get_auth_token_user_pass, acc=ui_account, idt=data.username, pwd=data.password.encode("ascii"))
        if not token:
            return RENDERER.problem(('Cannot get auth token. It is possible that the presented identity %s is not mapped to any Rucio account %s.') % (html_escape(data.username), html_escape(ui_account)))
    return finalize_auth(token, 'userpass') 
开发者ID:rucio,项目名称:rucio,代码行数:25,代码来源:utils.py

示例4: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def GET(self, extension):
    i = web.input(seed=None)
    if i.seed is None:
      return "No seed specified"
    
    if not re.match("[a-z0-9-_]+", extension, re.IGNORECASE):
      return "Invalid extension"
    
    path = os.path.join(BASE_PATH, extension)
    if not os.path.exists(path) or not os.path.isdir(path):
      return "Extension not found"
    
    cmd = ["radamsa", "-r", path, "-s", i.seed]
    try:
      buf = check_output(cmd)
    except CalledProcessError as e:
      buf = e.output

    return buf 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:21,代码来源:radamsa_server.py

示例5: POST

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def POST(self):
    if not 'user' in session or session.user is None:
      f = register_form()
      return render.login(f)
    i = web.input(id=-1, sure="")
    if i.id == -1:
      return render.error("Invalid project identifier")
    elif i.sure != "on":
      return render.error("You must check the \"I'm sure\" field.")
    
    db = init_web_db()
    with db.transaction():
      vars={"project_id":i.id}
      where = "project_id=$project_id"
      db.delete("projects", where=where, vars=vars)
    return web.redirect("/projects") 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:18,代码来源:nightmare_frontend.py

示例6: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def GET(self):
    if not 'user' in session or session.user is None:
      f = register_form()
      return render.login(f)
    i = web.input(id=-1)
    if i.id == -1:
      return render.error("Invalid project identifier")
    
    db = init_web_db()
    what = "mutation_engine_id, name, description, command, date"
    where = "mutation_engine_id = $id"
    vars = {"id":i.id}
    res = db.select("mutation_engines", what=what, where=where, vars=vars)
    res = list(res)
    if len(res) == 0:
      return render.error("Invalid mutation engine identifier")
    return render.edit_mutation_engine(res[0])

#----------------------------------------------------------------------- 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:21,代码来源:nightmare_frontend.py

示例7: POST

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def POST(self):
		deviceId = str(web.input().get('devid'))
		try:
			devIndex = deviceId.split('USB')[1]
			cellLogshell = [sys.path[0]+"/osmocombb_x64/cell_log","-s","/tmp/osmocom_l2_"+ devIndex,"-O"];
			arfcnScan = subprocess.Popen(cellLogshell,stderr=subprocess.PIPE,stdout=subprocess.PIPE)
			scanlog = arfcnScan.communicate()
			arfcnScan.wait()
			scanloginfo = ";".join(scanlog)
			scanbase = re.findall(r"ARFCN\=[^)]+\)",scanloginfo)

			logfile = file(sys.path[0]+"/arfcn_"+ devIndex +".log","w+")
			for line in scanbase:
				logfile.write(str(line)+"\r\n")
			logfile.write('Date: '+GetCurrentTime())
			logfile.close()
		except Exception,e:
			return json.dumps({"res":-1,"msg":str(e)}) 
开发者ID:BG7YWL,项目名称:OsmocomBB_Raspberry-Pi_SMS_WEB_CODE,代码行数:20,代码来源:app.py

示例8: _delegate

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def _delegate(self, f, fvars, args=None):
        if args is None:
            args = [None]

        # load session
        if args[0] == "/@@":
            self._session.load('') # creates a new session
            raise web.redirect("/@" + self._session.session_id + "@"+web.ctx.fullpath[3:]) # redirect to the same page, with the new
            # session id
        elif args[0] is None:
            self._session.load(None)
        else:
            self._session.load(args[0][2:len(args[0])-1])

        # Switch language if specified
        input_data = web.input()
        if "lang" in input_data:
            self._session.language = input_data["lang"]
        elif "language" not in self._session:
            for lang in re.split("[,;]+", web.ctx.environ.get("HTTP_ACCEPT_LANGUAGE", "")):
                if lang in self._translations.keys():
                    self._session.language = lang
                    break

        return super(CookieLessCompatibleApplication, self)._delegate(f, fvars, args[1:]) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:27,代码来源:cookieless_app.py

示例9: API_POST

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def API_POST(self):  # pylint: disable=arguments-differ
        """
            Authenticates the remote client. Takes as input:

            login
                the INGInious account login

            password
                the associated password

            Response: a dict in the form {"status": "success"} (200 OK) or {"status": "error"} (403 Forbidden)
        """

        user_input = web.input()
        if "login" not in user_input or "password" not in user_input:
            raise APIInvalidArguments()

        try:
            if self.user_manager.auth_user(user_input["login"].strip(), user_input["password"]) is not None:
                    return 200, {"status": "success", "username": self.user_manager.session_username()}
        except:
            pass
        return 403, {"status": "error"} 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:25,代码来源:authentication.py

示例10: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def GET(self, *args, **kwargs):
        """
        Checks if user is authenticated and calls GET_AUTH or performs logout.
        Otherwise, returns the login template.
        """
        if self.user_manager.session_logged_in():
            if not self.user_manager.session_username() and not self.__class__.__name__ == "ProfilePage":
                raise web.seeother("/preferences/profile")

            if not self.is_lti_page and self.user_manager.session_lti_info() is not None: #lti session
                self.user_manager.disconnect_user()
                return self.template_helper.get_renderer().auth(self.user_manager.get_auth_methods())

            return self.GET_AUTH(*args, **kwargs)
        elif self.preview_allowed(*args, **kwargs):
            return self.GET_AUTH(*args, **kwargs)
        else:
            error = ''
            if "binderror" in web.input():
                error = _("An account using this email already exists and is not bound with this service. "
                          "For security reasons, please log in via another method and bind your account in your profile.")
            if "callbackerror" in web.input():
                error = _("Couldn't fetch the required information from the service. Please check the provided "
                          "permissions (name, email) and contact your INGInious administrator if the error persists.")
            return self.template_helper.get_renderer().auth(self.user_manager.get_auth_methods(), error) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:27,代码来源:utils.py

示例11: POST

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def POST(self, *args, **kwargs):
        """
        Checks if user is authenticated and calls POST_AUTH or performs login and calls GET_AUTH.
        Otherwise, returns the login template.
        """
        if self.user_manager.session_logged_in():
            if not self.user_manager.session_username() and not self.__class__.__name__ == "ProfilePage":
                raise web.seeother("/preferences/profile")

            if not self.is_lti_page and self.user_manager.session_lti_info() is not None:  # lti session
                self.user_manager.disconnect_user()
                return self.template_helper.get_renderer().auth(self.user_manager.get_auth_methods_fields())

            return self.POST_AUTH(*args, **kwargs)
        else:
            user_input = web.input()
            if "login" in user_input and "password" in user_input:
                if self.user_manager.auth_user(user_input["login"].strip(), user_input["password"]) is not None:
                    return self.GET_AUTH(*args, **kwargs)
                else:
                    return self.template_helper.get_renderer().auth(self.user_manager.get_auth_methods(), _("Invalid login/password"))
            elif self.preview_allowed(*args, **kwargs):
                return self.POST_AUTH(*args, **kwargs)
            else:
                return self.template_helper.get_renderer().auth(self.user_manager.get_auth_methods()) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:27,代码来源:utils.py

示例12: GET_AUTH

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def GET_AUTH(self, courseid):  # pylint: disable=arguments-differ
        """ GET request """
        course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=False)

        data = web.input()

        if "download" in data:
            filepath = os.path.join(self.backup_dir, courseid, data["download"] + '.zip')

            if not os.path.exists(os.path.dirname(filepath)):
                raise web.notfound()

            web.header('Content-Type', 'application/zip', unique=True)
            web.header('Content-Disposition', 'attachment; filename="' + data["download"] + '.zip' + '"', unique=True)

            return open(filepath, 'rb')

        else:
            return self.page(course) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:21,代码来源:danger_zone.py

示例13: GET_AUTH

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def GET_AUTH(self, courseid, groupid=''):  # pylint: disable=arguments-differ
        """ Edit a group """
        course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=True)

        if course.is_lti():
            raise web.notfound()

        if "download" in web.input():
            web.header('Content-Type', 'text/x-yaml', unique=True)
            web.header('Content-Disposition', 'attachment; filename="groups.yaml"', unique=True)
            groups = [{"description": group["description"],
                           "students": group["students"],
                           "size": group["size"],
                            "audiences": [str(c) for c in group["audiences"]]} for group in
                          self.user_manager.get_course_groups(course)]

            return yaml.dump(groups)

        return self.display_page(course) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:21,代码来源:group_edit.py

示例14: GET_AUTH

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def GET_AUTH(self, courseid):  # pylint: disable=arguments-differ
        """ GET request """
        course, __ = self.get_course_and_check_rights(courseid)
        user_input = web.input(tasks=[], aggregations=[], users=[])
        error = ""

        # First, check for a particular submission
        if "submission" in user_input:
            submission = self.database.submissions.find_one({"_id": ObjectId(user_input.submission),
                                                             "courseid": course.get_id(),
                                                             "status": {"$in": ["done", "error"]}})
            if submission is None:
                raise web.notfound()

            self._logger.info("Downloading submission %s - %s - %s - %s", submission['_id'], submission['courseid'],
                              submission['taskid'], submission['username'])
            archive, error = self.submission_manager.get_submission_archive(course, [submission], [])
            if not error:
                web.header('Content-Type', 'application/x-gzip', unique=True)
                web.header('Content-Disposition', 'attachment; filename="submissions.tgz"', unique=True)
                return archive

        # Else, display the complete page
        return self.display_page(course, user_input, error) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:26,代码来源:download.py

示例15: GET_AUTH

# 需要导入模块: import web [as 别名]
# 或者: from web import input [as 别名]
def GET_AUTH(self, courseid, taskid):  # pylint: disable=arguments-differ
        """ Edit a task """
        if not id_checker(taskid):
            raise Exception("Invalid task id")

        self.get_course_and_check_rights(courseid, allow_all_staff=False)

        request = web.input()
        if request.get("action") == "download" and request.get('path') is not None:
            return self.action_download(courseid, taskid, request.get('path'))
        elif request.get("action") == "delete" and request.get('path') is not None:
            return self.action_delete(courseid, taskid, request.get('path'))
        elif request.get("action") == "rename" and request.get('path') is not None and request.get('new_path') is not None:
            return self.action_rename(courseid, taskid, request.get('path'), request.get('new_path'))
        elif request.get("action") == "create" and request.get('path') is not None:
            return self.action_create(courseid, taskid, request.get('path'))
        elif request.get("action") == "edit" and request.get('path') is not None:
            return self.action_edit(courseid, taskid, request.get('path'))
        else:
            return self.show_tab_file(courseid, taskid) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:22,代码来源:task_edit_file.py


注:本文中的web.input方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。