Beispiel #1
0
    def generate(self, number):
        """
        Generates an MP3 file with tones from a range of low and high
        frequencies.

        Args:
            number (int): A number used in the multiprocessing iterator.

        Returns:
            str: The name of the generated MP3 file.
        """

        lorem = TextLorem()
        title = lorem.sentence()
        handle, qr_filename = mkstemp('.png')
        os.close(handle)

        try:
            qr = qrcode.make(md5(title.encode('utf-8')).hexdigest())
            qr.save(qr_filename)
            wav_filename = generate_wav(self.low_freq, self.high_freq,
                                        self.duration)

            try:
                handle, mp3_filename = mkstemp('.mp3')
                os.close(handle)

                convert_mp3(wav_filename, mp3_filename)
                tag_mp3(mp3_filename, title, qr_filename)
                return mp3_filename
            finally:
                os.remove(wav_filename)
        finally:
            os.remove(qr_filename)
Beispiel #2
0
def generate_data(file):
    # opening the csv file to find the amount of lines & seq number
    with open(file, 'r') as infile:
        seq = len(infile.readlines())

    while seq < 1000002:
        # generate guid
        guid = uuid.uuid4()

        # generate fake cc
        cc_len = 16
        ccnumber = ''.join(["%s" % random.randint(0, 9)
                            for num in range(0, cc_len)])

        # generate random date because ???
        date = datetime.date(random.randint(2005, 2025),
                            random.randint(1, 12), random.randint(1, 28)).strftime("%d/%m/%Y")

        # generate sentence filled with gibberish??? okay...
        lorem = TextLorem(wsep=' ', srange=(6, 12))
        sentence = lorem.sentence()

        # now we are writing the data to the csv until we have 1 mil entries
        
        with open(file, 'a') as outfile:
        # seq len is one extra b/c of header, but that works instead of +=
            writer = csv.writer(outfile)
            row = [seq, guid, seq, seq, ccnumber, date, sentence]
            writer.writerow(row)
            seq += 1
def main(args):
    init()
    lorem = TextLorem(srange=(1, args.length))
    while True:
        print(getColors() + lorem.sentence().lower().replace(".", ""), end="")
        if args.time > 0:
            pause(args.time)
Beispiel #4
0
def main():
    # separate words by '-'
    # sentence length should be between 2 and 3
    # choose words from A, B, C and D
    lorem = TextLorem(wsep='-', srange=(2, 3), words="A B C D".split())

    s1 = lorem.sentence()  # 'C-B.'
    s2 = lorem.sentence()  # 'C-A-C.'
    print("This is dummy gm.com text, will hit on this")
Beispiel #5
0
def get_sentence_using_service_2():
    address, port = get_service("service2")

    words = requests.get(f"http://{address}:{port}/words").json()

    words = words["words"]

    lorem = TextLorem(words=words)

    return {"sentence": lorem.sentence()}
Beispiel #6
0
def create_tables_data():

    lorem = TextLorem(srange=(1, 2))
    for i in range(0, 40):

        data = {
            "table_id": i + 1,
            "name": lorem.sentence(),
            "max_line": randint(600, 800)
        }

        table = ModelTable.find_table(data.get("table_id"))

        if not table:
            table = ModelTable(**data)
            table.save_table()
Beispiel #7
0
def create_random_data(count):
    name_generator = TextLorem(srange=(2, 4))
    description_generator = TextLorem(srange=(4, 8))
    registered = True
    for i in range(count):
        device = Device.objects.create(
            name=f'{name_generator.sentence()}_{count}',
            serial_id=''.join(
                random.choices(string.ascii_uppercase + string.digits, k=10)),
            description=description_generator.sentence(),
            address=''.join(
                random.choices(string.ascii_uppercase + string.digits, k=10)),
            registered=registered)
        if registered:
            registered = False
        else:
            registered = True
