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

init: Remove duplicate mapset cleaning code, use verbose #2455

Merged
merged 1 commit into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/init/grass.py
Original file line number Diff line number Diff line change
Expand Up @@ -2104,10 +2104,14 @@ def done_message():


def clean_temp():
message(_("Cleaning up temporary files..."))
nul = open(os.devnull, "w")
call([gpath("etc", "clean_temp")], stdout=nul)
nul.close()
"""Clean mapset temporary directory

Simple wrapper around the library function avoiding the need to solve imports at
the top level. This can hopefully be avoided in the future.
"""
from grass.script import setup as gsetup

gsetup.clean_temp()


def clean_all():
Expand Down
11 changes: 6 additions & 5 deletions python/grass/script/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,13 +447,14 @@ def call(cmd, **kwargs):


def clean_temp():
from grass.script import core as gcore
"""Clean mapset temporary directory"""
# Lazy-importing to reduce dependencies (this can be eventually removed).
# pylint: disable=import-outside-toplevel
import grass.script as gs

gcore.message(_("Cleaning up temporary files..."))
nul = open(os.devnull, "w")
gs.verbose(_("Cleaning up temporary files..."))
gisbase = os.environ["GISBASE"]
call([os.path.join(gisbase, "etc", "clean_temp")], stdout=nul)
nul.close()
call([os.path.join(gisbase, "etc", "clean_temp")], stdout=subprocess.DEVNULL)


def finish():
Expand Down