• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python session.Session类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中session.Session的典型用法代码示例。如果您正苦于以下问题:Python Session类的具体用法?Python Session怎么用?Python Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: prepSimProfile

 def prepSimProfile(self):
     """
         Prepare data and create User Sessions (to be simulated). 
         each of them will wait for the start signal.
     """
     # @todo: implement a mechanism to load and use other types of RAS (from ras_type.py)
     self.__ras_obj = MikrotikRas(self.__sim_profile.nas_id,
                                  self.__sim_profile.nas_ip,
                                  self.__sim_profile.radius_secret, 
                                  self.__sim_profile.aaa_server_ip)
     
     # @todo: we better save and keep track of the used IP
     ips = []
     for ip in IPy.IP( self.__sim_profile.user_ips ):
         if str(ip).endswith("0") or "255" in str(ip):
             continue
         ips.append( str(ip) )
     
     for i in xrange( self.__sim_profile.total_sessions ):
         session_type = random.choice( self.__sim_profile.session_types )
         self.__start_sessions[ session_type ] = 1 + self.__start_sessions.get(session_type, 0)
         username, password = self.__genUserPass(i)
         sess = Session(session_type, self.__ready_event,
                  username, password,
                  ips.pop(0), self.__ras_obj)
         
         sess.start()
         self.__sessions.append(sess)
开发者ID:vnvo,项目名称:rasd,代码行数:28,代码来源:sim_manager.py


示例2: get_responses

  def get_responses(self, id_=1):
    session = Session()
    bbs = session.query(BBS).filter(BBS.id == id_).one()

    responses = [ res.toDict() for res in bbs.responses]
    responses.reverse()
    return responses
开发者ID:kouki-dan,项目名称:ShootingStarChecker,代码行数:7,代码来源:BBSHandler.py


示例3: AppDelegate

class AppDelegate(NSObject):
  def applicationDidFinishLaunching_(self, app):
    self.session = None
    self.init_status_bar()
    self.init_menu()

  def init_status_bar(self):
    self.status_bar = NSStatusBar.systemStatusBar()
    self.status_item = self.status_bar.statusItemWithLength_(NSVariableStatusItemLength)
    self.status_item.setHighlightMode_(1)

    icon = NSImage.alloc().initWithContentsOfFile_('icon.png')
    self.status_item.setImage_(icon)

  def init_menu(self):
    self.menu = NSMenu.alloc().init()
    self.menu_item_start = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Start', 'start:', '')
    self.menu.addItem_(self.menu_item_start)
    menu_item_quit = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'terminate:', '')
    self.menu.addItem_(menu_item_quit)
    self.status_item.setMenu_(self.menu)

  def start_(self, notification):
    if self.session != None:
      self.session.stop()
    self.session = Session()
    self.session.start()
开发者ID:pilu,项目名称:bloody-mary,代码行数:27,代码来源:app_delegate.py


示例4: post

 def post(self):
     username = self.get_argument("username", "")
     password = self.get_argument("password", "")
     error_messages = list()
     if username == "" or password == "":
         error_messages.append("参数不能为空")
         self.render("login.html", error_messages=error_messages, username="")
         return
     user = self.db.get("SELECT * FROM accounts WHERE username = %s", username)
     if user is None:
         error_messages.append("用户名密码错误")
         self.render("login.html", error_messages=error_messages, username=username)
         return
     if user["status"] == 0:
         error_messages.append("帐户没有开通")
         self.render("login.html", error_messages=error_messages, username=username)
         return
     password_generator = UserPassword()
     password_hash = password_generator.generate_hash(password, user["password_salt"])
     if password_hash != user["password_hash"]:
         error_messages.append("用户名密码错误")
         self.render("login.html", error_messages=error_messages, username=username)
         return
     session = Session(self.settings["session_secretSid"], self.settings["session_secretEid"], self.settings["session_expired"])
     if session.encode(user["id"]) is False:
         error_messages.append("用户数据错误")
         self.render("login.html", error_messages=error_messages, username=username)
         return
     sid = session.getSid()
     eid = session.getEid()
     self.set_secure_cookie("sid", sid, None)
     self.set_secure_cookie("eid", eid, None)
     self.redirect(self.get_argument("next", "/"))
开发者ID:chenshu,项目名称:ims,代码行数:33,代码来源:server.py


示例5: command_start