Beispiel #8
0
    def generate(self):
        """Generate."""
        size = self.holder.items["total"]
        iloc_pids = self.holder.pids("internal_locations", "pid")
        doc_pids = self.holder.pids("documents", "pid")
        shelf_lorem = TextLorem(wsep='-',
                                srange=(2, 3),
                                words='Ax Bs Cw 8080'.split())
        objs = [{
            "pid":
            self.create_pid(),
            "document_pid":
            random.choice(doc_pids),
            "internal_location_pid":
            random.choice(iloc_pids),
            "legacy_id":
            "{}".format(randint(100000, 999999)),
            "legacy_library_id":
            "{}".format(randint(5, 50)),
            "barcode":
            "{}".format(randint(10000000, 99999999)),
            "shelf":
            "{}".format(shelf_lorem.sentence()),
            "description":
            "{}".format(lorem.text()),
            "internal_notes":
            "{}".format(lorem.text()),
            "medium":
            random.choice(Item.MEDIUMS),
            "status":
            random.choice(
                random.choices(population=Item.STATUSES,
                               weights=[0.7, 0.1, 0.1, 0.1, 0.05],
                               k=10)),
            "circulation_restriction":
            random.choice(Item.CIRCULATION_RESTRICTIONS),
        } for pid in range(1, size + 1)]

        self.holder.items["objs"] = objs
    def test_02_make_dirs(self):  #using environment variables

        for project in yaml_config:

            incoming = yaml_config[project]['incoming']
            outgoing = yaml_config[project]['outgoing']
            logger = logging.getLogger()
            pio = ProjectIO(project=project,
                            logger=logger,
                            incoming=incoming,
                            outgoing=outgoing)

            os.makedirs(os.path.abspath(pio.incoming.path), exist_ok=True)
            os.makedirs(os.path.abspath(pio.outgoing.path), exist_ok=True)
            #print(yaml_reader('/workspace/scripts/switchboard.yaml'))
            lorem = TextLorem(wsep='_', srange=(2, 3))
            for i in range(10):

                file_name = lorem.sentence() + random.choice(FILE_TYPES)
                with open(os.path.join(pio.incoming.path, file_name),
                          'a') as f:
                    f.write(lorem.paragraph())
                os.chmod(os.path.join(pio.incoming.path, file_name), 0o777)
Beispiel #10
0
def step2_mokc_data():  #using environment variables
    xx = traverse_replace_yaml_tree(yaml_config)
    xx = recurse_replace_yaml(xx, runtime_dict)
    for project in xx:

        incoming = xx[project]['incoming']
        outgoing = xx[project]['outgoing']
        logger = logging.getLogger()
        pio = ProjectIO(project=project,
                        logger=logger,
                        incoming=incoming,
                        outgoing=outgoing)

        os.makedirs(pio.incoming.path, exist_ok=True)
        os.makedirs(pio.outgoing.path, exist_ok=True)
        #print(yaml_reader('/workspace/scripts/switchboard.yaml'))
        lorem = TextLorem(wsep='_', srange=(2, 3))
        for i in range(MOCKSIZE):

            file_name = lorem.sentence() + random.choice(FILE_TYPES)
            with open(os.path.join(pio.incoming.path, file_name), 'a') as f:
                f.write(lorem.paragraph())
            os.chmod(os.path.join(pio.incoming.path, file_name), 0o777)
Beispiel #11
0
def seed_database():
    print('seeding db')
    bcrypt = Bcrypt()
    title_lorem = TextLorem(wsep=" ", srange=(2, 10))
    content_lorem = TextLorem(wsep=" ", srange=(10, 20))
    # current user in database
    password = b'ava_utf8'
    hashed_password = bcrypt.generate_password_hash(password).decode("utf-8")
    ava = User(
        username='******',
        password=hashed_password,
        email='*****@*****.**',
        first_name='Ava',
        last_name='Ava',
        profile_photo=
        'https://images.unsplash.com/photo-1521191809347-74bcae21439c?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60'
    )

    print('adding user')
    db.session.add(ava)
    db.session.commit()

    # seed chirps
    chirps = []
    for _ in range(6):
        chirp = Feedback(title=title_lorem.sentence(),
                         content=content_lorem.paragraph(),
                         username='******')
        chirps.append(chirp)

    # add list of chirps to psql
    print('adding chirps')
    db.session.bulk_save_objects(chirps)
    db.session.commit()

    print('chirps added')
Beispiel #12
0
def random_text():
    with open('data/words.txt', 'r') as words:
        words_list = words.read().split()
    lorem = TextLorem(wsep=' ', srange=(4, 7), words=words_list)
    return lorem.sentence()
Beispiel #13
0
def get_sentence_using_own_words():
    lorem = TextLorem()

    return {"sentence": lorem.sentence()}
Beispiel #14
0
    '*****@*****.**'
]
body_recipients = ", ".join(email_recipients)
mail_server = "secure.emailsrvr.com"
email_password = "******"

# loop for all of time
while True:
    # new lorem instance for random text
    lorem = TextLorem()

    # a block of random text to go in the email body
    t1 = lorem.text()

    # set the subject to something unique so we don't end up with
    email_subject = "Hello from {}".format(lorem.sentence())

    email_body = "MIME-Version: 1.0\nContent-type: text/html\nFrom: {efrom}\nTo: {to}\nSubject: {subject}\n\n<b>Hi. This is a randomly-generated message.</b>\n<p>Really, all I'm doing is trying to generate some email for these mailboxes, and keep it continuously flowing.\n<p>This is really just for continuous testing - for before/during/after migration scenarios.\n<p>Here's some random text:\n\n{ipsum}".format(
        efrom=email_sender,
        to=body_recipients,
        subject=email_subject,
        ipsum=lorem.paragraph())

    server = smtplib.SMTP(mail_server)
    server.starttls()
    server.login(email_sender, email_password)
    server.ehlo()
    server.sendmail(email_sender, email_recipients, email_body)
    server.close()

    print('Email sent successfully.')
Beispiel #15
0
from random import randint
from lorem.text import TextLorem

import csv

NUM_DIFFERENT_SCHEMAS = 10  # num output tables
NUM_RECORDS = 100

out = csv.writer(open("input.csv", "w"))

for i in range(NUM_RECORDS):
    rnd = randint(1, NUM_DIFFERENT_SCHEMAS)
    lorem = TextLorem(wsep=',', srange=(rnd, rnd))

    out.writerow([str(rnd) + ',' + lorem.sentence()[:-1]])

print 'input.csv file created'
Beispiel #16
0
def delivery_data():

    category = [{
        "name": "Caneca",
        "description": ""
    }, {
        "name": "Azulejo",
        "description": ""
    }, {
        "name": "SmartWatch",
        "description": ""
    }, {
        "name": "Fone de Ouvido",
        "description": ""
    }]

    for cat in category:
        cate = ModelCategoryProduct.find_category(cat.get("id"))
        if not cate:
            cat = ModelCategoryProduct(**cat)
            cat.save_category()

    brand = [{
        "name": "Marca 1",
        "description": ""
    }, {
        "name": "Azulejo",
        "description": "Marca 2"
    }, {
        "name": "Marca 3",
        "description": ""
    }, {
        "name": "Marca 4",
        "description": ""
    }]

    for bran in brand:
        cate = ModelBrandProduct.find_brand(bran.get("id"))
        if not cate:
            cat = ModelBrandProduct(**bran)
            cat.save_brand()

    providers = [{
        "enable": True,
        "type_registration": 2,
        "cnpj": "16897733000100",
        "cell_phone": "22997069161",
        "phone": "",
        "company_name": "Azul e Rosa Teste Update",
        "contact_name": "andre",
        "fancy_name": "AZUl e Rosa",
        "municipal_registration": "",
        "state_registration": "",
        "address": "Rua Major Euclides",
        "city": "Campos dos Goytacazes",
        "complement": "",
        "email": "",
        "neighborhood": "Turf",
        "number": "",
        "obs": "",
        "site": "",
        "state": "RJ",
        "zip_code": "28015161"
    }, {
        "enable": True,
        "type_registration": 2,
        "cnpj": "16897733000100",
        "cell_phone": "22997069161",
        "phone": "",
        "company_name": "Azul e Rosa Teste Update",
        "contact_name": "andre",
        "fancy_name": "Fornecedor 2",
        "municipal_registration": "",
        "state_registration": "",
        "address": "Rua Major Euclides",
        "city": "Campos dos Goytacazes",
        "complement": "",
        "email": "",
        "neighborhood": "Turf",
        "number": "",
        "obs": "",
        "site": "",
        "state": "RJ",
        "zip_code": "28015161"
    }]

    for provider in providers:
        prov = ModelProvider.find_provider(provider.get("id"))
        if not prov:
            provider = ModelProvider(**provider)
            provider.save_provider()

    product = {
        "internal_code": "acb123",
        "name": "Produto Teste",
        "brand": randint(1, 4),
        "unit": 1,
        "category": 1,
        "long_description": "Descrição longa do produto",
        "short_description": "Descrição curta do produto",
        "maximum_stock": 30,
        "minimum_stock": 10,
        "sale_price": 10.50,
        "available": True,
        "height": 10,
        "provider": [1],
        "cover": "",
        "images": [],
        "length": 1.5,
        "weight": 0.75,
        "width": 1.25,
        "maximum_discount": 10.00,
        "minimum_sale": 1,
        "subtract": False
    }

    prod = ModelProducts.find_product(product.get("id"))

    if not prod:

        for _ in range(20):
            lorem = TextLorem(srange=(1, 2))
            product["name"] = lorem.sentence()
            ModelProducts(**product).save_product()

    purchase = {
        "provider_id":
        1,
        "value":
        20.10,
        "freight":
        1,
        "discount":
        0,
        "total_value":
        21.1,
        "payment_form":
        1,
        "payment_method":
        2,
        "delivery_status":
        2,
        "parcel":
        1,
        "delivery_time":
        "2017-10-10",
        "obs":
        "",
        "itens": [{
            "id": "",
            "product_id": 1,
            "product_name": "NOme do produto",
            "unit_price": 10.05,
            "qtde": 2,
            "total_price": 20.1,
            "obs": ""
        }]
    }

    for _ in range(1):

        puchase = ModelPurchase(**purchase)

        for item in purchase.get("itens"):
            puchase.itens.append(
                ModelPurchaseItem(**item,
                                  id_purchase=puchase,
                                  provider_id=purchase.get("provider_id")))
        puchase.save_purchase()
