kjnh10 / saseg_runner

Run egp file from python
MIT License
10 stars 2 forks source link

Error saving #12

Closed eddyizm closed 4 years ago

eddyizm commented 4 years ago

I'm trying out this library instead of rolling my own subprocess script to get a few epg files automated.

System: Windows 10 Python: 3.6.0 SAS: EG 7.1 (32-bit)

It looks like process flow runs and outputs a file on the final step (.csv) but crashes when trying to save because it's missing a keyword argument 'createdexpected keyword argument 'capture_output''

Not sure if I should look in the python on the vbs script.

opening SAS Enterprise Guide 7.1rgs) as process:
-> application instance createdexpected keyword argument 'capture_output'
activating profile:[MyServer]Workspace\Weekly.SAS.Export>
-> profile:[MyServer] activated
opening C:\Users\Documents\My SAS Files\AOR\AOR.egp
-> egp file opened
running C:\Users\Documents\My SAS Files\AOR\AOR.egp
-> run finished
-> saved to C:\Users\Documents\My SAS Files\AOR\.AOR_20200606-1816.egp
getting logs from C:\Users\Documents\My SAS Files\AOR\.AOR_20200606-1816.egp
Traceback (most recent call last):
  File "extract_sas.py", line 5, in <module>
    run_egp(egp_path=SAS_script, eg_version='7.1', profile_name='MyServer', remove_log=False )
  File "C:\Python360\lib\site-packages\saseg_runner\runner.py", line 82, in run_egp
    check=True,
  File "C:\Python360\lib\subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'capture_output'
eddyizm commented 4 years ago

I commented out line 81 from runner.py

# capture_output=True,

and changed the default arguments when calling the function:

remove_log=False, overwrite=True

and I was able to run successfully and without error. If this works for you I can create a pull request to remove that line.

kjnh10 commented 4 years ago

Thanks @eddyizm

The pull request will help a lot!

eddyizm commented 4 years ago

Sounds good. I put in the PR and associated with this issue.

kjnh10 commented 4 years ago

Thanks for the kindly pull request.

I have noticed that the issue is from the python version. subprocess.run does not have capture_output parameter in python 3.6 https://stackoverflow.com/questions/53209127/subprocess-unexpected-keyword-argument-capture-output/53209196

Maybe commenting out #81 will show up the verbose output from VBS code. Since I did not want to see the log, I added the line.

So, in your pull request #13 , is it possible to try to change from deleting #81 to code like below?

    res = subprocess.run(
        f'Cscript {SCRIPTDIR_PATH}/ExtractCodeAndLog.vbs "{output}" "{eg_version}"',
        stdout=PIPE,
        stderr=PIPE.
        check=True,
    )
eddyizm commented 4 years ago

Sure thing. I'll do that and send an updated PR.

kjnh10 commented 4 years ago

Thanks, but maybe, your latest commit will fail to run since PIPE is not defined. Sorry for that I missed 'subprocess' before PIPE in my suggestion.

could you change PIPE to subprocess.PIPE in your pull request?

kjnh10 commented 4 years ago

I have released v01.1.12. plz check it works. Thanks.

eddyizm commented 4 years ago

Looks good,. Thanks!