3

Is it possible to have mona.py save the output from a specific command to a specific file. So for example if I wanted to run multiple compare commands could I have them all saved to different output files?

The way it works presently is that they would get saved as compare.txt, compare.txt.old, compare.txt.old2 etc. I basically want to know if its possible to set them to output as compare.txt, compare1.txt etc so I dont need to go around deleting all the .old extensions.

  • i just googled mona.py is in github and the class Mnlog seems to append the string old2 to the name of logfile so you should be able to rewrite it as you need – blabb Aug 11 '17 at 3:20
3

Since Mona's source is available on Github you can easily modify the code to fit your needs.

The code that responsible to save the files can be found (currently) in line 2477 inside the class MnLog.

try:
    if os.path.exists(logfile):
        try:
            os.delete(logfile+".old")
        except:
            pass
        try:
            os.rename(logfile,logfile+".old")
        except:
            try:
                os.rename(logfile,logfile+".old2")
            except:
                pass
except:
    pass

You can download the file and modify the code as you wish. For example the following modification will change the files from compare.txt.old and compare.txt.old2 to compare1.txt and compare2.txt accordingly.

if os.path.exists(logfile):
    try:
        os.delete(logfile[:-4] + "1.txt")
        pass
    try:
        os.rename(logfile,logfile[:-4] + "1.txt")
    except:
        try:
            os.rename(logfile,logfile[:-4] + "2.txt")
        except:
            pass
except:
    pass

I used [:-4] to remove the last four chars from the filename (from 'compare.txt' to 'compare') and appended 1.txt and 2.txt instead of .old and .old2.

I didn't check whether the modified code actually works, but it supposed to - and if not, the concept is what important here.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.