ViperMonkey icon indicating copy to clipboard operation
ViperMonkey copied to clipboard

Make vmonkey.py a little more OS agnostic

Open dmoore44 opened this issue 4 years ago • 3 comments

  • Made temp file location OS independent - temp files were originally saved to /tmp, but this doesn't work so well if ViperMonkey is installed to FLARE VM.
  • Added a check for python3 binary location, just in case python3 was installed using the command alias "python" rather than "python3" as was the case in my FLARE VM. This is a bit janky and could probably benefit from a better coder cleaning it up.

dmoore44 avatar Sep 16 '20 22:09 dmoore44

What about using the tempfile make to make the entire filename?

temp_prefix= 'tmp_word_file_' or 'tmp_excel_file_' or 'tmp_file_'
tempfile.mkstemp(prefix=temp_prefix, dir=tempfile.tempdir)

Is there a requirement to have the file name end with numbers?

Is the current code base Python 3 compatible already? Or is #30 redundant?

malvidin avatar Oct 01 '20 18:10 malvidin

Adding .exe to the executable name doesn't appear necessary. https://github.com/python/cpython/blob/master/Lib/distutils/spawn.py#L99

Since subprocess.check_output is where python3 is used, perhaps checking the outputs of these commands would be effective:

version = subprocess.check_output(['python3', '--version']) or subprocess.check_output(['python', '--version'])
if version is None or 'Python 3'  not in version.lower():
    print("Can't find python3 - make sure it's installed, then try again.")
    sys.exit()

Since subprocess.check_output(['python3', ...]) is the only command that appears to be used later, checking 'python' without storing it for later use may not be helpful.

malvidin avatar Oct 09 '20 09:10 malvidin

The current code base does a lot of work with strings, so I'm not sure what the level of effort would be for getting it to work under Python 3.

I'll take a look at the OS-specific behavior since that would not be too hard to fix.

kirk-sayre-work avatar Oct 18 '20 20:10 kirk-sayre-work