def save(self): username = self.cleaned_data['username'] password = self.cleaned_data['password1'] cass.save_user(username, { 'password': password, }) return username
def handle(self, *args, **options): # Oldest account is 10 years origin = int(time.time() + datetime.timedelta(days=365.25 * 10).total_seconds() * 1e6) now = int(time.time() * 1e6) num_users = int(args[0]) max_tweets = int(args[1]) # Generate number of tweets based on a Zipfian distribution sample = [random.paretovariate(15) - 1 for x in range(max_tweets)] normalizer = 1 / float(max(sample)) * max_tweets num_tweets = [int(x * normalizer) for x in sample] for i in range(num_users): username = self.get_random_string() cass.save_user(username, {'password': self.get_random_string()}) creation_date = random.randint(origin, now) for _ in range(num_tweets[i % max_tweets]): cass.save_tweet(str(uuid.uuid1()), username, { 'username': username, 'body': self.get_tweet(), }, timestamp=random.randint(creation_date, now))
def save(self): user_id = str(uuid.uuid1()) username = self.cleaned_data['username'] password = self.cleaned_data['password1'] cass.save_user(user_id, { 'id': user_id, 'username': username, 'password': password, }) return user_id
def user(val): stat ={} #print 'in user(), val is ',val match= val.split(' ',2) password= match[2].split('\n',1) stat['actual_name']=match[1][1:-1] stat['password']=password[0][1:-1] #print 'actual name is:',match[0] cass.save_user(match[0],stat)
def user_frnd_post(name): #print "in function" file = open('file.txt', 'r') for line in file: #print "line is:",line match = line.split(' ', 1) #print match[0],"------->",match[1] if match: if not match[0] in 'photo': #print"in not photo- extracted:",match[0] if match[0] in 'user': #print "in user" stat= {} MATCH= match[1].split(' ',1) NEW=MATCH[1].split('"',4) #print NEW password= NEW[3] stat['actual_name']=NEW[1] stat['password']=password #print 'actual name is:',NEW[1] #print 'password is:',password #print 'user name is:',MATCH[0] cass.save_user(MATCH[0],stat) if match[0] in 'wallpost': stat1 ={} #print 'in wallpost(), val is ',val MATCH= match[1].split(' ',1) #print 'user is',MATCH[0] post= MATCH[1].split('\n',1) stat1['body']=post[0][1:-1] #print 'body is:',stat1['body'] cass.save_post(MATCH[0],stat1) else: MATCH= match[0].split(' ',1) cass.add_friend(match[0],match[1][0:-1])
def handle(self, *args, **options): # Oldest account is 10 years origin = int( time.time() + datetime.timedelta(days=365.25 * 10).total_seconds() * 1e6) now = int(time.time() * 1e6) num_users = int(args[0]) max_tweets = int(args[1]) # Generate number of tweets based on a Zipfian distribution sample = [random.paretovariate(15) - 1 for x in range(max_tweets)] normalizer = 1 / float(max(sample)) * max_tweets num_tweets = [int(x * normalizer) for x in sample] for i in range(num_users): username = self.get_random_string() cass.save_user(username, self.get_random_string()) creation_date = random.randint(origin, now) for _ in range(num_tweets[i % max_tweets]): cass.save_tweet(uuid.uuid1(), username, self.get_tweet(), timestamp=random.randint(creation_date, now)) print "created user"
def create_users(): for user in USERS: save_user(user, "qwerty")
def save(self): username = self.cleaned_data['username'] password = make_password(self.cleaned_data['password1']) cass.save_user(username, password) return username
def save(self): username = self.cleaned_data["username"] password = self.cleaned_data["password1"] cass.save_user(username, {"password": password}) return username