-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
67 lines (61 loc) · 2.88 KB
/
__init__.py
File metadata and controls
67 lines (61 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
"""
/***************************************************************************
FireScarMapper
A QGIS plugin
Generate georeferenced fire scar rasters using a pre-trained U-Net model and analyze the impact of fire events by comparing pre- and post-fire satellite images.
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2024-11-25
copyright : (C) 2024 by Fire 2A
email : N/A
git sha : $Format:%H$
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
This script initializes the plugin, making it known to QGIS.
"""
# noinspection PyPep8Naming
def classFactory(iface): # pylint: disable=invalid-name
"""Load FireScarMapper class from file FireScarMapper.
:param iface: A QGIS interface instance.
:type iface: QgsInterface
"""
# Auto-generate resources.py if missing or outdated
try:
import os, subprocess
plugin_dir = os.path.dirname(__file__)
qrc_path = os.path.join(plugin_dir, "resources.qrc")
res_path = os.path.join(plugin_dir, "resources.py")
needs_rebuild = (
not os.path.exists(res_path) or
os.path.getmtime(qrc_path) > os.path.getmtime(res_path)
)
if needs_rebuild:
result = subprocess.run(
["pyrcc5", qrc_path, "-o", res_path],
capture_output=True, text=True
)
if result.returncode == 0:
print("✅ resources.py generated successfully.")
else:
print(f"⚠️ pyrcc5 failed: {result.stderr}")
except Exception as e:
import traceback
print("resources.py auto-generation failed:", traceback.format_exc())
#Import and execute dependencies handler
try:
from . import dependencies_handler
dependencies_handler.run()
except Exception as e:
# No falla la carga del plugin si el handler falla por algún motivo
import traceback
print("Dependency handler failed:", traceback.format_exc())
from .firescarmapper import FireScarMapper
return FireScarMapper(iface)