Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2@file
3@brief Various functions to install `SQLiteSpy <http://www.yunqa.de/delphi/doku.php/products/sqlitespy/index>`_.
4"""
5from __future__ import print_function
6import sys
7import re
8import os
10from ..installhelper.install_cmd_helper import unzip_files
11from ..installhelper.link_shortcuts import add_shortcut_to_desktop
12from .install_custom import download_page, download_from_sourceforge, DownloadException, download_file
15def IsSQLiteSpyInstalled(dest_folder):
16 """
17 Checks if :epkg:`SQLiteSpy` was already installed
19 @param dest_folder where it was installed
20 @return boolean
21 """
22 if sys.platform.startswith("win"):
23 file = os.path.join(dest_folder, "SQLiteSpy.exe")
24 return os.path.exists(file)
25 else:
26 raise NotImplementedError("not available on platform " + sys.platform)
29def install_sqlitespy(temp_folder=".", fLOG=print, install=True, version=None, backup=False):
30 """
31 Installs :epkg:`SQLiteSpy`.
32 It does not do it a second time if it is already installed.
34 @param temp_folder where to download the setup
35 @param fLOG logging function
36 @param install install (otherwise only download)
37 @param version version to install (unused)
38 @return temporary file
39 """
40 if version is not None:
41 raise ValueError("cannot specify a version")
42 if IsSQLiteSpyInstalled(temp_folder):
43 return os.path.join(temp_folder, "SQLiteSpy.exe")
45 link = "https://www.yunqa.de/delphi/products/sqlitespy/index"
46 outfile = None
47 try:
48 page = download_page(link)
49 except DownloadException as e:
50 if backup and sys.platform.startswith("win"):
51 link = "http://www.xavierdupre.fr/enseignement/setup/SQLiteSpy_1.9.12.zip"
52 fLOG("[pymy] download ", link)
53 outfile = os.path.join(temp_folder, "SQLiteSpy_1.9.12.zip")
54 download_file(link, outfile)
55 version = "1.9.12"
56 fLOG("[pymy] SQLiteSpy, version ", version)
57 else:
58 raise e
60 if sys.platform.startswith("win"):
61 if outfile is None:
62 reg = re.compile(
63 "href=[\\\"'](https://www.yunqa.de/delphi/downloads/SQLiteSpy.*?[.]zip)[\\\"']")
64 alls = reg.findall(page)
65 if len(alls) == 0:
66 raise Exception(
67 "Unable to find a link on a .zip file on page: " + page)
69 file = alls[0].replace("&", "&")
70 full = file
71 version = file.split("_")[-1].replace(".zip", "")
72 fLOG("[pymy] SQLiteSpy, version ", version)
73 outfile = os.path.join(
74 temp_folder, "{0}_{1}.zip".format("SQLiteSpy", version))
75 fLOG("[pymy] download ", full)
76 download_from_sourceforge(
77 full, outfile, temp_folder=temp_folder, fLOG=fLOG)
78 if install:
79 files = unzip_files(outfile, temp_folder, fLOG=fLOG)
80 local = [f for f in files if f.endswith(".exe")][0]
81 return local
82 else:
83 return outfile
84 else:
85 raise NotImplementedError("not available on platform " + sys.platform)
88def add_shortcut_to_desktop_for_sqlitespy(exe):
89 """
90 create a shortcut on your desktop
92 @param exe exe location (SQLiteSpy.exe)
93 @return filename
94 """
95 return add_shortcut_to_desktop(exe, "SQLiteSpy", "SQLiteSpy")