mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-30 17:55:13 +02:00
fix: avoid swallowing cache directory errors
This commit is contained in:
parent
4200b5d683
commit
7ca41fa893
1 changed files with 4 additions and 9 deletions
|
|
@ -4,9 +4,10 @@ Loads a PDF document into the library
|
|||
|
||||
import argparse
|
||||
import os
|
||||
import uuid
|
||||
import datetime
|
||||
import requests
|
||||
from requests.adapters import HTTPAdapter
|
||||
from urllib3.response import HTTPResponse
|
||||
|
||||
from trustgraph.api import Api
|
||||
from trustgraph.api.types import hash, Uri, Literal, Triple
|
||||
|
|
@ -16,9 +17,6 @@ default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
|||
default_workspace = os.getenv("TRUSTGRAPH_WORKSPACE", "default")
|
||||
|
||||
|
||||
from requests.adapters import HTTPAdapter
|
||||
from urllib3.response import HTTPResponse
|
||||
|
||||
class FileAdapter(HTTPAdapter):
|
||||
def send(self, request, *args, **kwargs):
|
||||
resp = HTTPResponse(body=open(request.url[7:], 'rb'), status=200, preload_content=False)
|
||||
|
|
@ -28,10 +26,7 @@ session = requests.session()
|
|||
|
||||
session.mount('file://', FileAdapter())
|
||||
|
||||
try:
|
||||
os.mkdir("doc-cache")
|
||||
except:
|
||||
pass
|
||||
os.makedirs("doc-cache", exist_ok=True)
|
||||
|
||||
documents = [
|
||||
|
||||
|
|
@ -743,4 +738,4 @@ def main():
|
|||
raise e
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue