Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 108 lines (84 sloc) 3.457 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
'''
Created on Nov 11, 2011

@author: clarkmatthew
'''
import random,string, time
#import eulogger
#logger = eulogger.Eulogger()
#log = logger.log


##########################################################################################
##########################################################################################

class Euwebuser(object):
    
    
    def __init__ (self,
                  account="",
                  user="",
                  passwd="",
                  credpath="",
                  email = "",
                  prefix="",
                  path="",
                  uid="",
                  enabled="",
                  regstatus="",
                  makerandom=True):
        
            print "Init euwebuser...."
            print("creating user...")
            #If the ID is not provided use the username, if the user is not provided create a random one
            self.account = account
            self.user = user
            self.passwd = passwd
            self.credpath = credpath
            self.email = email
            self.prefix = prefix
            self.path = path
            self.id = uid
            self.enabled = enabled
            self.status = regstatus
            self.rid = "NA"
            
            if (makerandom == True):
                try:
                    rand = random.Random()
                    time.sleep(1)# just to make sure seed is unique
                    self.rid = str(rand.randint(1, 100000000))
                except Exception, e:
                    print "Couldn't gen random id use time.clock instead:" + str(e)
                    rid = str(time.clock())
                
                #UID should be created by the CLC not the user
                self.id = uid
                    
                if (account != ""):
                    if (account == "random"):
                        self.account = prefix+"account-"+self.rid
                    else:
                        self.account = account
                else:
                    self.account = prefix+"account-"+self.rid
                
                if (user):
                    if (user == "random"):
                        self.user = prefix+self.rid
                    else:
                        self.user = user
                else:
                    self.user = "admin"
                
                if (passwd):
                    self.passwd = passwd
                else:
                    self.passwd = "passwd"+self.rid
                
                if (credpath):
                    self.credpath = credpath
                else:
                    self.credpath = self.user+"_dir"
                    
                if (email):
                    self.email = email
                else:
                    self.email = self.user+'@'+self.account
                
            
                             
    def printUser(self):
        print("+++++++++++++PRINT USER+++++++++++++++++++++")
        print("id:"+self.id)
        print("account:"+self.account)
        print("user:"+self.user)
        print("passwd:"+self.passwd)
        print("credpath:"+self.credpath)
        print("email: " +self.email)
        print("enabled:"+self.enabled)
        print("regstat:"+self.status)
        print("++++++++++++++++++++++++++++++++++++++++++++")
        
        
        
        
        
        
        
Something went wrong with that request. Please try again.