2024-07-10 23:20:06 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
2024-07-12 15:06:51 +01:00
|
|
|
"""
|
2024-09-05 16:40:47 +01:00
|
|
|
Loads a PDF document into TrustGraph processing.
|
2024-07-12 15:06:51 +01:00
|
|
|
"""
|
|
|
|
|
|
2024-07-10 23:20:06 +01:00
|
|
|
import pulsar
|
2024-07-25 22:24:14 +01:00
|
|
|
from pulsar.schema import JsonSchema
|
2024-10-22 23:23:24 +01:00
|
|
|
from trustgraph.schema import Document, document_ingest_queue
|
|
|
|
|
from trustgraph.schema import Value, Metadata, Triple
|
2024-07-10 23:20:06 +01:00
|
|
|
import base64
|
|
|
|
|
import hashlib
|
2024-07-12 15:06:51 +01:00
|
|
|
import argparse
|
|
|
|
|
import os
|
|
|
|
|
import time
|
2024-10-22 16:28:54 +01:00
|
|
|
import uuid
|
2024-07-12 15:06:51 +01:00
|
|
|
|
2024-09-30 16:16:20 +01:00
|
|
|
from trustgraph.log_level import LogLevel
|
2024-07-12 15:06:51 +01:00
|
|
|
|
2024-10-02 18:14:29 +01:00
|
|
|
default_user = 'trustgraph'
|
|
|
|
|
default_collection = 'default'
|
|
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
IS_A = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
|
|
|
|
|
LABEL = 'http://www.w3.org/2000/01/rdf-schema#label'
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
DIGITAL_DOCUMENT = 'https://schema.org/DigitalDocument'
|
|
|
|
|
PUBLICATION_EVENT = 'https://schema.org/PublicationEvent'
|
|
|
|
|
ORGANIZATION = 'https://schema.org/Organization'
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
NAME = 'https://schema.org/name'
|
|
|
|
|
DESCRIPTION = 'https://schema.org/description'
|
|
|
|
|
COPYRIGHT_NOTICE = 'https://schema.org/copyrightNotice'
|
|
|
|
|
COPYRIGHT_HOLDER = 'https://schema.org/copyrightHolder'
|
|
|
|
|
COPYRIGHT_YEAR = 'https://schema.org/copyrightYear'
|
|
|
|
|
LICENSE = 'https://schema.org/license'
|
|
|
|
|
PUBLICATION = 'https://schema.org/publication'
|
|
|
|
|
START_DATE = 'https://schema.org/startDate'
|
|
|
|
|
END_DATE = 'https://schema.org/endDate'
|
|
|
|
|
PUBLISHED_BY = 'https://schema.org/publishedBy'
|
|
|
|
|
DATE_PUBLISHED = 'https://schema.org/datePublished'
|
|
|
|
|
PUBLICATION = 'https://schema.org/publication'
|
|
|
|
|
DATE_PUBLISHED = 'https://schema.org/datePublished'
|
|
|
|
|
URL = 'https://schema.org/url'
|
|
|
|
|
IDENTIFIER = 'https://schema.org/identifier'
|
|
|
|
|
KEYWORD = 'https://schema.org/keywords'
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
def hash(data):
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
if isinstance(data, str):
|
|
|
|
|
data = data.encode("utf-8")
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
# Create a SHA256 hash from the data
|
|
|
|
|
id = hashlib.sha256(data).hexdigest()
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
# Convert into a UUID, 64-byte hash becomes 32-byte UUID
|
|
|
|
|
id = str(uuid.UUID(id[::2]))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
return id
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:39:54 +01:00
|
|
|
def curi(pref, id):
|
|
|
|
|
return f"https://trustgraph.ai/{pref}/{id}"
|
|
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
class DigitalDocument:
|
|
|
|
|
def __init__(
|
|
|
|
|
self, id, name=None, description=None, copyright_notice=None,
|
|
|
|
|
copyright_holder=None, copyright_year=None, license=None,
|
|
|
|
|
identifier=None,
|
|
|
|
|
publication=None, url=None, keywords=[]
|
|
|
|
|
):
|
|
|
|
|
self.id = id
|
|
|
|
|
self.name = name
|
|
|
|
|
self.description = description
|
|
|
|
|
self.copyright_notice = copyright_notice
|
|
|
|
|
self.copyright_holder = copyright_holder
|
|
|
|
|
self.copyright_year = copyright_year
|
|
|
|
|
self.license = license
|
|
|
|
|
self.publication = publication
|
|
|
|
|
self.url = url
|
|
|
|
|
self.identifier = identifier
|
|
|
|
|
self.keywords = keywords
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
def emit(self, emit):
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(Value(self.id), Value(IS_A), Value(DIGITAL_DOCUMENT)))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
if self.name:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(Value(self.id), Value(LABEL), Value(self.name)))
|
|
|
|
|
emit(Triple(Value(self.id), Value(NAME), Value(self.name)))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
if self.identifier:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(Value(id), Value(IDENTIFIER), Value(self.identifier)))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
if self.description:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(
|
|
|
|
|
Value(self.id), Value(DESCRIPTION), Value(self.description)
|
|
|
|
|
))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
if self.copyright_notice:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(
|
|
|
|
|
Value(self.id), Value(COPYRIGHT_NOTICE),
|
|
|
|
|
Value(self.copyright_notice)
|
|
|
|
|
))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
if self.copyright_holder:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(
|
|
|
|
|
Value(self.id), Value(COPYRIGHT_HOLDER),
|
|
|
|
|
Value(self.copyright_holder)
|
|
|
|
|
))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
if self.copyright_year:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(
|
|
|
|
|
Value(self.id), Value(COPYRIGHT_YEAR),
|
|
|
|
|
Value(self.copyright_year)
|
|
|
|
|
))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
if self.license:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(
|
|
|
|
|
Value(self.id), Value(LICENSE), Value(self.license)
|
|
|
|
|
))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
if self.keywords:
|
|
|
|
|
for k in self.keywords:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(Value(self.id), Value(KEYWORD), Value(k)))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
if self.publication:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(
|
|
|
|
|
Value(self.id), Value(PUBLICATION, Value(self.publication.id))
|
|
|
|
|
))
|
2024-10-22 22:21:09 +01:00
|
|
|
self.publication.emit(emit)
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
if self.url:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(Value(self.id), Value(URL), Value(self.url)))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
class PublicationEvent:
|
|
|
|
|
def __init__(
|
|
|
|
|
self, id, organization=None, name=None, description=None,
|
|
|
|
|
start_date=None, end_date=None,
|
|
|
|
|
):
|
|
|
|
|
self.id = id
|
|
|
|
|
self.organization = organization
|
|
|
|
|
self.name = name
|
|
|
|
|
self.description = description
|
|
|
|
|
self.start_date = start_date
|
|
|
|
|
self.end_date = end_date
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
def emit(self, emit):
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(Value(self.id), Value(IS_A), Value(PUBLICATION_EVENT)))
|
2024-10-22 22:21:09 +01:00
|
|
|
|
|
|
|
|
if self.name:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(Value(self.id), Value(LABEL), Value(self.name)))
|
|
|
|
|
emit(Triple(Value(self.id), Value(NAME), Value(self.name)))
|
2024-10-22 22:21:09 +01:00
|
|
|
|
|
|
|
|
if self.description:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(
|
|
|
|
|
Value(self.id), Value(DESCRIPTION), Value(self.description)
|
|
|
|
|
))
|
2024-10-22 22:21:09 +01:00
|
|
|
|
|
|
|
|
if self.organization:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(
|
|
|
|
|
Value(self.id), Value(PUBLISHED_BY),
|
|
|
|
|
Value(self.organization.id)
|
|
|
|
|
))
|
2024-10-22 22:21:09 +01:00
|
|
|
self.organization.emit(emit)
|
|
|
|
|
|
|
|
|
|
if self.start_date:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(
|
|
|
|
|
Value(self.id), Value(START_DATE), Value(self.start_date)
|
|
|
|
|
))
|
2024-10-22 22:21:09 +01:00
|
|
|
|
|
|
|
|
if self.end_date:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(Value(self.id), Value(END_DATE), Value(self.end_date)))
|
2024-10-22 22:21:09 +01:00
|
|
|
|
|
|
|
|
class Organization:
|
|
|
|
|
def __init__(self, id, name=None, description=None):
|
|
|
|
|
self.id = id
|
|
|
|
|
self.name = name
|
|
|
|
|
self.description = description
|
|
|
|
|
|
|
|
|
|
def emit(self, emit):
|
|
|
|
|
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(Value(self.id), Value(IS_A), Value(ORGANIZATION)))
|
2024-10-22 22:21:09 +01:00
|
|
|
|
|
|
|
|
if self.name:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(Value(self.id), Value(LABEL), Value(self.name)))
|
|
|
|
|
emit(Triple(Value(self.id), Value(NAME), Value(self.name)))
|
2024-10-22 22:21:09 +01:00
|
|
|
|
|
|
|
|
if self.description:
|
2024-10-22 23:23:24 +01:00
|
|
|
emit(Triple(
|
|
|
|
|
Value(self.id), Value(DESCRIPTION), Value(self.description)
|
|
|
|
|
))
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-07-12 15:06:51 +01:00
|
|
|
class Loader:
|
|
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
|
self,
|
|
|
|
|
pulsar_host,
|
|
|
|
|
output_queue,
|
2024-10-02 18:14:29 +01:00
|
|
|
user,
|
|
|
|
|
collection,
|
2024-07-12 15:06:51 +01:00
|
|
|
log_level,
|
2024-10-22 16:28:54 +01:00
|
|
|
metadata,
|
2024-07-12 15:06:51 +01:00
|
|
|
):
|
|
|
|
|
|
2024-10-22 23:23:24 +01:00
|
|
|
self.client = pulsar.Client(
|
|
|
|
|
pulsar_host,
|
|
|
|
|
logger=pulsar.ConsoleLogger(log_level.to_pulsar())
|
|
|
|
|
)
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 23:23:24 +01:00
|
|
|
self.producer = self.client.create_producer(
|
|
|
|
|
topic=output_queue,
|
|
|
|
|
schema=JsonSchema(Document),
|
|
|
|
|
chunking_enabled=True,
|
|
|
|
|
)
|
2024-07-12 15:06:51 +01:00
|
|
|
|
2024-10-02 18:14:29 +01:00
|
|
|
self.user = user
|
|
|
|
|
self.collection = collection
|
2024-10-22 16:28:54 +01:00
|
|
|
self.metadata = metadata
|
2024-10-02 18:14:29 +01:00
|
|
|
|
2024-10-01 19:34:35 +01:00
|
|
|
def load(self, files):
|
2024-07-12 15:06:51 +01:00
|
|
|
|
2024-10-01 19:34:35 +01:00
|
|
|
for file in files:
|
|
|
|
|
self.load_file(file)
|
|
|
|
|
|
|
|
|
|
def load_file(self, file):
|
2024-07-12 15:06:51 +01:00
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
2024-10-01 19:34:35 +01:00
|
|
|
path = file
|
2024-07-12 15:06:51 +01:00
|
|
|
data = open(path, "rb").read()
|
|
|
|
|
|
2024-10-16 23:30:51 +01:00
|
|
|
# Create a SHA256 hash from the data
|
2024-10-22 23:23:24 +01:00
|
|
|
id = hash(data)
|
2024-07-12 15:06:51 +01:00
|
|
|
|
2024-10-22 22:39:54 +01:00
|
|
|
id = curi("doc", id)
|
|
|
|
|
|
2024-10-22 16:28:54 +01:00
|
|
|
triples = []
|
|
|
|
|
|
2024-10-22 23:23:24 +01:00
|
|
|
def emit(t):
|
|
|
|
|
triples.append(t)
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
self.metadata.id = id
|
|
|
|
|
self.metadata.emit(emit)
|
2024-10-22 16:28:54 +01:00
|
|
|
|
2024-07-12 15:06:51 +01:00
|
|
|
r = Document(
|
2024-10-02 18:14:29 +01:00
|
|
|
metadata=Metadata(
|
2024-07-12 15:06:51 +01:00
|
|
|
id=id,
|
2024-10-22 23:23:24 +01:00
|
|
|
metadata = triples,
|
2024-10-02 18:14:29 +01:00
|
|
|
user=self.user,
|
|
|
|
|
collection=self.collection,
|
2024-07-12 15:06:51 +01:00
|
|
|
),
|
|
|
|
|
data=base64.b64encode(data),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
self.producer.send(r)
|
|
|
|
|
|
2024-10-01 19:34:35 +01:00
|
|
|
print(f"{file}: Loaded successfully.")
|
|
|
|
|
|
2024-07-12 15:06:51 +01:00
|
|
|
except Exception as e:
|
2024-10-01 19:34:35 +01:00
|
|
|
print(f"{file}: Failed: {str(e)}", flush=True)
|
2024-07-12 15:06:51 +01:00
|
|
|
|
|
|
|
|
def __del__(self):
|
|
|
|
|
self.client.close()
|
|
|
|
|
|
|
|
|
|
def main():
|
2024-07-10 23:20:06 +01:00
|
|
|
|
2024-07-12 15:06:51 +01:00
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
|
prog='loader',
|
|
|
|
|
description=__doc__,
|
2024-07-10 23:20:06 +01:00
|
|
|
)
|
|
|
|
|
|
2024-07-12 15:06:51 +01:00
|
|
|
default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://localhost:6650')
|
2024-07-25 21:43:55 +01:00
|
|
|
default_output_queue = document_ingest_queue
|
2024-07-12 15:06:51 +01:00
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'-p', '--pulsar-host',
|
|
|
|
|
default=default_pulsar_host,
|
|
|
|
|
help=f'Pulsar host (default: {default_pulsar_host})',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'-o', '--output-queue',
|
|
|
|
|
default=default_output_queue,
|
|
|
|
|
help=f'Output queue (default: {default_output_queue})'
|
|
|
|
|
)
|
|
|
|
|
|
2024-10-02 18:14:29 +01:00
|
|
|
parser.add_argument(
|
|
|
|
|
'-u', '--user',
|
|
|
|
|
default=default_user,
|
|
|
|
|
help=f'User ID (default: {default_user})'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'-c', '--collection',
|
|
|
|
|
default=default_collection,
|
|
|
|
|
help=f'Collection ID (default: {default_collection})'
|
|
|
|
|
)
|
|
|
|
|
|
2024-10-16 23:30:51 +01:00
|
|
|
parser.add_argument(
|
|
|
|
|
'--name', help=f'Document name'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--description', help=f'Document description'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--copyright-notice', help=f'Copyright notice'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--copyright-holder', help=f'Copyright holder'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--copyright-year', help=f'Copyright year'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
2024-10-22 16:28:54 +01:00
|
|
|
'--license', help=f'Copyright license'
|
2024-10-16 23:30:51 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--publication-organization', help=f'Publication organization'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--publication-description', help=f'Publication description'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--publication-date', help=f'Publication date'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--url', help=f'Document URL'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
2024-10-22 16:28:54 +01:00
|
|
|
'--keyword', nargs='+', help=f'Keyword'
|
2024-10-16 23:30:51 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
2024-10-22 16:28:54 +01:00
|
|
|
'--identifier', '--id', help=f'Document ID'
|
2024-10-16 23:30:51 +01:00
|
|
|
)
|
|
|
|
|
|
2024-07-12 15:06:51 +01:00
|
|
|
parser.add_argument(
|
|
|
|
|
'-l', '--log-level',
|
|
|
|
|
type=LogLevel,
|
|
|
|
|
default=LogLevel.ERROR,
|
|
|
|
|
choices=list(LogLevel),
|
|
|
|
|
help=f'Output queue (default: info)'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
2024-10-01 19:34:35 +01:00
|
|
|
'files', nargs='+',
|
2024-07-12 15:06:51 +01:00
|
|
|
help=f'File to load'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
|
|
|
|
|
try:
|
2024-10-01 19:34:35 +01:00
|
|
|
|
2024-10-22 22:21:09 +01:00
|
|
|
document = DigitalDocument(
|
|
|
|
|
id,
|
|
|
|
|
name=args.name,
|
|
|
|
|
description=args.description,
|
|
|
|
|
copyright_notice=args.copyright_notice,
|
|
|
|
|
copyright_holder=args.copyright_holder,
|
|
|
|
|
copyright_year=args.copyright_year,
|
|
|
|
|
license=args.license,
|
|
|
|
|
url=args.url,
|
|
|
|
|
keywords=args.keyword,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if args.publication_organization:
|
|
|
|
|
org = Organization(
|
2024-10-22 22:39:54 +01:00
|
|
|
id=curi("org", hash(args.publication_organization)),
|
2024-10-22 22:21:09 +01:00
|
|
|
name=args.publication_organization,
|
|
|
|
|
)
|
|
|
|
|
document.publication = PublicationEvent(
|
2024-10-22 22:39:54 +01:00
|
|
|
id = curi("pubev", str(uuid.uuid4())),
|
2024-10-22 22:21:09 +01:00
|
|
|
organization=org,
|
|
|
|
|
description=args.publication_description,
|
|
|
|
|
start_date=args.publication_date,
|
|
|
|
|
end_date=args.publication_date,
|
|
|
|
|
)
|
|
|
|
|
|
2024-07-12 15:06:51 +01:00
|
|
|
p = Loader(
|
|
|
|
|
pulsar_host=args.pulsar_host,
|
|
|
|
|
output_queue=args.output_queue,
|
2024-10-02 18:14:29 +01:00
|
|
|
user=args.user,
|
|
|
|
|
collection=args.collection,
|
2024-07-12 15:06:51 +01:00
|
|
|
log_level=args.log_level,
|
2024-10-22 22:21:09 +01:00
|
|
|
metadata=document,
|
2024-07-12 15:06:51 +01:00
|
|
|
)
|
|
|
|
|
|
2024-10-01 19:34:35 +01:00
|
|
|
p.load(args.files)
|
2024-07-12 15:06:51 +01:00
|
|
|
|
2024-10-01 19:34:35 +01:00
|
|
|
print("All done.")
|
2024-07-12 15:06:51 +01:00
|
|
|
break
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
|
|
print("Exception:", e, flush=True)
|
|
|
|
|
print("Will retry...", flush=True)
|
2024-07-10 23:20:06 +01:00
|
|
|
|
2024-07-12 15:06:51 +01:00
|
|
|
time.sleep(10)
|
2024-07-10 23:20:06 +01:00
|
|
|
|
2024-07-12 15:06:51 +01:00
|
|
|
main()
|
2024-07-10 23:20:06 +01:00
|
|
|
|