user.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2015 Airbus
00004 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #   http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
00017 
00018 
00019 import rospy
00020 from privilege import Privilege
00021 import base64
00022 
00023 ## @class User
00024 ## @brief Class for difine the user informations.
00025 class User(object):
00026     
00027     UNKNOWN = 'Unknown'
00028     NONE    = UNKNOWN
00029     DEFAULT_LNG = 'en'
00030     
00031     def __init__(self, userid = None, privilege = Privilege.NONE):
00032         
00033         self.userid    = userid or ''
00034         self.created   = ''
00035         self.modified  = ''
00036         self.connected = ''
00037         self.privilege = privilege
00038         self.password  = ''
00039         self.encoded   = False
00040         self.language  = self.DEFAULT_LNG
00041         
00042         if userid is not None:
00043             self.connected = rospy.get_time()
00044         
00045     def init(self, userid, privilege):
00046         self.connected = rospy.get_time()
00047         self.userid    = userid
00048         self.privilege = privilege
00049         
00050     def setUserId(self, user_id):
00051         self.userid = user_id
00052         
00053     def getUserId(self):
00054         return self.userid
00055     
00056     def setUserPrivilege(self, privilege):
00057         self.privilege = privilege
00058     
00059     def getUserPrivilege(self):
00060         return self.privilege
00061     
00062     def setUserLanguage(self, lng):
00063         self.language = lng
00064         
00065     def getUserLanguage(self):
00066         return self.language
00067     
00068     def whenCreated(self):
00069         return self.created
00070     
00071     def getWhenUserModified(self):
00072         return self.created
00073     
00074     def getUserSinceConnected(self):
00075         return self.connected
00076         
00077     def setUserPassword(self, password, encode = True):
00078         
00079         if encode:
00080             self.password = base64.b64encode(password)
00081         else:
00082             self.password = password
00083             
00084         self.encoded = encode
00085         
00086     def getUserPassword(self, decode = False):
00087         
00088         if decode:
00089             return base64.b64decode(self.password)
00090         else:
00091             return self.password
00092         
00093     def __str__(self):
00094         return 'User[%s,%s]'%(self.userid, Privilege.TOSTR[self.privilege]) 
00095     
00096 #End of file
00097 


airbus_cobot_gui
Author(s): Martin Matignon
autogenerated on Thu Jun 6 2019 17:59:19