def command_start(bot, update):
    chat_id = update.message.chat_id
    if chat_id not in SESSIONS.keys():
        messenger = Messenger(bot, logger)
        SESSIONS[chat_id] = Session(chat_id, config_instance, logger)
        SESSIONS[chat_id].set_messenger(messenger)
        SESSIONS[chat_id].quiz = Quiz(SESSIONS[chat_id])
开发者ID:,项目名称:,代码行数:7,代码来源:


示例6: get

    def get(self):
        if 'pairing' in self.request.arguments:
            key = self.get_argument('pairing')
            # validate pairing key

            if 'type' in self.request.arguments:
                if 'session' in self.request.arguments:
                    session = Session.get(self.get_argument('session'))
                    if session:
                        if self.get_argument('type') == 'update':
                            self.writeout( session.get_update() )
                        elif self.get_argument('type') == 'function':
                            queries = self.get_argument('queries')
                            qargs = json.loads(queries)
                            args = [urllib.unquote(arg) for arg in qargs]
                            decoded = [decode_func_args(a) for a in args]
                            for fnargs in decoded:
                                self.writeout( session.handle_function(fnargs) )
                                return
                        else:
                            self.writeout( { 'no':'huh' } )
                        # validate session
                        #self.writeout( [ {'add': {'btapp':{'torrent':{'aotheu':{'hello':23}}}} } ] )
                    else:
                        self.set_status(404)
                else:
                    #logging.info('no session id in args -- %s, %s' % (self.request.uri, self.request.arguments))
                    session = Session.create(Client.instances[0])
                    self.writeout( {'session':session.id} )
            else:
                self.writeout( { 'hey':'whatup' } )
        else:
            self.set_status(403)
开发者ID:kzahel,项目名称:ktorrent,代码行数:33,代码来源:frontend.py


示例7: killProcess

def killProcess(agent, user, password, pid):
    s = Session(agent, service="ProcessStop")
    s.authorize(user, password)

    response = s.doRequest(attributes={"PID" : str(pid)})

    return int(ElementTree.fromstring(response).get("ExitCode"))
开发者ID:DukeNuoDB,项目名称:nuodb-python,代码行数:7,代码来源:util.py


示例8: get

 def get(self):
     username = self.request.get("user")
     password = self.request.get("password")
     
     self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
     
     if not username or not password:
         # some fields were missing in the request
         self.response.write(json_error('invalid', ''))
     else:
         # check if username exists in db
         query_user = User.query(User.username == username).fetch()
         if query_user:
             # check if password is correct
             query = User.query(ndb.AND(User.username == username, User.pswd == password)).fetch()
             if query:
                 # generate 64 char session cookie and send it back
                 cookie = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(64))
                 session = Session(cookie = cookie, user = username)
                 session.put()
                 self.response.write(login_response('ok', cookie))   
             else: 
                 # password was incorrect
                 self.response.write(json_error('failure', 'password'))
         else:
             # user didn't exist
             self.response.write(json_error('failure', 'user'))
开发者ID:tuvior,项目名称:WhatsFree,代码行数:27,代码来源:login.py


示例9: on_finish

 def on_finish(self):
     try:
         self.session.commit()            
     except Exception as e:
         self.session.rollback()
         import traceback
         logging.critical('Transaction needed to be rolled back because of: \n %s' % traceback.format_exc() )
     Session.remove()
开发者ID:gmacleod,项目名称:beautytube,代码行数:8,代码来源:base.py


示例10: __call__

 def __call__(self, environ, start_response):
     sc = SimpleCookie()
     if 'HTTP_COOKIE' in environ:
         sc.load(environ.get('HTTP_COOKIE'))
     ses = Session(ExpressSession(sc))
     ses.read()
     environ['express.session'] = ses
     return self.app(environ, start_response)
开发者ID:adcurrenday,项目名称:decanter,代码行数:8,代码来源:middleware.py


示例11: login

 def login(self, password):
     if self.password == password:
         current_session = Session(player_id=self.player_id)
         current_session.start_session()
         self.sessions.append(current_session)
         print("Player {} has logged in".format(self.name))
     else:
         print("Password error. Try again.")
开发者ID:RubashkoM,项目名称:homework,代码行数:8,代码来源:player.py


