diff options
| author | Lex Neva <github.com@lexneva.name> | 2020-08-19 14:53:01 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2020-08-19 14:53:01 -0400 |
| commit | 690ee0c416635f8d6d3dc07048be90bd0da7748f (patch) | |
| tree | 8351dd7ffa0aee40e6409d29fda7577bf1f04a95 /lib/api/install.py | |
| parent | 1631428ae44465ee96b7a283d7fec8cde1a68d73 (diff) | |
wip: move install extension to electron
Diffstat (limited to 'lib/api/install.py')
| -rw-r--r-- | lib/api/install.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/api/install.py b/lib/api/install.py new file mode 100644 index 00000000..f379f142 --- /dev/null +++ b/lib/api/install.py @@ -0,0 +1,42 @@ +import os +import sys +from glob import glob + +from flask import Blueprint, request + +from ..utils import get_bundled_dir, guess_inkscape_config_path + +install = Blueprint('install', __name__) + + +@install.route('/palettes') +def palettes(): + base_path = request.json.get('path') or guess_inkscape_config_path() + path = os.path.join(base_path, 'palettes') + src_dir = get_bundled_dir('palettes') + copy_files(glob(os.path.join(src_dir, "*")), path) + + +if sys.platform == "win32": + # If we try to just use shutil.copy it says the operation requires elevation. + def copy_files(files, dest): + import winutils + + if not os.path.exists(dest): + os.makedirs(dest) + + winutils.copy(files, dest) +else: + def copy_files(files, dest): + import shutil + + if not os.path.exists(dest): + os.makedirs(dest) + + for palette_file in files: + shutil.copy(palette_file, dest) + + +@install.route('/default-path') +def default_path(): + return guess_inkscape_config_path() |
