Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
hru-delin-dev
hru-delin-qgis
Commits
0d9c4b97
Unverified
Commit
0d9c4b97
authored
Apr 22, 2020
by
Julien Veyssier
Browse files
first attempt to make it work on windows
Signed-off-by:
Julien Veyssier
<
eneiluj@posteo.net
>
parent
aabefe6b
Changes
3
Hide whitespace changes
Inline
Side-by-side
hrudelinCore
@
8523d22d
Compare
aa544b71
...
8523d22d
Subproject commit
aa544b714214402ba57a1c3f0d621e9fe4c5cd36
Subproject commit
8523d22dc5031077c333c1ed452f8c96d4878d9d
hrudelin_dockwidget.py
View file @
0d9c4b97
...
...
@@ -506,7 +506,7 @@ class HruDelinDockWidget(QtWidgets.QDockWidget, FORM_CLASS):
def
step2FinishedAuto
(
self
):
self
.
step2Finished
()
# launch all maps generation
self
.
doStep3
(
False
,
self
.
step3FinishedAuto
)
#
self.doStep3(False, self.step3FinishedAuto)
def
step3FinishedAuto
(
self
):
self
.
step3Finished
()
...
...
@@ -907,7 +907,8 @@ class HruDelinDockWidget(QtWidgets.QDockWidget, FORM_CLASS):
'type'
:
'raster'
,
'path'
:
strPath
,
'name'
:
os
.
path
.
basename
(
strPath
).
replace
(
'step1_'
,
''
),
'tag'
:
'step1'
'tag'
:
'step1'
,
'zoom'
:
(
os
.
path
.
basename
(
strPath
)
==
'step1_dem_cut.tif'
)
})
for
fPath
in
Path
(
self
.
cfgFilesOutPath
).
rglob
(
'*step1*.shp'
):
strPath
=
str
(
fPath
)
...
...
pluginUtils/tools.py
View file @
0d9c4b97
import
platform
import
os
,
sys
from
pathlib
import
Path
import
subprocess
def
isWindows
():
plat
=
platform
.
system
()
...
...
@@ -33,45 +34,60 @@ def split_list(alist, wanted_parts=1):
for
i
in
range
(
wanted_parts
)
]
def
prepareGrassEnv
():
grassBasePath
=
None
# sys.path (to be able to import grass.script)
# find grass depending on the system
if
isWindows
():
pass
for
grassVersion
in
[
'74'
,
'75'
,
'76'
,
'77'
,
'78'
,
'79'
]:
try
:
grassBasePath
=
subprocess
.
check_output
([
'grass%s.bat'
%
grassVersion
,
'--config'
,
'path'
],
shell
=
True
).
decode
(
'utf-8'
).
rstrip
(
os
.
linesep
)
break
except
Exception
as
e
:
pass
print
(
'found winwin %s !!!'
%
grassBasePath
)
elif
isMac
():
pass
else
:
for
grassVersion
in
[
'74'
,
'75'
,
'76'
,
'77'
,
'78'
,
'79'
]:
findRes
=
list
(
Path
(
'/usr/lib/grass%s'
%
grassVersion
).
rglob
(
'*r.thin*'
))
if
len
(
findRes
)
>
0
:
thinPath
=
str
(
findRes
[
0
])
grassBasePath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
thinPath
))
grassPythonPath
=
os
.
path
.
join
(
grassBasePath
,
'etc'
,
'python'
)
if
grassPythonPath
not
in
sys
.
path
:
sys
.
path
.
append
(
grassPythonPath
)
break
os
.
environ
[
'GISBASE'
]
=
grassBasePath
grassBasePath
=
subprocess
.
check_output
([
'grass'
,
'--config'
,
'path'
]).
decode
(
'utf-8'
).
rstrip
(
os
.
linesep
)
print
(
'found first %s !!!'
%
grassBasePath
)
if
grassBasePath
==
None
:
for
grassVersion
in
[
'74'
,
'75'
,
'76'
,
'77'
,
'78'
,
'79'
]:
findRes
=
list
(
Path
(
'/usr/lib/grass%s'
%
grassVersion
).
rglob
(
'*r.thin*'
))
if
len
(
findRes
)
>
0
:
thinPath
=
str
(
findRes
[
0
])
grassBasePath
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
thinPath
))
break
if
grassBasePath
==
None
:
print
(
'GRASS not found on your system'
)
return
grassPythonPath
=
os
.
path
.
join
(
grassBasePath
,
'etc'
,
'python'
)
if
grassPythonPath
not
in
sys
.
path
:
sys
.
path
.
append
(
grassPythonPath
)
os
.
environ
[
'GISBASE'
]
=
grassBasePath
libPathToAdd
=
os
.
path
.
join
(
grassBasePath
,
'lib'
)
existingLdLibraryPath
=
''
if
'LD_LIBRARY_PATH'
in
os
.
environ
:
existingLdLibraryPath
=
os
.
environ
[
'LD_LIBRARY_PATH'
]
if
libPathToAdd
not
in
existingLdLibraryPath
.
split
(
':'
):
os
.
environ
[
'LD_LIBRARY_PATH'
]
=
'%s:%s'
%
(
existingLdLibraryPath
,
libPathToAdd
)
existingPYTHONPATH
=
''
if
'PYTHONPATH'
in
os
.
environ
:
existingPYTHONPATH
=
os
.
environ
[
'PYTHONPATH'
]
if
grassPythonPath
not
in
existingPYTHONPATH
.
split
(
':'
):
os
.
environ
[
'PYTHONPATH'
]
=
'%s:%s'
%
(
existingPYTHONPATH
,
grassPythonPath
)
py
PathToAdd
=
os
.
path
.
join
(
grassBasePath
,
'
etc'
,
'python
'
)
existing
PYTHONPATH
=
''
if
'
PYTHON
PATH'
in
os
.
environ
:
existing
PYTHONPATH
=
os
.
environ
[
'
PYTHON
PATH'
]
if
py
PathToAdd
not
in
existing
PYTHONPATH
.
split
(
':'
):
os
.
environ
[
'
PYTHON
PATH'
]
=
'%s:%s'
%
(
existing
PYTHONPATH
,
py
PathToAdd
)
lib
PathToAdd
=
os
.
path
.
join
(
grassBasePath
,
'
lib
'
)
existing
LdLibraryPath
=
''
if
'
LD_LIBRARY_
PATH'
in
os
.
environ
:
existing
LdLibraryPath
=
os
.
environ
[
'
LD_LIBRARY_
PATH'
]
if
lib
PathToAdd
not
in
existing
LdLibraryPath
.
split
(
':'
):
os
.
environ
[
'
LD_LIBRARY_
PATH'
]
=
'%s:%s'
%
(
existing
LdLibraryPath
,
lib
PathToAdd
)
grassBinPath
=
os
.
path
.
join
(
grassBasePath
,
'bin'
)
grassScriptPath
=
os
.
path
.
join
(
grassBasePath
,
'scripts'
)
existingPath
=
''
if
'PATH'
in
os
.
environ
:
existingPath
=
os
.
environ
[
'PATH'
]
if
grassBinPath
not
in
existingPath
.
split
(
':'
):
os
.
environ
[
'PATH'
]
=
'%s:%s'
%
(
existingPath
,
grassBinPath
)
existingPath
=
os
.
environ
[
'PATH'
]
if
grassScriptPath
not
in
existingPath
.
split
(
':'
):
os
.
environ
[
'PATH'
]
=
'%s:%s'
%
(
existingPath
,
grassScriptPath
)
\ No newline at end of file
grassBinPath
=
os
.
path
.
join
(
grassBasePath
,
'bin'
)
grassScriptPath
=
os
.
path
.
join
(
grassBasePath
,
'scripts'
)
existingPath
=
''
if
'PATH'
in
os
.
environ
:
existingPath
=
os
.
environ
[
'PATH'
]
if
grassBinPath
not
in
existingPath
.
split
(
':'
):
os
.
environ
[
'PATH'
]
=
'%s:%s'
%
(
existingPath
,
grassBinPath
)
existingPath
=
os
.
environ
[
'PATH'
]
if
grassScriptPath
not
in
existingPath
.
split
(
':'
):
os
.
environ
[
'PATH'
]
=
'%s:%s'
%
(
existingPath
,
grassScriptPath
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment