Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • cebash/sakia
  • santiago/sakia
  • jonas/sakia
3 results
Select Git revision
Loading items
Show changes
Showing
with 11070 additions and 21550 deletions
#!/bin/bash #!/bin/bash
#__version_info__ = ('0', '20', '0dev6') #__version_info__ = ('0', '20', '0dev6')
current=`grep -P "__version_info__ = \(\'\d+\', \'\d+\', \'\d+(\w*)\'\)" src/sakia/__init__.py | grep -oP "\'\d+\', \'\d+\', \'\d+(\w*)\'"` current=`grep -P "__version_info__ = \(\"\d+\", \"\d+\", \"\d+(\w*)\"\)" src/sakia/__init__.py | grep -oP "\"\d+\", \"\d+\", \"\d+(\w*)\""`
echo "Current version: $current" echo "Current version: $current"
if [[ $1 =~ ^[0-9]+.[0-9]+.[0-9]+[0-9A-Za-z]*$ ]]; then if [[ $1 =~ ^[0-9]+.[0-9]+.[0-9]+[0-9A-Za-z]*$ ]]; then
IFS='.' read -r -a array <<< "$1" IFS='.' read -r -a array <<< "$1"
sed -i "s/__version_info__\ = ($current)/__version_info__ = ('${array[0]}', '${array[1]}', '${array[2]}')/g" src/sakia/__init__.py sed -i "s/__version_info__\ = ($current)/__version_info__ = (\"${array[0]}\", \"${array[1]}\", \"${array[2]}\")/g" src/sakia/__init__.py
sed -i "s/#define MyAppVerStr .*/#define MyAppVerStr \"$1\"/g" ci/appveyor/sakia.iss sed -i "s/#define MyAppVerStr .*/#define MyAppVerStr \"$1\"/g" ci/appveyor/sakia.iss
sed -i "s/Version: .*/Version: $1/g" ci/travis/debian/DEBIAN/control sed -i "s/Version: .*/Version: $1/g" ci/travis/debian/DEBIAN/control
sed -i "s/Version=.*/Version=$1/g" res/linux/usr/share/applications/sakia.desktop sed -i "s/Version=.*/Version=$1/g" res/linux/usr/share/applications/sakia.desktop
git commit src/sakia/__init__.py ci/appveyor/sakia.iss ci/travis/debian/DEBIAN/control res/linux/usr/share/applications/sakia.desktop -m "$1" sed -i "s/version=.*/version=$1/g" ci/appimage/config.env
git commit src/sakia/__init__.py ci/appveyor/sakia.iss ci/travis/debian/DEBIAN/control res/linux/usr/share/applications/sakia.desktop ci/appimage/config.env -m "$1"
git tag "$1" -a -m "$1" git tag "$1" -a -m "$1"
else else
echo "Wrong version format" echo "Wrong version format"
......
quamash pypeg2
asynctest aiohttp==3.6.2
networkx async-timeout==3.0.1
attrs attrs==19.3.0
duniter-mirage duniterpy==0.58.1
duniterpy>=0.40 jsonschema==3.2.0
pytest networkx==2.4
pytest-asyncio<0.6 PyQt5==5.9.2
pyyaml PyYAML==5.3
aiohttp Quamash==0.6.1
async_timeout
PyQt5>=5.9,<5.10
\ No newline at end of file
setuptools>=46.0.0
wheel
twine
\ No newline at end of file
black==20.8b1
duniter-mirage>=0.1.50
mypy==0.770
pylint==2.4.4
pytest
pytest-asyncio
md-to-html
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
[Desktop Entry] [Desktop Entry]
Version=0.32.10post1 Version=0.53.2
Name=Sakia Name=Sakia
Comment=Duniter Qt Client Comment=Duniter Qt Client
Exec=sakia Exec=sakia
......
...@@ -81,7 +81,7 @@ else: ...@@ -81,7 +81,7 @@ else:
debug=True, debug=True,
strip=False, strip=False,
upx=True, upx=True,
console=True, console=False,
icon='sakia.ico') icon='sakia.ico')
......
from setuptools import setup, find_packages from setuptools import setup, find_packages
import os import os
import re import re
import subprocess
import sys import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'src'))) sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')))
import sakia import sakia
...@@ -26,11 +27,22 @@ def which(program): ...@@ -26,11 +27,22 @@ def which(program):
return None return None
path = os.path.abspath(os.path.join(os.path.dirname(__file__)))
subprocess.call(
"python {0}/gen_resources.py".format(path), shell=True
)
subprocess.call(
"python {0}/gen_translations.py".format(path), shell=True
)
EDITABLE_REQUIREMENT = re.compile(r'^-e (?P<link>(?P<vcs>git|svn|hg|bzr).+#egg=(?P<package>.+)-(?P<version>\d(?:\.\d)*))$') EDITABLE_REQUIREMENT = re.compile(r'^-e (?P<link>(?P<vcs>git|svn|hg|bzr).+#egg=(?P<package>.+)-(?P<version>\d(?:\.\d)*))$')
install_requires = [] install_requires = []
dependency_links = [] dependency_links = []
data_files = [('sakia', ['src/sakia/root_servers.yml', 'src/sakia/g1_licence.html'])] data_files = [('sakia', ['src/sakia/root_servers.yml', 'src/sakia/g1_license.html'])]
for requirement in (l.strip() for l in open('requirements.txt')): for requirement in (l.strip() for l in open('requirements.txt')):
match = EDITABLE_REQUIREMENT.match(requirement) match = EDITABLE_REQUIREMENT.match(requirement)
...@@ -61,6 +73,7 @@ setup( ...@@ -61,6 +73,7 @@ setup(
description="A [duniter](https://github.com/duniter/duniter) Python client", description="A [duniter](https://github.com/duniter/duniter) Python client",
long_description=open('README.md').read(), long_description=open('README.md').read(),
long_description_content_type="text/markdown",
# Active la prise en compte du fichier MANIFEST.in # Active la prise en compte du fichier MANIFEST.in
include_package_data=True, include_package_data=True,
......
__version_info__ = ('0', '32', '10post1') __version_info__ = ("0", "53", "2")
__version__ = '.'.join(__version_info__) __version__ = ".".join(__version_info__)
import os
import shutil
import attr import attr
import datetime import datetime
import logging import logging
import socket import socket
import yaml
import sakia.i18n_rc import sakia.i18n_rc
import async_timeout import async_timeout
import aiohttp import aiohttp
from PyQt5.QtCore import QObject, pyqtSignal, QTranslator, QCoreApplication, QLocale, Qt from PyQt5.QtCore import (
QObject,
pyqtSignal,
QTranslator,
QCoreApplication,
QLocale,
Qt,
QFile,
)
from . import __version__ from . import __version__
from .options import SakiaOptions from sakia.constants import GITLAB_RELEASES_API_URL, GITLAB_RELEASES_PAGE_URL
from sakia.options import SakiaOptions
from sakia.data.connectors import BmaConnector from sakia.data.connectors import BmaConnector
from sakia.services import NetworkService, BlockchainService, IdentitiesService, \ from sakia.services import (
SourcesServices, TransactionsService, DocumentsService NetworkService,
BlockchainService,
IdentitiesService,
SourcesServices,
TransactionsService,
DocumentsService,
)
from sakia.data.repositories import SakiaDatabase from sakia.data.repositories import SakiaDatabase
from sakia.data.entities import Transaction, Connection, Identity, Dividend from sakia.data.entities import Transaction, Connection, Identity, Dividend
from sakia.data.processors import BlockchainProcessor, NodesProcessor, IdentitiesProcessor, \ from sakia.data.processors import (
CertificationsProcessor, SourcesProcessor, TransactionsProcessor, ConnectionsProcessor, DividendsProcessor BlockchainProcessor,
NodesProcessor,
IdentitiesProcessor,
CertificationsProcessor,
SourcesProcessor,
TransactionsProcessor,
ConnectionsProcessor,
DividendsProcessor,
)
from sakia.data.files import AppDataFile, UserParametersFile, PluginsDirectory from sakia.data.files import AppDataFile, UserParametersFile, PluginsDirectory
from sakia.decorators import asyncify from sakia.decorators import asyncify
from sakia.money import * from sakia.money import *
...@@ -61,10 +90,11 @@ class Application(QObject): ...@@ -61,10 +90,11 @@ class Application(QObject):
loop = attr.ib() loop = attr.ib()
options = attr.ib() options = attr.ib()
app_data = attr.ib() app_data = attr.ib()
parameters = attr.ib() root_servers = attr.ib(default=None)
db = attr.ib() parameters = attr.ib(default=None)
currency = attr.ib() db = attr.ib(default=None)
plugins_dir = attr.ib() currency = attr.ib(default=None)
plugins_dir = attr.ib(default=None)
network_service = attr.ib(default=None) network_service = attr.ib(default=None)
blockchain_service = attr.ib(default=None) blockchain_service = attr.ib(default=None)
identities_service = attr.ib(default=None) identities_service = attr.ib(default=None)
...@@ -72,9 +102,10 @@ class Application(QObject): ...@@ -72,9 +102,10 @@ class Application(QObject):
transactions_service = attr.ib(default=None) transactions_service = attr.ib(default=None)
documents_service = attr.ib(default=None) documents_service = attr.ib(default=None)
current_ref = attr.ib(default=Quantitative) current_ref = attr.ib(default=Quantitative)
_logger = attr.ib(default=attr.Factory(lambda:logging.getLogger('sakia'))) _logger = attr.ib(default=attr.Factory(lambda: logging.getLogger("sakia")))
available_version = attr.ib(init=False) available_version = attr.ib(init=False)
_translator = attr.ib(init=False) _translator = attr.ib(init=False)
_qt_translator = attr.ib(init=False)
def __attrs_post_init__(self): def __attrs_post_init__(self):
super().__init__() super().__init__()
...@@ -86,21 +117,56 @@ class Application(QObject): ...@@ -86,21 +117,56 @@ class Application(QObject):
qapp.setAttribute(Qt.AA_EnableHighDpiScaling, True) qapp.setAttribute(Qt.AA_EnableHighDpiScaling, True)
options = SakiaOptions.from_arguments(argv) options = SakiaOptions.from_arguments(argv)
app_data = AppDataFile.in_config_path(options.config_path).load_or_init() app_data = AppDataFile.in_config_path(options.config_path).load_or_init()
app = cls(qapp, loop, options, app_data, None, None, options.currency, None) app = cls(
qapp, loop, options, app_data, None, None, None, options.currency, None
)
app.load_root_servers()
# app.set_proxy() # app.set_proxy()
app.load_profile(options.profile) app.load_profile(options.profile)
app.documents_service = DocumentsService.instanciate(app) app.documents_service = DocumentsService.instanciate(app)
app.switch_language() app.switch_language()
return app return app
def load_root_servers(self):
"""
Load root servers config
:return:
"""
filename = "root_servers.yml"
root_servers_default_path = os.path.join(os.path.dirname(__file__), filename)
root_servers_config_path = os.path.join(self.options.config_path, filename)
self._logger.debug(
"Check root servers config file: {}...".format(root_servers_config_path)
)
if not os.path.exists(root_servers_config_path):
self._logger.debug(
"Create root servers config file: {}".format(root_servers_config_path)
)
shutil.copy(root_servers_default_path, root_servers_config_path)
self._logger.debug(
"Load root servers config file: {}".format(root_servers_config_path)
)
with open(
root_servers_config_path,
"r",
encoding="utf-8",
) as stream:
self.root_servers = yaml.load(stream, Loader=yaml.FullLoader)
def load_profile(self, profile_name): def load_profile(self, profile_name):
""" """
Initialize databases depending on profile loaded Initialize databases depending on profile loaded
:param profile_name: :param profile_name:
:return: :return:
""" """
self.plugins_dir = PluginsDirectory.in_config_path(self.options.config_path, profile_name).load_or_init(self.options.with_plugin) self.plugins_dir = PluginsDirectory.in_config_path(
self.parameters = UserParametersFile.in_config_path(self.options.config_path, profile_name).load_or_init(profile_name) self.options.config_path, profile_name
).load_or_init(self.options.with_plugin)
self.parameters = UserParametersFile.in_config_path(
self.options.config_path, profile_name
).load_or_init(profile_name)
self.db = SakiaDatabase.load_or_init(self.options, profile_name) self.db = SakiaDatabase.load_or_init(self.options, profile_name)
self.instanciate_services() self.instanciate_services()
...@@ -109,52 +175,87 @@ class Application(QObject): ...@@ -109,52 +175,87 @@ class Application(QObject):
nodes_processor = NodesProcessor(self.db.nodes_repo) nodes_processor = NodesProcessor(self.db.nodes_repo)
bma_connector = BmaConnector(nodes_processor, self.parameters) bma_connector = BmaConnector(nodes_processor, self.parameters)
connections_processor = ConnectionsProcessor(self.db.connections_repo) connections_processor = ConnectionsProcessor(self.db.connections_repo)
identities_processor = IdentitiesProcessor(self.db.identities_repo, self.db.certifications_repo, self.db.blockchains_repo, bma_connector) identities_processor = IdentitiesProcessor(
certs_processor = CertificationsProcessor(self.db.certifications_repo, self.db.identities_repo, bma_connector) self.db.identities_repo,
self.db.certifications_repo,
self.db.blockchains_repo,
bma_connector,
)
certs_processor = CertificationsProcessor(
self.db.certifications_repo, self.db.identities_repo, bma_connector
)
blockchain_processor = BlockchainProcessor.instanciate(self) blockchain_processor = BlockchainProcessor.instanciate(self)
sources_processor = SourcesProcessor.instanciate(self) sources_processor = SourcesProcessor.instanciate(self)
transactions_processor = TransactionsProcessor.instanciate(self) transactions_processor = TransactionsProcessor.instanciate(self)
dividends_processor = DividendsProcessor.instanciate(self) dividends_processor = DividendsProcessor.instanciate(self)
nodes_processor.initialize_root_nodes(self.currency) nodes_processor.initialize_root_nodes(self.currency, self.root_servers)
self.db.commit() self.db.commit()
self.documents_service = DocumentsService.instanciate(self) self.documents_service = DocumentsService.instanciate(self)
self.identities_service = IdentitiesService(self.currency, connections_processor, self.identities_service = IdentitiesService(
self.currency,
connections_processor,
identities_processor, identities_processor,
certs_processor, blockchain_processor, certs_processor,
bma_connector) blockchain_processor,
bma_connector,
)
self.transactions_service = TransactionsService(self.currency, transactions_processor, self.transactions_service = TransactionsService(
self.currency,
transactions_processor,
dividends_processor, dividends_processor,
identities_processor, connections_processor, identities_processor,
bma_connector) connections_processor,
bma_connector,
)
self.sources_service = SourcesServices(self.currency, sources_processor, self.sources_service = SourcesServices(
connections_processor, transactions_processor, self.currency,
blockchain_processor, bma_connector) sources_processor,
connections_processor,
transactions_processor,
blockchain_processor,
bma_connector,
)
self.blockchain_service = BlockchainService(self, self.currency, blockchain_processor, connections_processor, self.blockchain_service = BlockchainService(
self,
self.currency,
blockchain_processor,
connections_processor,
bma_connector, bma_connector,
self.identities_service, self.identities_service,
self.transactions_service, self.transactions_service,
self.sources_service) self.sources_service,
)
self.network_service = NetworkService.load(self, self.currency, nodes_processor, self.network_service = NetworkService.load(
self,
self.currency,
nodes_processor,
self.blockchain_service, self.blockchain_service,
self.identities_service) self.identities_service,
)
async def remove_connection(self, connection): async def remove_connection(self, connection):
connections_processor = ConnectionsProcessor.instanciate(self) connections_processor = ConnectionsProcessor.instanciate(self)
connections_processor.remove_connections(connection) connections_processor.remove_connections(connection)
CertificationsProcessor.instanciate(self).cleanup_connection(connection, connections_processor.pubkeys()) CertificationsProcessor.instanciate(self).cleanup_connection(
connection, connections_processor.pubkeys()
)
IdentitiesProcessor.instanciate(self).cleanup_connection(connection) IdentitiesProcessor.instanciate(self).cleanup_connection(connection)
SourcesProcessor.instanciate(self).drop_all_of(currency=connection.currency, pubkey=connection.pubkey) SourcesProcessor.instanciate(self).drop_all_of(
currency=connection.currency, pubkey=connection.pubkey
)
DividendsProcessor.instanciate(self).cleanup_connection(connection) DividendsProcessor.instanciate(self).cleanup_connection(connection)
TransactionsProcessor.instanciate(self).cleanup_connection(connection, connections_processor.pubkeys()) TransactionsProcessor.instanciate(self).cleanup_connection(
connection, connections_processor.pubkeys()
)
self.db.commit() self.db.commit()
self.connection_removed.emit(connection) self.connection_removed.emit(connection)
...@@ -171,13 +272,26 @@ class Application(QObject): ...@@ -171,13 +272,26 @@ class Application(QObject):
self._translator = QTranslator(self.qapp) self._translator = QTranslator(self.qapp)
if locale == "en": if locale == "en":
QCoreApplication.installTranslator(self._translator) QCoreApplication.installTranslator(self._translator)
elif self._translator.load(":/i18n/{0}".format(locale)): else:
# load chosen language
filepath = ":/i18n/{0}".format(locale)
if not QFile.exists(filepath):
self._logger.debug("File not found: {0}".format(filepath))
self._translator.load(filepath)
if QCoreApplication.installTranslator(self._translator): if QCoreApplication.installTranslator(self._translator):
self._logger.debug("Loaded i18n/{0}".format(locale)) self._logger.debug("Loaded {0}".format(filepath))
else: else:
self._logger.debug("Couldn't load translation") self._logger.debug("Couldn't load {0}".format(filepath))
# load standardButtons Qt translation
filepath = ":/i18n/qtbase_{0}".format(locale)
if not QFile.exists(filepath):
self._logger.debug("File not found: {0}".format(filepath))
self._qt_translator = QTranslator(self.qapp)
self._qt_translator.load(filepath)
if QCoreApplication.installTranslator(self._qt_translator):
self._logger.debug("Loaded {0}".format(filepath))
else: else:
self._logger.debug("Couldn't load i18n/{0}".format(locale)) self._logger.debug("Couldn't load {0}".format(filepath))
def start_coroutines(self): def start_coroutines(self):
self.network_service.start_coroutines() self.network_service.start_coroutines()
...@@ -195,33 +309,36 @@ class Application(QObject): ...@@ -195,33 +309,36 @@ class Application(QObject):
try: try:
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with async_timeout.timeout(10): async with async_timeout.timeout(10):
response = await session.get("https://api.github.com/repos/duniter/sakia/releases", response = await session.get(
proxy=self.parameters.proxy()) GITLAB_RELEASES_API_URL,
proxy=self.parameters.proxy(),
)
if response.status == 200: if response.status == 200:
releases = await response.json() releases = await response.json()
latest = None
for r in releases: if len(releases) > 0:
if not latest: release = releases[0]
latest = r latest_version = release["tag_name"]
else: version = (
latest_date = datetime.datetime.strptime(latest['published_at'], "%Y-%m-%dT%H:%M:%SZ") __version__ == latest_version,
date = datetime.datetime.strptime(r['published_at'], "%Y-%m-%dT%H:%M:%SZ")
if latest_date < date:
latest = r
latest_version = latest["tag_name"]
version = (__version__ == latest_version,
latest_version, latest_version,
latest["html_url"]) GITLAB_RELEASES_PAGE_URL,
)
logging.debug("Found version: {0}".format(latest_version)) logging.debug("Found version: {0}".format(latest_version))
logging.debug("Current version: {0}".format(__version__)) logging.debug("Current version: {0}".format(__version__))
self.available_version = version self.available_version = version
except (aiohttp.ClientError, aiohttp.ServerDisconnectedError, asyncio.TimeoutError, socket.gaierror) as e: except (
self._logger.debug("Could not connect to github : {0}".format(str(e))) aiohttp.ClientError,
aiohttp.ServerDisconnectedError,
asyncio.TimeoutError,
socket.gaierror,
) as e:
self._logger.debug("Could not connect to gitlab: {0}".format(str(e)))
def save_parameters(self, parameters): def save_parameters(self, parameters):
self.parameters = UserParametersFile\ self.parameters = UserParametersFile.in_config_path(
.in_config_path(self.options.config_path, parameters.profile_name)\ self.options.config_path, parameters.profile_name
.save(parameters) ).save(parameters)
def change_referential(self, index): def change_referential(self, index):
self.current_ref = Referentials[index] self.current_ref = Referentials[index]
......
import os import os
import yaml
MAX_CONFIRMATIONS = 6 MAX_CONFIRMATIONS = 6
with open(os.path.join(os.path.dirname(__file__), "root_servers.yml"), 'r') as stream: with open(
ROOT_SERVERS = yaml.load(stream) os.path.join(os.path.dirname(__file__), "g1_license.html"), "r", encoding="utf-8"
) as stream:
G1_LICENSE = stream.read()
with open(os.path.join(os.path.dirname(__file__), "g1_licence.html"), 'r') as stream: GITLAB_RELEASES_PAGE_URL = "https://git.duniter.org/clients/python/sakia/-/releases"
G1_LICENCE = stream.read() GITLAB_RELEASES_API_URL = (
"https://git.duniter.org/api/v4/projects/clients%2Fpython%2Fsakia/releases"
)
GITLAB_NEW_ISSUE_PAGE_URL = "https://git.duniter.org/clients/python/sakia/-/issues/new"
This diff is collapsed.
This diff is collapsed.