示例12: query

    def query(self, query_type, msg_body=None):
        session = Session(self.peer.connect_str, service="Manager")
        session.authorize(self.peer.domain.user, self.peer.domain.password)
        pwd_response = session.doRequest(attributes={"Type": "GetDatabaseCredentials", "Database": self.database.name})

        pwd_xml = ElementTree.fromstring(pwd_response)
        pwd = pwd_xml.find("Password").text.strip()

        return queryEngine(self.address, self.port, query_type, pwd, msg_body)
开发者ID:jgetto,项目名称:nuodb-python,代码行数:9,代码来源:entity.py


示例13: __init__

    def __init__(self, host, port, service='SQL2'):
        """Constructor for the EncodedSession class."""
        Session.__init__(self, host, port=port, service=service)
        self.doConnect()

        self.__output = None
        self.__input = None
        self.__inpos = 0
        self.closed = False
开发者ID:princeirmal,项目名称:nuodb-python,代码行数:9,代码来源:encodedsession.py


示例14: execute

    def execute(self, session: Session, args: Dict[str, Any]) -> ExitCode:
        data_to_remove = get_data_to_remove(session)

        data = args['data']
        args['data'] = deque(filterfalse(lambda x: x == data_to_remove, data))

        session.get_io().output('Removed {} data points'.format(len(data) - len(args['data'])))

        return ExitCode.SUCCESS
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:9,代码来源:deletealloccourrencescommand.py


示例15: get_data_points_per_line

def get_data_points_per_line(session: Session) -> int:
    while True:
        data_points_per_line = get_integer_from_user(session, 'How many data points per line should be outputted: ')
        if data_points_per_line <= 0:
            session.get_io().output('Your input must be greater than zero, instead got {}'.format(str(data_points_per_line)))
            time.sleep(1)
            session.clear()
            continue
        return data_points_per_line
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:9,代码来源:dataprintingcommand.py


示例16: retrieve_data_point_count

def retrieve_data_point_count(session: Session) -> int:
    while True:
        data_point_count = get_integer_from_user(session, 'How many data points do you want to create: ')
        if data_point_count <= 0:
            session.get_io().output('Your input must be greater than zero, instead got {}'.format(str(data_point_count)))
            time.sleep(1)
            session.clear()
            continue
        return data_point_count
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:9,代码来源:datainitializationcommand.py


示例17: query

    def query(self, type, msgBody=None):
        s = Session(self.getPeer().getConnectStr(), service="Manager")
        s.authorize(self.getPeer().getDomain().getUser(), self.getPeer().getDomain().getPassword())
        pwdResponse = s.doRequest(attributes={"Type": "GetDatabaseCredentials", "Database": self.getDbName()})

        pwdXml = ElementTree.fromstring(pwdResponse)
        pwd = pwdXml.find("Password").text.strip()

        return queryEngine(self.getAddress(), self.getPort(), type, pwd, msgBody)
开发者ID:princeirmal,项目名称:nuodb-python,代码行数:9,代码来源:entity.py


示例18: SocketHandler

class SocketHandler(tornado.websocket.WebSocketHandler):
    def open(self):
        logging.info("Connected: websocket")
        self.device = 'web'
        self.session = Session(self, world)
        self.session.start()

    def on_message(self, message):
        dispatch(self.session, message.strip())
开发者ID:trentonstrong,项目名称:easymud,代码行数:9,代码来源:server.py


示例19: main

def main():
    from pprint import pprint
    from sys import argv
    s = Session()
    s.login(argv[1], argv[2])

    f = Forum(s)
    pprint(f.get_hot())
    pprint(f.get_thread(argv[3]))
开发者ID:hghwng,项目名称:byrevealed,代码行数:9,代码来源:forum.py


示例20: execute

    def execute(self, session: Session, args: Dict[str, Any]) -> ExitCode:
        data_to_remove = get_data_to_remove(session)

        try:
            args['data'].remove(data_to_remove)
            session.get_io().output('Removed the first instance of data point "{}"'.format(data_to_remove))
        except ValueError:
            session.get_io().error('Data point "{}" is not present in the data store!'.format(data_to_remove))

        return ExitCode.SUCCESS
开发者ID:notfoundry,项目名称:PyMenuArchitect,代码行数:10,代码来源:deletefirstoccurrencecommand.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python session_csrf.monkeypatch函数代码示例发布时间:2022-05-27
下一篇:
Python session.get_session函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap