def generate_uuid0(ts: Optional[int] = None):
    """
    Generate a random UUID partly based on Unix timestamp (not part of official "variants").

    Uses 6 bytes to encode the time and does not encode any version bits, leaving 10 bytes (80 bits) of random data.

    :param ts: optional timestamp to use instead of current time (if not falsey)
    :return: uuid0 object (subclass of UUID)
    """
    return uuid0.generate(ts)
Пример #2
0
    def handle(self, *args, **options):
        rfid_id = str(uuid0.generate())
        endpoint_path = reverse("rfid-lookup")

        endpoint_url = "http://127.0.0.1:8000{}".format(endpoint_path)
        # endpoint_url = "https://firefox.vryhof.net{}".format(endpoint_path)

        log_message("talking to: {}".format(endpoint_url))

        resp = requests.post(endpoint_url,
                             data=dict(catalog_id=1, rfid_id=rfid_id))

        print(resp.text)
Пример #3
0
    def save(self,
             force_insert=False,
             force_update=False,
             using=None,
             update_fields=None):
        if not self.item_id:
            self.item_id = str(uuid0.generate())

        if not self.variant_key:
            self.variant_key = "#{}".format(slugify(self.name))
            self.object_id = "#{}".format(slugify(self.name))

        super().save(force_insert, force_update, using, update_fields)

        if self.catalog_item is not None:
            self.catalog_item.save()
Пример #4
0
    def save(self,
             force_insert=False,
             force_update=False,
             using=None,
             update_fields=None):
        if not self.item_abbreviation or self.item_abbreviation is None:
            self.item_abbreviation = generate_abbreviation(self.name)

        if not self.item_key or self.item_key is None:
            self.item_key = str(uuid0.generate())

        if not self.item_id:
            self.item_id = "#{}".format(slugify(self.name))
            self.object_id = "#{}".format(slugify(self.name))

        super().save(force_insert, force_update, using, update_fields)

        itemid = self.item_id
        if not self._state.adding:
            if self.object_id is not None:
                itemid = self.object_id

        body = self.as_dict(itemid)

        log_message(body, pretty=True)

        if self.variants.count() > 0:
            result = square_client.catalog.upsert_catalog_object(body=body)
            catalog_item = result.body if result.is_success(
            ) else result.errors

            if "catalog_object" in catalog_item:
                self.catalog.version = catalog_item.get("catalog_object").get(
                    "version")
                self.object_id = catalog_item.get("catalog_object").get("id")
                super().save(force_insert, force_update, using, update_fields)

            try:
                id_mappings = catalog_item.get("id_mappings", [])
            except AttributeError:
                log_message(catalog_item, pretty=True)
            else:
                self.update_id_mappings(id_mappings)
Пример #5
0
 def idempotency_key(self):
     return str(uuid0.generate())
Пример #6
0
import argparse

import uuid0

parser = argparse.ArgumentParser(description='Generate a UUID0')
parser.add_argument('--timestamp', '-t', type=float,
                    help='UNIX timestamp')
parser.add_argument('--number', '-n', type=int, default=200,
                    help='Number of UUIDs to generate')
args = parser.parse_args()

for x in range(args.number):
    print(uuid0.generate(args.timestamp))
Пример #7
0
 def pkgen(self):
     return uuid0.generate().base62