Skip to content

Commit

Permalink
Fix formatting and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
cpbotha committed Jul 2, 2024
1 parent ca80297 commit 075127a
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions org_roam_canvas/orserve.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import logging
import os
import platform
import subprocess
from pathlib import Path
from threading import Lock
import webbrowser
from urllib.parse import quote_plus

import uvicorn
Expand All @@ -10,9 +12,6 @@

from . import utils_emacs


import subprocess, os, platform

mutex = Lock()

logging.basicConfig(level=logging.INFO)
Expand Down Expand Up @@ -71,7 +70,7 @@ async def get_node_css():


@app.get("/node/")
#@lru_cache(maxsize=64)
# @lru_cache(maxsize=64)
def get_or_node_details(id: str):
det = utils_emacs.get_or_node_details(id)

Expand All @@ -89,16 +88,19 @@ def get_or_node_details(id: str):

@app.get("/os-open/")
def open(filename: str):
# previous file opener:
# convert filename into file:// link
file_uri = Path(filename).absolute().as_uri()
# file_uri = Path(filename).absolute().as_uri()
# webbrowser.open(file_uri)

# new file opener:
filepath = filename
if platform.system() == 'Darwin': # macOS
subprocess.call(('open', filepath))
elif platform.system() == 'Windows': # Windows
if platform.system() == "Darwin": # macOS
subprocess.call(("open", filepath))
elif platform.system() == "Windows": # Windows
os.startfile(filepath)
else: # linux variants
subprocess.call(('xdg-open', filepath))
else: # linux variants
subprocess.call(("xdg-open", filepath))

html = f"""<html><body>
<p>
Expand All @@ -109,9 +111,9 @@ def open(filename: str):
</p>
"""


return Response(media_type="text/html", content=html)


# / on Linux, c:/ or the drive from where you're running this script
# I want orc-files to be able to accept full path names
root = Path.cwd().anchor
Expand Down

0 comments on commit 075127a

Please sign in to comment.