Package rhnpush :: Module rhnpush_cache
[hide private]
[frames] | no frames]

Source Code for Module rhnpush.rhnpush_cache

 1  # 
 2  # Copyright (c) 2008--2016 Red Hat, Inc. 
 3  # 
 4  # This software is licensed to you under the GNU General Public License, 
 5  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 6  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 8  # along with this software; if not, see 
 9  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
10  # 
11  # Red Hat trademarks are not licensed under GPLv2. No permission is 
12  # granted to use or replicate Red Hat trademarks that are incorporated 
13  # in this software or its documentation. 
14  # 
15  # rhnpush_cache.py 
16  # 
17  # Classes that control the caching of usernames and passwords, 
18  # along with the retrieval of the username and password. 
19  # 
20  # UserInfo - Instantiations of this class are pickled. 
21  #            Cache won't be valid after a certain amount of time. 
22  # 
23  # CacheManager - Controls access to the cache. 
24   
25  import os 
26  from rhnpush import utils 
27   
28  # This is the class that contains the session. 
29   
30   
31 -class RHNPushSession:
32
33 - def __init__(self):
34 self.location = os.path.join(utils.get_home_dir(), ".rhnpushcache") 35 self.session = None
36
37 - def setSessionString(self, session):
38 self.session = session
39
40 - def getSessionString(self):
41 return self.session
42
43 - def readSession(self):
44 sessionfile = open(self.location, "r") 45 self.session = sessionfile.read() 46 sessionfile.close()
47
48 - def writeSession(self):
49 sessionfile = open(self.location, "w") 50 sessionfile.write(self.session) 51 sessionfile.close()
52