Skip to content

Commit

Permalink
add api-client
Browse files Browse the repository at this point in the history
  • Loading branch information
eliranwong committed Nov 6, 2024
1 parent 12f00f0 commit 0b47a98
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/
setup(
name=package,
version="0.1.59",
version="0.1.64",
python_requires=">=3.8, <3.13",
description=f"UniqueBible App is a cross-platform & offline bible application, integrated with high-quality resources and unique features. Developers: Eliran Wong and Oliver Tseng",
long_description=long_description,
Expand Down
38 changes: 21 additions & 17 deletions uniquebible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,30 @@ def isServerAlive(ip, port):
except socket.error:
return False

if isServerAlive("8.8.8.8", 53):
if hasattr(config, "checkVersionOnStartup") and config.checkVersionOnStartup:

thisPackage = "uniquebible"
if isServerAlive("8.8.8.8", 53):

print(f"Checking '{thisPackage}' version ...")
thisPackage = "uniquebible"

config.version = installed_version = getPackageInstalledVersion(thisPackage)
if installed_version is None:
print("Installed version information is not accessible!")
content = []

content.append(f"# Checked '{thisPackage}' version ...")

config.version = installed_version = getPackageInstalledVersion(thisPackage)
if installed_version is not None:
content.append(f"Installed version: {installed_version}")
latest_version = getPackageLatestVersion(thisPackage)
if latest_version is not None:
content.append(f"Latest version: {latest_version}")
if latest_version > installed_version:
content.append("Run `pip install --upgrade uniquebible` to upgrade!")
print("\n".join(content))

config.internetConnectivity = True
else:
print(f"Installed version: {installed_version}")
latest_version = getPackageLatestVersion(thisPackage)
if latest_version is None:
print("Latest version information is not accessible at the moment!")
elif installed_version is not None:
print(f"Latest version: {latest_version}")
if latest_version > installed_version:
print("Run `pip install --upgrade uniquebible` to upgrade!")

config.internetConnectivity = True
config.internetConnectivity = False
config.version = "0.0.0"

else:
config.internetConnectivity = False
config.version = "0.0.0"
2 changes: 1 addition & 1 deletion uniquebible/db/BiblesSqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ def __init__(self, text=None):
self.connection = None
self.cursor = None
self.database = os.path.join(config.marvelData, "bibles", text+".bible")
if os.path.exists(self.database):
if os.path.isfile(self.database):
self.connection = apsw.Connection(self.database)
self.connection.createscalarfunction("REGEXP", TextUtil.regexp)
self.cursor = self.connection.cursor()
Expand Down
10 changes: 10 additions & 0 deletions uniquebible/latest_changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
PIP package:

0.1.60-0.1.61

* version message displayed on console only if newer version is available.

0.1.58-0.1.59

* added commands `ub`, `ubapi`, `ubhttp`, `ubssh`, `ubtelnet` and `ubterm`. Read https://github.com/eliranwong/UniqueBible/wiki/UBA-Run-Modes

* added `api-client` mode

0.1.54-0.1.57

* added bible parameter to commands `crossreference` and `tske`.
Expand Down
6 changes: 3 additions & 3 deletions uniquebible/startup/nonGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def checkCommand(command):
def run_terminal_mode():
from uniquebible.util.LocalCliHandler import LocalCliHandler
from uniquebible.util.prompt_shared_key_bindings import prompt_shared_key_bindings
from uniquebible.util.uba_command_prompt_key_bindings import api_command_prompt_key_bindings
from uniquebible.util.uba_command_prompt_key_bindings import uba_command_prompt_key_bindings
from prompt_toolkit.key_binding import merge_key_bindings
from prompt_toolkit.shortcuts import set_title, clear_title
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
Expand All @@ -123,12 +123,12 @@ def run_terminal_mode():
config.terminalCommandDefault = ""
default = ""
# make key bindings available in config to allow futher customisation via plugins
config.key_bindings = uba_command_prompt_key_bindings
#config.key_bindings = uba_command_prompt_key_bindings
# run plugin where users may add customised key bindings
runStartupPlugins()
config.key_bindings = merge_key_bindings([
prompt_shared_key_bindings,
config.key_bindings,
uba_command_prompt_key_bindings,
])
# make sure user-customised menu contains valid item only.
# validation can only be running after, not before, running startup plugin, as some startup plugin works on command shortcuts.
Expand Down
4 changes: 4 additions & 0 deletions uniquebible/util/ConfigUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ def getCurrentVenvDir():
# Use PySide6 as Qt Library, even config.qtLibrary is set to a value other than 'pyside6'.""",
False)

setConfig("checkVersionOnStartup", """
# Check installed and latest versions on startup.""",
True)

# Start of api-client mode setting
setConfig("web_api_endpoint", """
# UniqueBible App web API endpoint.""",
Expand Down

0 comments on commit 0b47a98

Please sign in to comment.