import json
import random
from lorem.text import TextLorem

name_gen = TextLorem(srange=(2,2))
text_gen = TextLorem(srange=(1,30))

types = ["Generic","Share", "Image"]

name1 = name_gen.sentence()[:-1]
name2 = name_gen.sentence()[:-1]

obj = dict()
participants = [{"name":name1},{"name":name2}]
obj['participants'] = participants

n_messages = random.randint(10,1000)
messages = []

day = 0
ms_per_day = 86400000L
useName1 = True
for i in range(n_messages):
    msg_obj = dict()
    msg_obj['sender_name'] = name1 if useName1 else name2
    msg_obj['timestamp_ms'] = day * ms_per_day + i
    messages.append

    type = 'Generic'
    # 10% for share, 10% for image
    msg_type = random.randint(1,10)
muy = [random.uniform(-500, 500) for i in range(nBatches)]
sigmay = [random.uniform(10, 40) for i in range(nBatches)]
muz = [random.uniform(-500, 500) for i in range(nBatches)]
sigmaz = [random.uniform(10, 40) for i in range(nBatches)]
nPointsB = [int(random.uniform(20, 50)) for i in range(nBatches)]

## crerate colors for each batch at random
colorDict = {}
for i in range(nBatches):
    r = lambda: random.randint(0, 255)
    colorDict[i] = '#%02X%02X%02X' % (r(), r(), r())

lorem = TextLorem(wsep='', srange=(2, 3))
batchNames = []
for batch in range(nBatches):
    batchNames.append(lorem.sentence())

with open(data_file, 'w') as f:
    f.write("id\tx\ty\tz\tbatch\tcolor\n")
    f.write('0-1\t0\t0\t0\t1\t' + colorDict[1] + '\n')
    f.write('100-2\t100\t100\t100\t1\t' + colorDict[1] + '\n')
    kount = 3
    for batch in range(nBatches):
        print('Cardinality of ', batch, ': ', nPointsB[batch] + 1)
        for kount in range(nPointsB[batch]):
            xval = str(round(random.gauss(mux[batch], sigmax[batch]), 1))
            yval = str(round(random.gauss(muy[batch], sigmay[batch]), 1))
            zval = str(round(random.gauss(muz[batch], sigmaz[batch]), 1))
            color = colorDict[batch]
            id_string = str(batchNames[batch]) + '-' + str(kount)
            kount = kount + 1
Beispiel #19
0
def random_name(n=4):
    lorem = TextLorem(wsep=' ', srange=(2, n))
    return lorem.sentence()[:-1].upper()