Commit 56d7f629 authored by Gary Ruben's avatar Gary Ruben
Browse files

Added some stdout logging functionality

parent 81d63459
......@@ -7,12 +7,14 @@ for details on how to do this between a Monash Linux machine and ASCI.
"""
import os
import sys
import warnings
from dataclasses import dataclass
import pathlib
import subprocess
import pickle
import pprint
import time
# This isn't suppressing the warnings that fabric is generating; we need to
......@@ -30,8 +32,10 @@ KERNEL_CHECKSUM=$(cpio --to-stdout -i kernel.fat16 < archive.cpio | sha256sum |
"""
READ_PICKLE_FILE = False
READ_PICKLE_FILE = True
PICKLE_FILENAME = os.path.join(os.path.dirname(__file__), 'tree_state.pickle')
EXPERIMENT_NAME = "13660a"
PICKLE_FILENAME = os.path.join(os.path.dirname(__file__), "tree_state.pickle")
timestamp = time.strftime("%Y-%m-%d-%H%M%S")
LOG_FILENAME = os.path.join(os.path.dirname(__file__), f"{EXPERIMENT_NAME}-{timestamp}.log")
REMOTE_LOGIN = "gary.ruben@monash.edu@sftp.synchrotron.org.au"
# SRC_PATH = "/data/13660a/asci/input"
SRC_PATH = "/data/13660a/asci/output/tar_test"
......@@ -47,6 +51,20 @@ class Node:
processed: bool = False # True iff a node transfer completes
class Logger(object):
def __init__(self):
self.terminal = sys.stdout
self.log = open(LOG_FILENAME, "a")
def write(self, message):
self.terminal.write(message)
self.log.write(message)
def flush(self):
self.terminal.flush()
self.log.flush()
def tar_and_send_directory(node):
"""Sends all files in the node.src directory to the node.dest directory
across an ssh connection using the cpio command to tar the files into a
......@@ -107,6 +125,8 @@ def tar_and_send_directory(node):
node.processed = True
if __name__ == "__main__":
sys.stdout = Logger()
if not READ_PICKLE_FILE:
# Get the directory tree from remote server as a list
with Connection(REMOTE_LOGIN) as c:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment