當前位置: 首頁>>代碼示例>>Python>>正文


Python Session.Session類代碼示例

本文整理匯總了Python中Session.Session的典型用法代碼示例。如果您正苦於以下問題:Python Session類的具體用法?Python Session怎麽用?Python Session使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Session類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: openSession

 def openSession(self):
     session = Session()
     session.exec()
     if session.ret:
         if session.new:
             self.onBtnLoadRef()
         else:
             print(session.sel)
開發者ID:HenricusRex,項目名稱:TMV3,代碼行數:8,代碼來源:Viewer.py

示例2: testInsert

 def testInsert(self):
     sdao = SessionDAO()
     session = Session()
     session.startDate = '2009-10-10' 
     session.lastUpdate = '2009-10-10' 
     session.source.id = self.sourceId
     session.file.id = self.fileId
     session.address.id = self.addressId
     sid = sdao.insert(session)
     assert sid != -1, 'error inserting session'
開發者ID:tassia,項目名稱:DonkeySurvey,代碼行數:10,代碼來源:SessionTestCase.py

示例3: do_HEAD

	def do_HEAD(self, method = 'get', postData = {}):
		self.session = Session.load(Session.determineKey(self))
		self.processingRequest()

		try:
			self.buildResponse(method, postData)
			self.sendHead()
		except Redirect as r:
			self.responseCode = 302
			self.response = ''
			self.sendHead(additionalHeaders = {'Location': r.target})
開發者ID:mrozekma,項目名稱:Rorn,代碼行數:11,代碼來源:HTTPHandler.py

示例4: getHeatMapSessions

	def getHeatMapSessions(self,_json=True):
		_h = []
		_e = []
		_t = []
		_nSessions = 0 
		_x = 0
		for _folder in reversed(os.listdir(self._dataFolder)):
			for _device in self.devices:
				if _device in _folder: #get only the folders from his/her device
					_file = self._dataFolder + _folder 
					_d = Session(_file)
					_mdata = _d.getMetaDataOnly()
					_avgHR = _mdata["session"]["statistics"]["HR_avg"]
					_avgEDA = _mdata["session"]["statistics"]["EDA_avg"]
					_avgTEMP = _mdata["session"]["statistics"]["TEMP_avg"]
					_HM_HR= {}
					_HM_EDA= {}
					_HM_TEMP= {}
					if(_avgHR > 90):
						_HM_HR["sessionId"] = _folder 
						_HM_HR["date"] = int(_folder[:-7])
						_HM_HR["value"] = 60 + _x #silly hack to get links on the heatmap
					else:
						_HM_HR["sessionId"] = _folder 
						_HM_HR["date"] = int(_folder[:-7])
						_HM_HR["value"] = 2 + _x 
					print _HM_HR
					_h.append(_HM_HR)
					if(_avgEDA > 5):
						_HM_EDA["sessionId"] = _folder 
						_HM_EDA["date"] = int(_folder[:-7])
						_HM_EDA["value"] = 60 + _x 
					else:
						_HM_EDA["sessionId"] = _folder 
						_HM_EDA["date"] = int(_folder[:-7])
						_HM_EDA["value"] = 2+ _x 
					_e.append(_HM_EDA)
					if(_avgTEMP > 37.5):
						_HM_TEMP["sessionId"] = _folder 
						_HM_TEMP["date"] = int(_folder[:-7])
						_HM_TEMP["value"] = 60+ _x 
					else:
						_HM_TEMP["sessionId"] = _folder 
						_HM_TEMP["date"] = int(_folder[:-7])
						_HM_TEMP["value"] = 2+ _x 
					_t.append(_HM_TEMP)
					_x +=1

		if(_json):
			return [json.dumps(_h),json.dumps(_e),json.dumps(_t)]
		else:
			return [_HM_HR,_HM_EDA,_HM_TEMP]
開發者ID:panzerfausten,項目名稱:empatica_assigment_app,代碼行數:52,代碼來源:Data.py

示例5: doTests

	def doTests(self,_json=True):
		#create a new session and call check to the last 5 sessions
		_results = []
		_resultJson = {"device_id":self.device,"tests":[]}
		for _x,_s in  enumerate(self._sessions):
			_se = Session(_s)
			_res = _se.checkSessionStatus()
			_results.append(_res)
			_resultJson["tests"].append(_res)
			if _x == 4:
				break
		if(_json):
			return json.dumps(_resultJson)
		else:
			return _results
