Skip to content

Commit

Permalink
Fix python3 warnings and errors in v.surf.icw (#355)
Browse files Browse the repository at this point in the history
* fix python3 warnings
* futurize
* remove auto added python3
  • Loading branch information
smathermather committed Dec 2, 2020
1 parent db8a68e commit 93f6fe5
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions grass7/vector/v.surf.icw/v.surf.icw.py
Expand Up @@ -120,6 +120,9 @@
#% description: Number of parallel processes to launch
#%end

from __future__ import unicode_literals
from builtins import str
from builtins import range
import sys
import os
import atexit
Expand Down Expand Up @@ -148,7 +151,7 @@ def main():
where = options['where']
workers = int(options['workers'])

if workers is 1 and "WORKERS" in os.environ:
if workers == 1 and "WORKERS" in os.environ:
workers = int(os.environ["WORKERS"])
if workers < 1:
workers = 1
Expand Down Expand Up @@ -214,7 +217,7 @@ def main():

# Needed to strip away empty entries from MS Windows newlines
# list() is needed for Python 3 compatibility
points_list = list(filter(None, points_list))
points_list = list([_f for _f in points_list if _f])

# convert into a 2D list, drop unneeded cat column
# to drop cat col, add this to the end of the line [:-1]
Expand Down Expand Up @@ -284,14 +287,14 @@ def main():
start_coordinates = easting + ',' + northing,
quiet = True)
# stall to wait for the nth worker to complete,
if num % workers is 0:
if num % workers == 0:
proc[num-1].wait()

num += 1

# make sure everyone is finished
for i in range(n):
if proc[i].wait() is not 0:
if proc[i].wait() != 0:
grass.fatal(_('Problem running %s') % 'r.cost')


Expand All @@ -310,13 +313,13 @@ def main():
cost_n_cleansed = cost_site_name + '.cleansed',
cost_n = cost_site_name, quiet = True)
# stall to wait for the nth worker to complete,
if (i+1) % workers is 0:
if (i+1) % workers == 0:
#print 'stalling ...'
proc[i].wait()

# make sure everyone is finished
for i in range(n):
if proc[i].wait() is not 0:
if proc[i].wait() != 0:
grass.fatal(_('Problem running %s') % 'r.mapcalc')


Expand Down Expand Up @@ -352,7 +355,7 @@ def main():
friction = friction,
quiet = True)
# stall to wait for the nth worker to complete,
if (i+1) % workers is 0:
if (i+1) % workers == 0:
#print 'stalling ...'
proc[i].wait()

Expand All @@ -361,7 +364,7 @@ def main():

# make sure everyone is finished
for i in range(n):
if proc[i].wait() is not 0:
if proc[i].wait() != 0:
grass.fatal(_('Problem running %s') % 'r.mapcalc')

grass.run_command('g.remove', flags = 'f', type = 'raster',
Expand Down Expand Up @@ -453,7 +456,7 @@ def main():
quiet = True)

# stall to wait for the nth worker to complete,
if num % workers is 0:
if num % workers == 0:
proc[num-1].wait()

# free up disk space ASAP
Expand Down

0 comments on commit 93f6fe5

Please sign in to comment.