Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getOperators() doesn't work with Python from within Cygwin on Windows #14

Closed
andreas-h opened this issue Sep 26, 2017 · 4 comments
Closed

Comments

@andreas-h
Copy link

For Windows there are Cygwin64 CDO binaries available. When trying to use these I have the problem that the getOperators() function doesn't work properly. The culprit seems to be that the output of cdo --operators is being split at os.linesep (see, e.g., https://github.com/Try2Code/cdo-bindings/blob/master/python/cdo.py#L305). However, os.linesep on Windows is \r\n, while the output of the cdo --operators call is only separated by \n.

I guess it should be possible to use something like (pseudo-code)

if on_cygwin:
    cdosep = '\n'
else:
    cdosep = os.linesep

and then use cdosep instead of os.linesep.

Would you be open to a PR implementing this?

@Try2Code
Copy link
Owner

Hi!
I (hopefully) fixed this with the latest release 1.3.4? Could you give it a try?

thx in advance

@andreas-h
Copy link
Author

andreas-h commented Sep 27, 2017

Thanks for your quick reply! I Installed the 1.3.4 package from Anaconda (btw, the cdo.py still reads 1.3.3), but it doesn't work properly:

In [1]: from cdo import Cdo
Could not load xarray
In [2]: cdo = Cdo()
In [3]: cdo.operators
Out[3]: ['abs']
In [4]: cdo.__version__()
Out[4]: '1.3.3'
In [5]: cdo.version()
Out[5]: '1.8.2'

The same is true for the 1.9.0 binary.

@Try2Code
Copy link
Owner

Ah, now I see. I though you would use the latest release, which has other problems concerning the operator listing.

I guess, the problem does not occur if you hard-code the separator to '\n'. the listing given by CDO itself does not make use of '\r\n' at all. I think the use of 'os.linesep' might have been a really bad type of optimization.
I do not check on cygwin regularly - so it would be nice you could test it for me ;-)

@Try2Code
Copy link
Owner

Some recent testing of the current release 1.4.0 did not reveal this behavior - so I think the ticket can be closed. @andreas-h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants