eftalgezer / SIESTAstepper

SIESTAstepper runs SIESTA step by step, designed for constrained calculations.
https://beyondthearistotelian.blogspot.com/search/label/SIESTAstepper
GNU General Public License v3.0
0 stars 0 forks source link

Remove sh package #12

Open eftalgezer opened 1 month ago

eftalgezer commented 1 month ago

Remove sh package and find another equivalent for Linux's tail functionality to broaden OS support.

muddi900 commented 1 month ago

Would splitting the log string at new line and then running a reverse loop achieve the same function?

eftalgezer commented 1 month ago

Would splitting the log string at new line and then running a reverse loop achieve the same function?

Can you elaborate?

muddi900 commented 1 month ago
with open(settings.get_log(), 'r') as log_file:
    data = log_file.readlines()

for i in range(-1,-len(data), -1):
    ...

This would achieve the same effect. We can also use data.reverse or reversed(data). But this is more efficient.

eftalgezer commented 1 month ago
with open(settings.get_log(), 'r') as log_file:
    data = log_file.readlines()

for i in range(-1,-len(data), -1):
    ...

This would achieve the same effect. We can also use data.reverse or reversed(data). But this is more efficient.

It is unrelevant. The current implementation writes the output of subprocess.Popen to the log file. Popen runs SIESTA. SIESTA gives many output in a certain timeframe and one should save the whole output from SIESTA to the log file as it comes. Also, one needs to see those flowing outputs.

Without this package, one runs SIESTA from the terminal as follows

siesta system.fdf > log &

And then, runs the following command to see every incoming output

tail -f log

It is not possible to use > with subprocess, and also run tail, so we direct the SIESTA's output to a file and write into it as it comes. Normally, one does it with >. And since it is not possible to run tail, we use sh package's tail.