metno / emep-ctm

Open Source EMEP/MSC-W model
GNU General Public License v3.0
27 stars 18 forks source link

catalog.py fail to untar on Python 2.6 #33

Closed mvieno closed 6 years ago

mvieno commented 6 years ago
[emep4uk@nemesis Common_4.17]$ ./catalog.py -R rv4_17
Queue download:   2.7G rv4_17input
Queue download:  21.1G meteo2015
Queue download: 715.7K rv4_17source
Queue download: 524.7K rv4_17docs
Queue download:   2.3G rv4_17output
Queue download:  26.1G Total
Do you wish to proceed? [Y]/n:Y
Untar    meteo2015        1.8G EMEP_MSC-W_model.rv4.17.OpenSource/meteo2015/EECCA/meteo201507.tar.bz2
Traceback (most recent call last):
  File "./catalog.py", line 517, in <module>
    main(parse_arguments()[0])
  File "./catalog.py", line 512, in main
    x.unpack(opts.verbose, opts.ask)
  File "./catalog.py", line 330, in unpack
    with tarfile.open(self.dst, 'r') as infile:
AttributeError: 'TarFile' object has no attribute '__exit__'
cskarby commented 6 years ago

https://github.com/metno/emep-ctm/blob/3578f91ae88362980962d868bceeedd2cdc38763/catalog.py#L330

cskarby commented 6 years ago

The user uses Python version earlier than 2.7, which added support for the "context manager" protocol (which is necessary for using the with statement) to the tarfile module. See https://stackoverflow.com/questions/6086603/statement-with-and-tarfile

mvieno commented 6 years ago

My workaround is to remove the "unpack" call in the catalog.py at the end of the python script

avaldebe commented 6 years ago

@mvieno Do you have Python 2.7 or later at your HPC? Maybe trough a module load?

avaldebe commented 6 years ago

I know that a download link would be easier, but the EMEP01 meteorology files hare so big that they need to be downloaded individually...

If you do not have Python 2.7, I'll look into untaring without with.

Also, the 2015 EECCA meteorology on this release is the same that on the previous release. So if you already have it, you do not need to download it again.

mvieno commented 6 years ago

Hi. Possibly, but instead of doing that I changed the python script skipping the automatic untar. I actually prefer untar and unzip manually. I've now also added the python2.7.

avaldebe commented 6 years ago

@mvieno I'm glad you found a solution and that you moved to Python 2.7. Python 2.6 reached end of life on 2013 and 2.7 will stay until 2020. I just committed a fix for Python 2.6, but considering how outdated it is I do not think that we should support it any longer.