def createFakePosts(): li = LoremIpsum() # find out how many users there are count = models.User.query.count() iterations = 100 for x in range(iterations): # get a random id within the range of the count user1Id = random.randint(0, count) #create a random string li = LoremIpsum() li.get_sentences(1+ x%2) entry = li.get_sentences(1+ x%2) print(entry) #entry = falseData.randomStringGenerator(x, x) #add it as a post #post_text, creator_id, date newPost = models.Post(entry, user1Id, datetime.datetime.now()) db.session.add(newPost) db.session.commit()
def main(): args = parse_args() r = redis.Redis(**config.REDIS_CREDS) li = LoremIpsum() sentences = [li.get_sentences(10) for i in range(100)] for sentence in sentences: r.set(str(uuid4()), sentence) log.info("Seeded 100 records to redis.")
def main(): args = parse_args() redis_creds = vcap.strip_redis_creds( vcap.creds('hsdp-redis-sentinel', tag=args.redis_tag)) r = redis.Redis(**redis_creds) li = LoremIpsum() sentences = [li.get_sentences(10) for i in xrange(100)] for sentence in sentences: r.set(str(uuid4()), sentence) print("Added 100 records to redis.")
def create_users(): word_url = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain" log.info("Getting words for random names...") words = requests.get(word_url).text.splitlines() upper_words = [word for word in words if word[0].isupper()] name_words = [ word.lower() for word in upper_words if not word.isupper() ] li = LoremIpsum() for name in name_words: u = models.Users(name=name, comments=[li.get_sentences(5) for i in range(10)]) db_session.add(u) db_session.commit() del upper_words del name_words
class Command(BaseCommand): def __init__(self): super(Command, self).__init__() self.rw = RandomWords() self.li = LoremIpsum() self.array_size = 2 def handle(self, *args, **options): tags = [] for i in xrange(20000): name = self.make_name() tag, created = Tag.objects.get_or_create(name=name) if created: tags.append(tag) print '{0} tags has been created.'.format(len(tags)) posts = [] tags_ids = Tag.objects.all().values_list('id', flat=True) if self.array_size < len(tags_ids): for i in xrange(100000): name = self.make_name() rand = random.sample(tags_ids, self.array_size) post, created = Post.objects.get_or_create( name=name, defaults={ 'tags': rand, 'description': self.li.get_sentences(5), } ) if created: posts.append(post) print '{0} posts has been created.'.format(len(posts)) else: print 'Please generate more tags than {0}.'.format(self.array_size) def make_name(self): name = self.rw.random_word().capitalize() name = '{0}{1}'.format(name, random.randint(1, 10)) return name
class Command(BaseCommand): def __init__(self): super(Command, self).__init__() self.rw = RandomWords() self.li = LoremIpsum() self.array_size = 2 def handle(self, *args, **options): tags = [] for i in xrange(20000): name = self.make_name() tag, created = Tag.objects.get_or_create(name=name) if created: tags.append(tag) print '{0} tags has been created.'.format(len(tags)) posts = [] tags_ids = Tag.objects.all().values_list('id', flat=True) if self.array_size < len(tags_ids): for i in xrange(100000): name = self.make_name() rand = random.sample(tags_ids, self.array_size) post, created = Post.objects.get_or_create( name=name, defaults={ 'tags': rand, 'description': self.li.get_sentences(5), }) if created: posts.append(post) print '{0} posts has been created.'.format(len(posts)) else: print 'Please generate more tags than {0}.'.format(self.array_size) def make_name(self): name = self.rw.random_word().capitalize() name = '{0}{1}'.format(name, random.randint(1, 10)) return name
def generate_random_chats(message_count: int, participants: int = 2, chats_number: int = 1) -> List[Chat]: rn = RandomNicknames() li = LoremIpsum() chats = [] # Weighted sentence length probability table message_length_probability = \ [1] * 25 + \ [2] * 35 + \ [3] * 20 + \ [4] * 10 + \ [5] * 7 + \ [6] * 3 for chat_n in range(chats_number): people = rn.random_nicks(count=participants) dt = datetime.now() messages = [] for i in range(message_count): # Generate random time intervals between 10 seconds and 24 hours secs = randint(10, 60 * 60 * 24) dt = dt + timedelta(seconds=secs) # chooses a random sender sender = random.choice(people) # generate random message: sentences_number = random.choice(message_length_probability) text = li.get_sentences(sentences_number) messages.append(Message(sender, dt, text)) chats.append(Chat(f"RandomChat_{chat_n}", people, messages)) return chats
def get_random_sentence(number=10): li = LoremIpsum() return li.get_sentences(number)