generated from kamangir/blue-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
900 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#! /usr/bin/env bash | ||
|
||
export abcli_QGIS_path_profile="$HOME/Library/Application Support/QGIS/QGIS3/profiles/default" | ||
export abcli_QGIS_path_expressions=$abcli_QGIS_path_profile/python/expressions | ||
export abcli_QGIS_path_expressions_git=$abcli_path_git/blue-geo/blue_geo/QGIS/expressions | ||
export abcli_QGIS_path_templates=$abcli_QGIS_path_profile/project_templates | ||
export abcli_QGIS_path_shared=$HOME/Downloads/QGIS | ||
export abcli_QGIS_path_server=$abcli_QGIS_path_shared/server | ||
|
||
mkdir -p $abcli_QGIS_path_server | ||
|
||
function QGIS() { | ||
blue_geo_QGIS "$@" | ||
} | ||
|
||
# internal function to abcli_seed. | ||
function QGIS_seed() { | ||
# seed is NOT local | ||
seed=$(python3 -m blue_geo.QGIS generate_seed) | ||
} | ||
|
||
function blue_geo_QGIS() { | ||
local task=$(abcli_unpack_keyword $1 help) | ||
|
||
if [ $task == "help" ]; then | ||
abcli_show_usage "QGIS seed [screen]" \ | ||
"seed 🌱 QGIS." | ||
|
||
blue_geo_QGIS_expressions "$@" | ||
blue_geo_QGIS_server "$@" | ||
return | ||
fi | ||
|
||
local function_name=blue_geo_QGIS_$task | ||
if [[ $(type -t $function_name) == "function" ]]; then | ||
$function_name "${@:2}" | ||
return | ||
fi | ||
|
||
if [ "$task" == "seed" ]; then | ||
abcli_seed QGIS "${@:2}" | ||
return | ||
fi | ||
|
||
abcli_log_error "-QGIS: $task: command not found." | ||
return 1 | ||
} | ||
|
||
abcli_source_path - caller,suffix=/QGIS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_QGIS_expressions() { | ||
local task=$1 | ||
|
||
if [ "$task" == help ]; then | ||
abcli_show_usage "QGIS expressions pull" \ | ||
"pull QGIS expressions." | ||
abcli_show_usage "QGIS expressions push [push]" \ | ||
"push QGIS expressions." | ||
|
||
abcli_log " 📂 $abcli_QGIS_path_expressions" | ||
abcli_log " 📂 $abcli_QGIS_path_expressions_git" | ||
return | ||
fi | ||
|
||
if [[ "$task" == pull ]]; then | ||
rsync -av \ | ||
"$abcli_QGIS_path_expressions_git/" \ | ||
"$abcli_QGIS_path_expressions/" | ||
return | ||
fi | ||
|
||
if [[ "$task" == push ]]; then | ||
local options=$2 | ||
local do_push=$(abcli_option_int "$options" push 0) | ||
|
||
rsync -av \ | ||
--exclude='__pycache__' \ | ||
--exclude='default.py' \ | ||
--exclude='__init__.py' \ | ||
"$abcli_QGIS_path_expressions/" \ | ||
"$abcli_QGIS_path_expressions_git/" | ||
|
||
if [[ "$do_push" == 1 ]]; then | ||
abcli_git blue-geo push \ | ||
"$(python3 -m blue_geo version) QGIS expressions" | ||
else | ||
abcli_git blue-geo status ~all | ||
fi | ||
|
||
return | ||
fi | ||
|
||
abcli_log_error "-QGIS: expressions: $task: command not found." | ||
return 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_QGIS_serve() { | ||
blue_geo_QGIS_server "$@" | ||
} | ||
|
||
function blue_geo_QGIS_server() { | ||
local options=$1 | ||
if [ $(abcli_option_int "$options" help 0) == 1 ]; then | ||
abcli_show_usage "QGIS serve[r] [start]" \ | ||
"start QGIS server." | ||
return | ||
fi | ||
|
||
local prompt="🌐 $(blue_geo version).QGIS server ... (^C to stop)" | ||
abcli_log $prompt | ||
|
||
local filename | ||
cd $abcli_QGIS_path_server | ||
while true; do | ||
sleep 1 | ||
for filename in *.command; do | ||
if [ -e "$filename" ]; then | ||
local command=$(cat $filename) | ||
abcli_log "$filename: $command" | ||
|
||
abcli_eval - "$command" | ||
rm -v $filename | ||
|
||
abcli_log $prompt | ||
fi | ||
done | ||
done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from blue_geo import NAME | ||
|
||
NAME = f"{NAME}.QGIS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import argparse | ||
from blue_geo.QGIS import NAME | ||
from blue_geo import VERSION | ||
from blue_geo.QGIS.seed import generate_seed | ||
from blue_geo.logger import logger | ||
from blueness.argparse.generic import sys_exit | ||
|
||
|
||
parser = argparse.ArgumentParser( | ||
f"python3 -m {NAME}", | ||
description=f"{NAME}-{VERSION}", | ||
) | ||
parser.add_argument( | ||
"task", | ||
type=str, | ||
help="generate_seed", | ||
) | ||
args = parser.parse_args() | ||
|
||
success = False | ||
if args.task == "generate_seed": | ||
success = seed = generate_seed() | ||
if success: | ||
print(seed) | ||
else: | ||
success = None | ||
|
||
sys_exit(logger, NAME, args.task, success) |
Oops, something went wrong.