Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/OSGeo/grass-addons
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Ullah committed Jun 7, 2020
2 parents 63c2200 + 96edddd commit 0bbe2f9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
34 changes: 33 additions & 1 deletion grass7/imagery/i.modis/i.modis.import/i.modis.import.py
Expand Up @@ -142,6 +142,11 @@ def list_files(opt, mosaik=False):
# read the file with the list of HDF
if opt['files'] != '':
if os.path.exists(opt['files']):
if os.path.splitext(opt['files'])[-1].lower() == '.hdf':
grass.fatal(_("Option <{}> assumes file with list of HDF files. "
"Use option <{}> to import a single HDF file").format(
'files', 'input'
))
listoffile = open(opt['files'], 'r')
basedir = os.path.split(listoffile.name)[0]
else:
Expand All @@ -163,6 +168,7 @@ def list_files(opt, mosaik=False):
filelist[day].append(line.strip())
else:
filelist[day] = [line.strip()]
listoffile.close()
# create a list for each file
elif options['input'] != '':
filelist = [options['input']]
Expand Down Expand Up @@ -350,7 +356,13 @@ def single(options, remove, an, ow, fil):
except:
grass.fatal("pymodis library is not installed")
listfile, basedir = list_files(options)
if not listfile:
grass.warning(_("No HDF files found"))
return

# for each file
count = len(listfile)
idx = 1
for i in listfile:
if os.path.exists(i):
hdf = i
Expand All @@ -360,7 +372,19 @@ def single(options, remove, an, ow, fil):
if not os.path.exists(hdf):
grass.warning(_("%s not found" % i))
continue
pm = parseModis(hdf)

grass.message(_("Proccessing <{f}> ({i}/{c})...").format(
f=os.path.basename(hdf), i=idx, c=count))
grass.percent(idx, count, 5)
idx += 1

try:
pm = parseModis(hdf)
except OSError:
grass.fatal(_("<{}> is not a HDF file").format(
hdf
))
continue
if options['mrtpath']:
# create conf file fro mrt tools
confname = confile(pm, options, an)
Expand Down Expand Up @@ -409,7 +433,15 @@ def mosaic(options, remove, an, ow, fil):
dictfile, targetdir = list_files(options, True)
pid = str(os.getpid())
# for each day
count = len(dictfile.keys())
idx = 1
for dat, listfiles in dictfile.items():
grass.message(_("Processing <{d}> ({i}/{c})...").format(
d=dat, i=idx, c=count
))
grass.percent(idx, count, 5)
idx += 1

pref = listfiles[0].split(os.path.sep)[-1]
prod = product().fromcode(pref.split('.')[0])
spectr = spectral(options, prod, an)
Expand Down
6 changes: 3 additions & 3 deletions tools/transifex_merge.sh
Expand Up @@ -2,12 +2,12 @@

# GRASS GIS transifex support script: fetches msg from transifex
# Luca Delucchi 2017, based on gettext message merge procedure by Markus Neteler
# - keep headers added by Markus
# - keep headers added by Markus
# 2018, grass72 -> grass7

# Required installation:
# see
# https://grasswiki.osgeo.org/wiki/GRASS_messages_translation#Get_the_translated_po_files
# sudo pip3 install transifex-client
# see also: https://grasswiki.osgeo.org/wiki/GRASS_messages_translation#Get_the_translated_po_files

# Usage:
# this script has to be launched in the `locale/` directory.
Expand Down

0 comments on commit 0bbe2f9

Please sign in to comment.