開發者ID:panzerfausten,項目名稱:empatica_assigment_app,代碼行數:15,代碼來源:DeviceStatus.py

示例6: __init__

 def __init__(self, parent=None, callback=None):
     """
     @summary: Create new authentication dialog.
     @param parent: GtkWindow parent.
     """
     super(AuthDialog, self).__init__()
     
     self.__session__ = Session()
     
     super(AuthDialog, self).set_title(self.__trans__("Google Authentication"))
     super(AuthDialog, self).set_flags(gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
     super(AuthDialog, self).add_buttons(gtk.STOCK_OK, gtk.RESPONSE_OK)
     
     super(AuthDialog, self).set_transient_for(parent)
     if (parent != None):
         super(AuthDialog, self).set_position(gtk.WIN_POS_CENTER_ON_PARENT)
     else:
         super(AuthDialog, self).set_position(gtk.WIN_POS_CENTER)
     
     # Add signals
     super(AuthDialog, self).connect("response", self.__closeEvent__)
     super(AuthDialog, self).set_size_request(self.__DEFAULT_WINDOW_WIDTH__, self.__DEFAULT_WINDOW_HEIGHT__)
     
     self.__initUI__()
     self.__callback__ = callback
開發者ID:babytux,項目名稱:PyCamimg,代碼行數:25,代碼來源:AuthDialog.py

示例7: getSessions

	def getSessions(self,_json=True):
		_availableSessions = {"sessions":[],"count":0}
		_nSessions = 0 
		for _folder in reversed(os.listdir(self._dataFolder)):
			for _device in self.devices:
				if _device in _folder: #get only the folders from his/her device
					_file = self._dataFolder + _folder 
					_d = Session(_file)
					_availableSessions["sessions"].append(_d.getMetaDataOnly())
					_nSessions += 1
		_availableSessions["count"] = _nSessions

		if(_json):
			return json.dumps(_availableSessions)
		else:
			return _availableSessions
開發者ID:panzerfausten,項目名稱:empatica_assigment_app,代碼行數:16,代碼來源:Data.py

示例8: login

    def login(cls, para):
        if not checkPara(para, ['version', 'did', ('type', lambda x: x in [cls.DEVICE_TYPE, cls.FB_TYPE])]):
            return Error.INVALID_PARAM

        version = para['version']
        did = para['did']

        if para['type'] == cls.DEVICE_TYPE:
            (uid, is_new) = Login.device_login(did)
        else:
            if para['fb_id'] in para['frd_list']:
                return Error.INVALID_PARAM

            (uid, is_new) = Login.fb_login(did, para['fb_id'], para['fb_name'], para['frd_list'])

        sid = Session.gen_session(uid)
        ret = {'uid': uid, 'sid': sid}

        user_info = User(uid).get(['coin', 'level', 'exp', 'name'], True)
        user_info['exp'] /= 100

        ret.update(user_info)

        if version < Config.LATEST_VERSION:
            ret['update'] = Config.PKG_URL

        User(uid).login_time = int(time.time())

        if 'ip' in para:
            g = cls.GEO.city(para['ip'])
            Location.update(uid, g['country_code'], g['region'])

        return ret
開發者ID:,項目名稱:,代碼行數:33,代碼來源:

示例9: __init__

 def __init__(self,name,attrs={},logger=None,logpath='./'):
     self.sutname=name
     self.attrs=attrs        
     command = attrs.get('CMD')
     if not attrs.get('TIMEOUT'):
         self.attrs.update({'TIMEOUT':int(30)})
     else:
         self.attrs.update({'TIMEOUT':int(attrs.get('TIMEOUT'))})
     #spawn.__init__(self, command, args, timeout, maxread, searchwindowsize, logfile, cwd, env, ignore_sighup)
     import os
     log = os.path.abspath(logpath)
     log= '%s%s%s'%(log,os.path.sep,'%s.log'%name)
     if self.attrs.get('LOGIN'):
         from common import csvstring2array
         self.loginstep= csvstring2array(self.attrs['LOGIN'])
      
     self.seslog = open(log, "wb")
     CSession.__init__(self, name, attrs,logger, logpath)
開發者ID:try-dash-now,項目名稱:dash-ia,代碼行數:18,代碼來源:Cisco.py

示例10: button_click

 def button_click(self):
     global configWin
     global session
     global myapp
     global mail
     pop3Name=str(configWin.ui.lineEdit.text())
     smtpName=str(configWin.ui.lineEdit_2.text())
     userName=str(self.ui.lineEdit.text())
     passwd=str(self.ui.lineEdit_2.text())
     session=Session([pop3Name, smtpName, userName, passwd])
     resultcode=session.sessionLogin()
     if resultcode==0:
         lastaccount=[pop3Name, smtpName, userName, passwd]
         init.writein(lastaccount)
         mail=MyMail(session)
         myapp = MyMailBox()
         myapp.show()
         myapp.ui.menubar.addMenu(lastaccount[2]).addAction(myapp.ui.logout)
         self.close()
開發者ID:brightmood,項目名稱:pymail,代碼行數:19,代碼來源:test.py

示例11: initSession

	def initSession(self, phone, AESKey):
		print "Core.initSession called"
		if self.session == None or self.session.authStatus == Constants.AUTHSTATUS_IDLE:	#self.yowsupStarted==0 and 
			self.yowsupStarted = 1
			if self.session == None:
				self.session = Session(self, phone, AESKey)
				self.session.getAuthData()
				self.signalsInterface.registerListener("disconnected", self.onDisconnected) 
			self.session.login()
		else:
			print "\nPretty sure yowsup is already started."
開發者ID:akshayah3,項目名稱:webwhatsapp,代碼行數:11,代碼來源:Core.py

示例12: lock

    def lock(self, type=Constants.LockType_Shared):
        """Contextmanager yielding a session to a locked machine.

        Machine must be registered."""
        session = Session.create()
        with VirtualBoxException.ExceptionHandler():
            self.getIMachine().lockMachine(session.getISession(), type)
        try:
            session._setMachine(VirtualMachine(session.getIMachine()))
            yield session
        finally:
            session.unlockMachine(wait=True)
開發者ID:aburan28,項目名稱:pyVBox,代碼行數:12,代碼來源:VirtualMachine.py

示例13: folderAdd

        def folderAdd(self, folderObject):
                """
                        each time one adds a new FileWalker object it triggers 
                        a new session that is stored using the unique FileWalker 
                        name
                """
                if isinstance(folderObject, FileWalker):
                        
                        # clone list of classes and create new
                        thisSession = Session(folderObject.name, folderObject.path, self.classes)

                        # iterate over all files
                        thisSession.addFiles(folderObject)
                        
                        # append the completed session to the list
                        self.sessions.append(thisSession)

                        print "add Folder: %s" % folderObject.name

                else:
                        return NotImplemented
                return True
開發者ID:pombreda,項目名稱:PyFileClassParser,代碼行數:22,代碼來源:PyFileClassParser.py

示例14: __init__

 def __init__(self, credentials):
     self.credentials = credentials
     self.queue = RequestQueue(request_limit=600)
     self.session = Session(self.credentials, self.queue)
     self.all_endpoints = {'ticket':{'plural':'tickets', 'singular':'ticket'}, 
                         'organization':{'plural':'organizations', 'singular':'organization'},
                         'requester': {'plural':'users','singular':'user'},
                         'user': {'plural':'users','singular':'user'},
                         'assignee': {'plural':'users','singular':'user'}}
     self.object_cache = BasicCache()
     self.tickets = Endpoint('ticket', self)
     self.organizations = Endpoint('organization', self)
     self.users = Endpoint('user', self)
開發者ID:Nebopolis,項目名稱:pyzendesk,代碼行數:13,代碼來源:Wrapper.py

示例15: validate

  def validate(self, name, pwd):
    cur = self._conn.cursor()

    cur.execute("""
      SELECT users.id   as id
            ,users.name as name
            ,auth.hash  as pass
        FROM users
            ,auth
       WHERE users.id   = auth.user_id
         and users.name = '""" + name + """'
         and auth.hash  = '""" + pwd + """'
    """)

    numrows = cur.rowcount
    assert numrows in {0, 1}

    if numrows == 0:
      return None

    row = cur.fetchone()
    sess = Session()
    sess.set(row[0], row[1], 9999)
    return sess
開發者ID:cwbriscoe,項目名稱:pyweb,代碼行數:24,代碼來源:Auth.py


注:本文中的Session.Session類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。