Skip to content

Commit

Permalink
More logging
Browse files Browse the repository at this point in the history
  • Loading branch information
angusjfw committed Nov 3, 2022
1 parent bec5b81 commit 173c158
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions further_link/runner/exec_process_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ async def _start(self, path, code=None, novncOptions={}):
path = get_absolute_path(path, get_working_directory(self.user))

# create path directories if they don't already exist
logging.debug(f"{self.id} Creating working directory for exec")
await create_directory(os.path.dirname(path), self.user)

entrypoint = path if code is None else os.path.join(path, f"exec-{self.id}")

# create a temporary file to execute if code is provided
if code is not None:
logging.debug(f"{self.id} Creating entrypoint for exec")
await write_file(entrypoint, code)
self._remove_entrypoint = entrypoint

Expand Down
4 changes: 4 additions & 0 deletions further_link/runner/process_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,13 @@ async def _clean_up(self):
logging.debug(f"{self.id} Cleaning up PTY")
try:
if getattr(self, "pty_master", None):
logging.debug(f"{self.id} Closing PTY master")
await self.pty_master.close()
logging.debug(f"{self.id} Closed PTY master")
if getattr(self, "pty_slave", None):
logging.debug(f"{self.id} Closing PTY slave")
await self.pty_slave.close()
logging.debug(f"{self.id} Closed PTY slave")
except Exception as e:
logging.exception(f"{self.id} PTY Cleanup error: {e}")

Expand Down
2 changes: 2 additions & 0 deletions further_link/runner/py_process_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ async def _start(self, path, code=None, novncOptions={}):
path = get_absolute_path(path, get_working_directory(self.user))

# create path directories if they don't already exist
logging.debug(f"{self.id} Creating working directory for python3")
await create_directory(os.path.dirname(path), self.user)

entrypoint = path if code is None else os.path.join(path, f"{self.id}.py")

# create a temporary file to execute if code is provided
if code is not None:
logging.debug(f"{self.id} Creating entrypoint for python3")
await write_file(entrypoint, code)
self._remove_entrypoint = entrypoint

Expand Down
3 changes: 3 additions & 0 deletions further_link/runner/shell_process_handler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from ..util.upload import create_directory
from ..util.user_config import get_absolute_path, get_shell, get_working_directory
from .process_handler import ProcessHandler
Expand All @@ -8,6 +10,7 @@ async def _start(self, path, code=None, novncOptions={}):
work_dir = get_absolute_path(path, get_working_directory(self.user))

# create work dir if it doesn't already exist
logging.debug(f"{self.id} Creating working directory for shell")
await create_directory(work_dir, self.user)

await super()._start(get_shell(self.user), work_dir, novncOptions=novncOptions)
3 changes: 0 additions & 3 deletions further_link/util/async_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ async def symlink(src, dst):

async def write_file(path, content, mode="w+"):
def sync_write_file(p, c):
print("opening file")
with open(p, mode) as file:
print("file open")
file.write(c)
print("file written")

await asyncio.to_thread(partial(sync_write_file, path, content))

Expand Down

0 comments on commit 173c158

Please sign in to comment.