Skip to content
Snippets Groups Projects
Commit 8d1e26a1 authored by inso's avatar inso
Browse files

Remove unused files

parent fb0d3b3a
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ import sys, os, multiprocessing, subprocess ...@@ -5,7 +5,7 @@ import sys, os, multiprocessing, subprocess
sakia = os.path.abspath(os.path.join(os.path.dirname(__file__))) sakia = os.path.abspath(os.path.join(os.path.dirname(__file__)))
resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'res')) resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'res'))
gen_ui = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src', 'sakia', 'presentation')) gen_ui = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src', 'sakia', 'gen_resources'))
gen_resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')) gen_resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src'))
def convert_ui(args, **kwargs): def convert_ui(args, **kwargs):
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>certificationsTabWidget</class>
<widget class="QWidget" name="certificationsTabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>481</width>
<height>456</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupbox_balance">
<property name="title">
<string>Certifications</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_resume">
<property name="font">
<font>
<pointsize>22</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>loading...</string>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>5</number>
</property>
<item>
<widget class="QDateTimeEdit" name="date_from">
<property name="displayFormat">
<string>dd/MM/yyyy</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDateTimeEdit" name="date_to">
<property name="displayFormat">
<string>dd/MM/yyyy</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QProgressBar" name="progressbar">
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item>
<widget class="QTableView" name="table_history">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="showGrid">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../icons/icons.qrc"/>
</resources>
<connections>
<connection>
<sender>table_history</sender>
<signal>customContextMenuRequested(QPoint)</signal>
<receiver>certificationsTabWidget</receiver>
<slot>history_context_menu()</slot>
<hints>
<hint type="sourcelabel">
<x>273</x>
<y>183</y>
</hint>
<hint type="destinationlabel">
<x>830</x>
<y>802</y>
</hint>
</hints>
</connection>
<connection>
<sender>date_from</sender>
<signal>dateChanged(QDate)</signal>
<receiver>certificationsTabWidget</receiver>
<slot>dates_changed()</slot>
<hints>
<hint type="sourcelabel">
<x>102</x>
<y>28</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
<connection>
<sender>date_to</sender>
<signal>dateChanged(QDate)</signal>
<receiver>certificationsTabWidget</receiver>
<slot>dates_changed()</slot>
<hints>
<hint type="sourcelabel">
<x>297</x>
<y>28</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>history_context_menu()</slot>
<slot>dates_changed()</slot>
</slots>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CommunityConfigurationDialog</class>
<widget class="QDialog" name="CommunityConfigurationDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>317</height>
</rect>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="windowTitle">
<string>Add a community</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QStackedWidget" name="stacked_pages">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page_node">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Please enter the address of a node :</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="rightMargin">
<number>5</number>
</property>
<item>
<widget class="QLineEdit" name="lineedit_server"/>
</item>
<item>
<widget class="QLabel" name="label_double_dot">
<property name="text">
<string>:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinbox_port">
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8001</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="topMargin">
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="button_register">
<property name="text">
<string>Register your account</string>
</property>
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/new_membership</normaloff>:/icons/new_membership</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_connect">
<property name="text">
<string>Connect using your account</string>
</property>
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/connect_icon</normaloff>:/icons/connect_icon</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_guest">
<property name="text">
<string>Connect as a guest</string>
</property>
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/guest_icon</normaloff>:/icons/guest_icon</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_error">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_add_nodes">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Communities nodes</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTreeView" name="tree_peers">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="lineedit_add_address">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Server</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinbox_add_port">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>8081</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_add">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_previous_next">
<item>
<widget class="QPushButton" name="button_previous">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="button_next">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../icons/icons.qrc"/>
</resources>
<connections>
<connection>
<sender>button_add</sender>
<signal>clicked()</signal>
<receiver>CommunityConfigurationDialog</receiver>
<slot>add_node()</slot>
<hints>
<hint type="sourcelabel">
<x>337</x>
<y>236</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
<connection>
<sender>tree_peers</sender>
<signal>customContextMenuRequested(QPoint)</signal>
<receiver>CommunityConfigurationDialog</receiver>
<slot>showContextMenu(QPoint)</slot>
<hints>
<hint type="sourcelabel">
<x>199</x>
<y>128</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_next</sender>
<signal>clicked()</signal>
<receiver>CommunityConfigurationDialog</receiver>
<slot>next()</slot>
<hints>
<hint type="sourcelabel">
<x>349</x>
<y>278</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_previous</sender>
<signal>clicked()</signal>
<receiver>CommunityConfigurationDialog</receiver>
<slot>previous()</slot>
<hints>
<hint type="sourcelabel">
<x>49</x>
<y>278</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>add_node()</slot>
<slot>showContextMenu(QPoint)</slot>
<slot>check()</slot>
<slot>next()</slot>
<slot>previous()</slot>
<slot>current_wallet_changed(int)</slot>
<slot>remove_node()</slot>
</slots>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateWalletDialog</class>
<widget class="QDialog" name="CreateWalletDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>234</height>
</rect>
</property>
<property name="windowTitle">
<string>Create a new wallet</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QStackedWidget" name="stacked_pages">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page_wallet">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Wallet name :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="edit_name"/>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="label_error">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>2</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="button_previous">
<property name="text">
<string>Previous</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="button_next">
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>edit_name</sender>
<signal>textChanged(QString)</signal>
<receiver>CreateWalletDialog</receiver>
<slot>check()</slot>
<hints>
<hint type="sourcelabel">
<x>238</x>
<y>91</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>116</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_next</sender>
<signal>clicked()</signal>
<receiver>CreateWalletDialog</receiver>
<slot>next()</slot>
<hints>
<hint type="sourcelabel">
<x>349</x>
<y>212</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>116</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_previous</sender>
<signal>clicked()</signal>
<receiver>CreateWalletDialog</receiver>
<slot>previous()</slot>
<hints>
<hint type="sourcelabel">
<x>49</x>
<y>212</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>116</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>open_import_key()</slot>
<slot>open_generate_key()</slot>
<slot>check()</slot>
<slot>next()</slot>
<slot>previous()</slot>
</slots>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CurrencyTabWidget</class>
<widget class="QWidget" name="CurrencyTabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>:/icons/noun_43022_cc.svg</normaloff>:/icons/noun_43022_cc.svg</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QFrame" name="actionsFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabs_account">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../icons/icons.qrc"/>
</resources>
<connections/>
<slots>
<slot>refresh_wallet_content(QModelIndex)</slot>
<slot>wallet_context_menu(QPoint)</slot>
<slot>dates_changed(QDateTime)</slot>
<slot>history_context_menu(QPoint)</slot>
</slots>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NodeManager</class>
<widget class="QDialog" name="NodeManager">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1024</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Node manager</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="web_view" native="true"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WalletsTab</class>
<widget class="QWidget" name="WalletsTab">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>924</width>
<height>920</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox {
border: 1px solid gray;
border-radius: 9px;
margin-top: 0.5em;
}
QGroupBox::title {
subcontrol-origin: margin;
left: 10px;
padding: 0 3px 0 3px;
font-weight: bold;
}</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Balance</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_balance">
<property name="font">
<font>
<pointsize>22</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>label_balance</string>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_balance_range">
<property name="text">
<string>label_balance_range</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QTableView" name="table_wallets">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../icons/icons.qrc"/>
</resources>
<connections>
<connection>
<sender>table_wallets</sender>
<signal>customContextMenuRequested(QPoint)</signal>
<receiver>WalletsTab</receiver>
<slot>wallet_context_menu(QPoint)</slot>
<hints>
<hint type="sourcelabel">
<x>199</x>
<y>346</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>225</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>wallet_context_menu(QPoint)</slot>
<slot>wallet_changed()</slot>
<slot>send_membership_demand()</slot>
<slot>send_membership_leaving()</slot>
<slot>revoke_uid()</slot>
<slot>publish_uid()</slot>
</slots>
</ui>
"""
Created on 6 mars 2014
@author: inso
"""
import logging
import asyncio
from duniterpy.key import SigningKey
from ..presentation.account_cfg_uic import Ui_AccountConfigurationDialog
from ..gui.process_cfg_community import ProcessConfigureCommunity
from ..gui.password_asker import PasswordAskerDialog, detect_non_printable
from ..gui.widgets.dialogs import QAsyncMessageBox
from ..models.communities import CommunitiesListModel
from ..tools.exceptions import KeyAlreadyUsed, Error, NoPeerAvailable
from ..tools.decorators import asyncify
from PyQt5.QtWidgets import QDialog, QMessageBox
from PyQt5.QtCore import QRegExp
from PyQt5.QtGui import QRegExpValidator
class Step():
def __init__(self, config_dialog, previous_step=None, next_step=None):
self.previous_step = previous_step
self.next_step = next_step
self.config_dialog = config_dialog
class StepPageInit(Step):
"""
First step when adding a community
"""
def __init__(self, config_dialog):
super().__init__(config_dialog)
def is_valid(self):
if len(self.config_dialog.edit_account_name.text()) > 2:
return True
else:
return False
def process_next(self):
if self.config_dialog.account is None:
name = self.config_dialog.edit_account_name.text()
self.config_dialog.account = self.config_dialog.app.create_account(name)
else:
name = self.config_dialog.edit_account_name.text()
self.config_dialog.account.name = name
def display_page(self):
if self.config_dialog.account is not None:
self.config_dialog.edit_account_name.setText(self.config_dialog.account.name)
model = CommunitiesListModel(self.config_dialog.account)
self.config_dialog.list_communities.setModel(model)
self.config_dialog.password_asker = PasswordAskerDialog(self.config_dialog.account)
self.config_dialog.button_previous.setEnabled(False)
self.config_dialog.button_next.setEnabled(False)
class StepPageKey(Step):
"""
First step when adding a community
"""
def __init__(self, config_dialog):
super().__init__(config_dialog)
def is_valid(self):
if self.config_dialog.app.preferences['expert_mode']:
return True
if len(self.config_dialog.edit_salt.text()) < 6:
self.config_dialog.label_info.setText(self.config_dialog.tr("Forbidden : salt is too short"))
return False
if len(self.config_dialog.edit_password.text()) < 6:
self.config_dialog.label_info.setText(self.config_dialog.tr("Forbidden : password is too short"))
return False
if detect_non_printable(self.config_dialog.edit_salt.text()):
self.config_dialog.label_info.setText(self.config_dialog.tr("Forbidden : Invalid characters in salt field"))
return False
if detect_non_printable(self.config_dialog.edit_password.text()):
self.config_dialog.label_info.setText(
self.config_dialog.tr("Forbidden : Invalid characters in password field"))
return False
if self.config_dialog.edit_password.text() != \
self.config_dialog.edit_password_repeat.text():
self.config_dialog.label_info.setText(self.config_dialog.tr("Error : passwords are different"))
return False
self.config_dialog.label_info.setText("")
return True
def process_next(self):
salt = self.config_dialog.edit_salt.text()
password = self.config_dialog.edit_password.text()
self.config_dialog.account.set_scrypt_infos(salt, password)
self.config_dialog.password_asker = PasswordAskerDialog(self.config_dialog.account)
model = CommunitiesListModel(self.config_dialog.account)
self.config_dialog.list_communities.setModel(model)
def display_page(self):
self.config_dialog.button_previous.setEnabled(False)
self.config_dialog.button_next.setEnabled(False)
class StepPageCommunities(Step):
"""
First step when adding a community
"""
def __init__(self, config_dialog):
super().__init__(config_dialog)
def is_valid(self):
return True
def process_next(self):
password = self.config_dialog.password_asker.exec_()
if self.config_dialog.password_asker.result() == QDialog.Rejected:
return
self.config_dialog.app.add_account(self.config_dialog.account)
if len(self.config_dialog.app.accounts) == 1:
self.config_dialog.app.preferences['account'] = self.config_dialog.account.name
self.config_dialog.app.save(self.config_dialog.account)
self.config_dialog.app.change_current_account(self.config_dialog.account)
def display_page(self):
logging.debug("Communities DISPLAY")
self.config_dialog.button_previous.setEnabled(False)
self.config_dialog.button_next.setText("Ok")
list_model = CommunitiesListModel(self.config_dialog.account)
self.config_dialog.list_communities.setModel(list_model)
class ProcessConfigureAccount(QDialog, Ui_AccountConfigurationDialog):
"""
classdocs
"""
def __init__(self, app, account):
"""
Constructor
"""
# Set up the user interface from Designer.
super().__init__()
self.setupUi(self)
regexp = QRegExp('[A-Za-z0-9_-]*')
validator = QRegExpValidator(regexp)
self.edit_account_name.setValidator(validator)
self.account = account
self.password_asker = None
self.app = app
step_init = StepPageInit(self)
step_key = StepPageKey(self)
step_communities = StepPageCommunities(self)
step_init.next_step = step_key
step_key.next_step = step_communities
self.step = step_init
self.step.display_page()
if self.account is None:
self.setWindowTitle(self.tr("New account"))
self.button_delete.hide()
else:
self.label_action.setText("Edit account uid")
self.edit_account_name.setPlaceholderText(self.account.name)
self.stacked_pages.removeWidget(self.stacked_pages.widget(1))
step_init.next_step = step_communities
self.button_next.setEnabled(True)
self.stacked_pages.currentWidget()
self.setWindowTitle(self.tr("Configure {0}".format(self.account.name)))
def open_process_add_community(self):
logging.debug("Opening configure community dialog")
logging.debug(self.password_asker)
dialog = ProcessConfigureCommunity(self.app,
self.account, None,
self.password_asker)
dialog.accepted.connect(self.action_add_community)
dialog.exec_()
def action_add_community(self):
logging.debug("Action add community : done")
self.list_communities.setModel(CommunitiesListModel(self.account))
self.button_next.setEnabled(True)
self.button_next.setText(self.tr("Ok"))
def action_remove_community(self):
for index in self.list_communities.selectedIndexes():
self.account.communities.pop(index.row())
self.list_communities.setModel(CommunitiesListModel(self.account))
def action_edit_community(self):
self.list_communities.setModel(CommunitiesListModel(self.account))
def action_edit_account_key(self):
self.button_generate.setEnabled(self.step.is_valid())
self.button_next.setEnabled(self.step.is_valid())
def action_show_pubkey(self):
salt = self.edit_salt.text()
password = self.edit_password.text()
pubkey = SigningKey(salt, password).pubkey
self.label_info.setText(pubkey)
def action_edit_account_parameters(self):
if self.step.is_valid():
self.button_next.setEnabled(True)
else:
self.button_next.setEnabled(False)
def open_process_edit_community(self, index):
community = self.account.communities[index.row()]
dialog = ProcessConfigureCommunity(self.app, self.account, community, self.password_asker)
dialog.accepted.connect(self.action_edit_community)
dialog.exec_()
@asyncify
async def action_delete_account(self, checked=False):
reply = await QAsyncMessageBox.question(self, self.tr("Warning"),
self.tr("""This action will delete your account ({0}) locally.
Please note your key parameters (salt and password) if you wish to recover it later.
Your account won't be removed from the networks it joined.
Are you sure ?""").format(self.app.current_account.name))
if reply == QMessageBox.Yes:
account = self.app.current_account
await self.app.delete_account(account)
self.app.save(account)
self.accept()
def next(self):
if self.step.is_valid():
try:
self.step.process_next()
if self.step.next_step is not None:
self.step = self.step.next_step
next_index = self.stacked_pages.currentIndex() + 1
self.stacked_pages.setCurrentIndex(next_index)
self.step.display_page()
else:
self.accept()
except Error as e:
QMessageBox.critical(self, self.tr("Error"),
str(e), QMessageBox.Ok)
def previous(self):
if self.step.previous_step is not None:
self.step = self.step.previous_step
previous_index = self.stacked_pages.currentIndex() - 1
self.stacked_pages.setCurrentIndex(previous_index)
self.step.display_page()
def async_exec(self):
future = asyncio.Future()
self.finished.connect(lambda r: future.set_result(r))
self.open()
return future
def accept(self):
super().accept()
"""
Created on 8 mars 2014
@author: inso
"""
import logging
import asyncio
import aiohttp
from duniterpy.api import errors
from duniterpy.documents import MalformedDocumentError
from PyQt5.QtWidgets import QDialog, QMenu, QApplication
from PyQt5.QtGui import QCursor
from PyQt5.QtCore import pyqtSignal, QObject
from ..presentation.community_cfg_uic import Ui_CommunityConfigurationDialog
from ..models.peering import PeeringTreeModel
from ..core import Community
from ..core.net import Node
from .widgets import toast
from .widgets.dialogs import QAsyncMessageBox
from ..tools.decorators import asyncify
from ..tools.exceptions import NoPeerAvailable
class Step(QObject):
def __init__(self, config_dialog, previous_step=None, next_step=None):
super().__init__()
self.previous_step = previous_step
self.next_step = next_step
self.config_dialog = config_dialog
class StepPageInit(Step):
"""
First step when adding a community
"""
def __init__(self, config_dialog):
super().__init__(config_dialog)
self.node = None
logging.debug("Init")
self.config_dialog.button_connect.clicked.connect(self.check_connect)
self.config_dialog.button_register.clicked.connect(self.check_register)
self.config_dialog.button_guest.clicked.connect(self.check_guest)
@property
def app(self):
return self.config_dialog.app
@property
def account(self):
return self.config_dialog.account
@property
def community(self):
return self.config_dialog.community
@property
def password_asker(self):
return self.config_dialog.password_asker
@asyncify
async def check_guest(self, checked=False):
server = self.config_dialog.lineedit_server.text()
port = self.config_dialog.spinbox_port.value()
logging.debug("Is valid ? ")
self.config_dialog.label_error.setText(self.tr("connecting..."))
try:
self.node = await Node.from_address(None, server, port, session=aiohttp.ClientSession())
community = Community.create(self.node)
self.config_dialog.button_connect.setEnabled(False)
self.config_dialog.button_register.setEnabled(False)
self.config_dialog.community = community
self.config_dialog.next()
except aiohttp.errors.DisconnectedError as e:
self.config_dialog.label_error.setText(str(e))
except aiohttp.errors.ClientError as e:
self.config_dialog.label_error.setText(str(e))
except (MalformedDocumentError, ValueError) as e:
self.config_dialog.label_error.setText(str(e))
except aiohttp.errors.TimeoutError:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check hostname, ip address or port"))
@asyncify
async def check_connect(self, checked=False):
server = self.config_dialog.lineedit_server.text()
port = self.config_dialog.spinbox_port.value()
logging.debug("Is valid ? ")
self.config_dialog.label_error.setText(self.tr("connecting..."))
try:
self.node = await Node.from_address(None, server, port, session=aiohttp.ClientSession())
community = Community.create(self.node)
self.config_dialog.button_connect.setEnabled(False)
self.config_dialog.button_register.setEnabled(False)
registered = await self.account.check_registered(community)
self.config_dialog.button_connect.setEnabled(True)
self.config_dialog.button_register.setEnabled(True)
if registered[0] is False and registered[2] is None:
self.config_dialog.label_error.setText(self.tr("Could not find your identity on the network."))
elif registered[0] is False and registered[2]:
self.config_dialog.label_error.setText(self.tr("""Your pubkey or UID is different on the network.
Yours : {0}, the network : {1}""".format(registered[1], registered[2])))
else:
self.config_dialog.community = community
self.config_dialog.next()
except aiohttp.errors.DisconnectedError as e:
self.config_dialog.label_error.setText(str(e))
except aiohttp.errors.ClientError as e:
self.config_dialog.label_error.setText(str(e))
except (MalformedDocumentError, ValueError) as e:
self.config_dialog.label_error.setText(str(e))
except NoPeerAvailable:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check node peering entry"))
except aiohttp.errors.TimeoutError:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check hostname, ip address or port"))
@asyncify
async def check_register(self, checked=False):
server = self.config_dialog.lineedit_server.text()
port = self.config_dialog.spinbox_port.value()
logging.debug("Is valid ? ")
self.config_dialog.label_error.setText(self.tr("connecting..."))
try:
session = aiohttp.ClientSession()
self.node = await Node.from_address(None, server, port, session=session)
community = Community.create(self.node)
self.config_dialog.button_connect.setEnabled(False)
self.config_dialog.button_register.setEnabled(False)
registered = await self.account.check_registered(community)
self.config_dialog.button_connect.setEnabled(True)
self.config_dialog.button_register.setEnabled(True)
if registered[0] is False and registered[2] is None:
password = await self.password_asker.async_exec()
if self.password_asker.result() == QDialog.Rejected:
return
self.config_dialog.label_error.setText(self.tr("Broadcasting identity..."))
result = await self.account.send_selfcert(password, community)
if result[0]:
if self.app.preferences['notifications']:
toast.display(self.tr("UID broadcast"), self.tr("Identity broadcasted to the network"))
QApplication.restoreOverrideCursor()
self.config_dialog.next()
else:
self.config_dialog.label_error.setText(self.tr("Error") + " " + \
self.tr("{0}".format(result[1])))
if self.app.preferences['notifications']:
toast.display(self.tr("Error"), self.tr("{0}".format(result[1])))
QApplication.restoreOverrideCursor()
self.config_dialog.community = community
elif registered[0] is False and registered[2]:
self.config_dialog.label_error.setText(self.tr("""Your pubkey or UID was already found on the network.
Yours : {0}, the network : {1}""".format(registered[1], registered[2])))
else:
self.config_dialog.label_error.setText(self.tr("Your account already exists on the network"))
except (MalformedDocumentError, ValueError, errors.DuniterError,
aiohttp.errors.ClientError, aiohttp.errors.DisconnectedError) as e:
session.close()
self.config_dialog.label_error.setText(str(e))
except NoPeerAvailable:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check node peering entry"))
except aiohttp.errors.TimeoutError:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check hostname, ip address or port"))
def is_valid(self):
return self.node is not None
def process_next(self):
"""
We create the community
"""
account = self.config_dialog.account
logging.debug("Account : {0}".format(account))
self.config_dialog.community = Community.create(self.node)
def display_page(self):
self.config_dialog.button_next.hide()
self.config_dialog.button_previous.hide()
class StepPageAddpeers(Step):
"""
The step where the user add peers
"""
def __init__(self, config_dialog):
super().__init__(config_dialog)
def is_valid(self):
return True
def process_next(self):
pass
def display_page(self):
self.config_dialog.button_next.show()
self.config_dialog.button_previous.show()
# We add already known peers to the displayed list
self.config_dialog.nodes = self.config_dialog.community.network.root_nodes
tree_model = PeeringTreeModel(self.config_dialog.community)
self.config_dialog.tree_peers.setModel(tree_model)
self.config_dialog.button_previous.setEnabled(False)
self.config_dialog.button_next.setText(self.config_dialog.tr("Ok"))
class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
"""
Dialog to configure or add a community
"""
community_added = pyqtSignal()
def __init__(self, app, account, community, password_asker):
"""
Constructor
:param sakia.core.Application app: The application
:param sakia.core.Account account: The configured account
:param sakia.core.Community community: The configured community
:param sakia.gui.password_asker.Password_Asker password_asker: The password asker
"""
super().__init__()
self.setupUi(self)
self.app = app
self.community = community
self.account = account
self.password_asker = password_asker
self.step = None
self.nodes = []
self.community_added.connect(self.add_community_and_close)
self._step_init = StepPageInit(self)
step_add_peers = StepPageAddpeers(self)
self._step_init.next_step = step_add_peers
if self.community is not None:
self.stacked_pages.removeWidget(self.page_node)
self.step = step_add_peers
self.setWindowTitle(self.tr("Configure community {0}").format(self.community.currency))
else:
self.step = self._step_init
self.setWindowTitle(self.tr("Add a community"))
self.step.display_page()
def next(self):
if self.step.next_step is not None:
if self.step.is_valid():
self.step.process_next()
self.step = self.step.next_step
next_index = self.stacked_pages.currentIndex() + 1
self.stacked_pages.setCurrentIndex(next_index)
self.step.display_page()
else:
self.add_community_and_close()
def previous(self):
if self.step.previous_step is not None:
self.step = self.step.previous_step
previous_index = self.stacked_pages.currentIndex() - 1
self.stacked_pages.setCurrentIndex(previous_index)
self.step.display_page()
async def start_add_node(self):
"""
Add node slot
"""
server = self.lineedit_add_address.text()
port = self.spinbox_add_port.value()
try:
node = await Node.from_address(self.community.currency, server, port, session=self.community.network.session)
self.community.add_node(node)
except Exception as e:
await QAsyncMessageBox.critical(self, self.tr("Error"),
str(e))
self.tree_peers.setModel(PeeringTreeModel(self.community))
def add_node(self):
asyncio.ensure_future(self.start_add_node())
def remove_node(self):
"""
Remove node slot
"""
logging.debug("Remove node")
index = self.sender().data()
self.community.remove_node(index)
self.tree_peers.setModel(PeeringTreeModel(self.community))
@property
def nb_steps(self):
s = self.step
nb_steps = 1
while s.next_step != None:
s = s.next_step
nb_steps = nb_steps + 1
return nb_steps
def showContextMenu(self, point):
if self.stacked_pages.currentIndex() == self.nb_steps - 1:
menu = QMenu()
index = self.tree_peers.indexAt(point)
action = menu.addAction(self.tr("Delete"), self.remove_node)
action.setData(index.row())
if self.community is not None:
if len(self.nodes) == 1:
action.setEnabled(False)
menu.exec_(QCursor.pos())
def async_exec(self):
future = asyncio.Future()
self.finished.connect(lambda r: future.set_result(r))
self.open()
return future
def add_community_and_close(self):
if self.community not in self.account.communities:
self.account.add_community(self.community)
self.accept()
import aiohttp
from PyQt5.QtCore import QObject, QEvent, QUrl
from PyQt5.QtWidgets import QDialog
#from ..gen_resources.node_manager_uic import Ui_NodeManager
from .widgets.dialogs import QAsyncMessageBox
from ..tools.decorators import asyncify
class NodeManager(QObject):
"""
A widget showing informations about a member
"""
def __init__(self, widget, ui):
"""
Init MemberDialog
:param PyQt5.QtWidget widget: The class of the widget
:param sakia.presentation.member_uic.Ui_DialogMember ui: the class of the ui applyed to the widget
:return:
"""
super().__init__()
self.widget = widget
self.ui = ui
self.ui.setupUi(self.widget)
self.widget.installEventFilter(self)
@classmethod
def create(cls, parent):
raise TypeError("Not implemented ( https://github.com/duniter/sakia/issues/399 )")
#dialog = cls(QDialog(parent), Ui_NodeManager())
#return dialog
@asyncify
async def open_home_page(self):
try:
with aiohttp.ClientSession() as session:
response = await session.get("http://127.0.0.1:9220")
if response.status == 200:
self.ui.web_view.load(QUrl("http://127.0.0.1:9220"))
self.ui.web_view.show()
self.widget.show()
else:
await QAsyncMessageBox.critical(self.widget, "Local node manager",
"Could not access to local node ui.")
except aiohttp.ClientError:
await QAsyncMessageBox.critical(self.widget, "Local node manager",
"Could not connect to node. Please make sure it's running.")
def eventFilter(self, source, event):
if event.type() == QEvent.Resize:
self.widget.resizeEvent(event)
return self.widget.eventFilter(source, event)
def exec(self):
self.widget.exec()
"""
Created on 8 mars 2014
@author: inso
"""
import logging
import asyncio
import aiohttp
from duniterpy.api import errors
from duniterpy.documents import MalformedDocumentError
from PyQt5.QtWidgets import QDialog, QMenu, QApplication
from PyQt5.QtGui import QCursor
from PyQt5.QtCore import pyqtSignal, QObject
from ..presentation.community_cfg_uic import Ui_CommunityConfigurationDialog
from ..models.peering import PeeringTreeModel
from ..core import Community
from ..core.net import Node
from .widgets import toast
from .widgets.dialogs import QAsyncMessageBox
from ..tools.decorators import asyncify
from ..tools.exceptions import NoPeerAvailable
class Step(QObject):
def __init__(self, config_dialog, previous_step=None, next_step=None):
super().__init__()
self.previous_step = previous_step
self.next_step = next_step
self.config_dialog = config_dialog
class StepPageInit(Step):
"""
First step when adding a community
"""
def __init__(self, config_dialog):
super().__init__(config_dialog)
self.node = None
logging.debug("Init")
self.config_dialog.button_connect.clicked.connect(self.check_connect)
self.config_dialog.button_register.clicked.connect(self.check_register)
self.config_dialog.button_guest.clicked.connect(self.check_guest)
@property
def app(self):
return self.config_dialog.app
@property
def account(self):
return self.config_dialog.account
@property
def community(self):
return self.config_dialog.community
@property
def password_asker(self):
return self.config_dialog.password_asker
@asyncify
async def check_guest(self, checked=False):
server = self.config_dialog.lineedit_server.text()
port = self.config_dialog.spinbox_port.value()
logging.debug("Is valid ? ")
self.config_dialog.label_error.setText(self.tr("connecting..."))
try:
self.node = await Node.from_address(None, server, port, session=aiohttp.ClientSession())
community = Community.create(self.node)
self.config_dialog.button_connect.setEnabled(False)
self.config_dialog.button_register.setEnabled(False)
self.config_dialog.community = community
self.config_dialog.next()
except aiohttp.errors.DisconnectedError as e:
self.config_dialog.label_error.setText(str(e))
except aiohttp.errors.ClientError as e:
self.config_dialog.label_error.setText(str(e))
except (MalformedDocumentError, ValueError) as e:
self.config_dialog.label_error.setText(str(e))
except aiohttp.errors.TimeoutError:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check hostname, ip address or port"))
@asyncify
async def check_connect(self, checked=False):
server = self.config_dialog.lineedit_server.text()
port = self.config_dialog.spinbox_port.value()
logging.debug("Is valid ? ")
self.config_dialog.label_error.setText(self.tr("connecting..."))
try:
self.node = await Node.from_address(None, server, port, session=aiohttp.ClientSession())
community = Community.create(self.node)
self.config_dialog.button_connect.setEnabled(False)
self.config_dialog.button_register.setEnabled(False)
registered = await self.account.check_registered(community)
self.config_dialog.button_connect.setEnabled(True)
self.config_dialog.button_register.setEnabled(True)
if registered[0] is False and registered[2] is None:
self.config_dialog.label_error.setText(self.tr("Could not find your identity on the network."))
elif registered[0] is False and registered[2]:
self.config_dialog.label_error.setText(self.tr("""Your pubkey or UID is different on the network.
Yours : {0}, the network : {1}""".format(registered[1], registered[2])))
else:
self.config_dialog.community = community
self.config_dialog.next()
except aiohttp.errors.DisconnectedError as e:
self.config_dialog.label_error.setText(str(e))
except aiohttp.errors.ClientError as e:
self.config_dialog.label_error.setText(str(e))
except (MalformedDocumentError, ValueError) as e:
self.config_dialog.label_error.setText(str(e))
except NoPeerAvailable:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check node peering entry"))
except aiohttp.errors.TimeoutError:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check hostname, ip address or port"))
@asyncify
async def check_register(self, checked=False):
server = self.config_dialog.lineedit_server.text()
port = self.config_dialog.spinbox_port.value()
logging.debug("Is valid ? ")
self.config_dialog.label_error.setText(self.tr("connecting..."))
try:
session = aiohttp.ClientSession()
self.node = await Node.from_address(None, server, port, session=session)
community = Community.create(self.node)
self.config_dialog.button_connect.setEnabled(False)
self.config_dialog.button_register.setEnabled(False)
registered = await self.account.check_registered(community)
self.config_dialog.button_connect.setEnabled(True)
self.config_dialog.button_register.setEnabled(True)
if registered[0] is False and registered[2] is None:
password = await self.password_asker.async_exec()
if self.password_asker.result() == QDialog.Rejected:
return
self.config_dialog.label_error.setText(self.tr("Broadcasting identity..."))
result = await self.account.send_selfcert(password, community)
if result[0]:
if self.app.preferences['notifications']:
toast.display(self.tr("UID broadcast"), self.tr("Identity broadcasted to the network"))
QApplication.restoreOverrideCursor()
self.config_dialog.next()
else:
self.config_dialog.label_error.setText(self.tr("Error") + " " + \
self.tr("{0}".format(result[1])))
if self.app.preferences['notifications']:
toast.display(self.tr("Error"), self.tr("{0}".format(result[1])))
QApplication.restoreOverrideCursor()
self.config_dialog.community = community
elif registered[0] is False and registered[2]:
self.config_dialog.label_error.setText(self.tr("""Your pubkey or UID was already found on the network.
Yours : {0}, the network : {1}""".format(registered[1], registered[2])))
else:
self.config_dialog.label_error.setText(self.tr("Your account already exists on the network"))
except (MalformedDocumentError, ValueError, errors.DuniterError,
aiohttp.errors.ClientError, aiohttp.errors.DisconnectedError) as e:
session.close()
self.config_dialog.label_error.setText(str(e))
except NoPeerAvailable:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check node peering entry"))
except aiohttp.errors.TimeoutError:
self.config_dialog.label_error.setText(self.tr("Could not connect. Check hostname, ip address or port"))
def is_valid(self):
return self.node is not None
def process_next(self):
"""
We create the community
"""
account = self.config_dialog.account
logging.debug("Account : {0}".format(account))
self.config_dialog.community = Community.create(self.node)
def display_page(self):
self.config_dialog.button_next.hide()
self.config_dialog.button_previous.hide()
class StepPageAddpeers(Step):
"""
The step where the user add peers
"""
def __init__(self, config_dialog):
super().__init__(config_dialog)
def is_valid(self):
return True
def process_next(self):
pass
def display_page(self):
self.config_dialog.button_next.show()
self.config_dialog.button_previous.show()
# We add already known peers to the displayed list
self.config_dialog.nodes = self.config_dialog.community.network.root_nodes
tree_model = PeeringTreeModel(self.config_dialog.community)
self.config_dialog.tree_peers.setModel(tree_model)
self.config_dialog.button_previous.setEnabled(False)
self.config_dialog.button_next.setText(self.config_dialog.tr("Ok"))
class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
"""
Dialog to configure or add a community
"""
community_added = pyqtSignal()
def __init__(self, app, account, community, password_asker):
"""
Constructor
:param sakia.core.Application app: The application
:param sakia.core.Account account: The configured account
:param sakia.core.Community community: The configured community
:param sakia.gui.password_asker.Password_Asker password_asker: The password asker
"""
super().__init__()
self.setupUi(self)
self.app = app
self.community = community
self.account = account
self.password_asker = password_asker
self.step = None
self.nodes = []
self.community_added.connect(self.add_community_and_close)
self._step_init = StepPageInit(self)
step_add_peers = StepPageAddpeers(self)
self._step_init.next_step = step_add_peers
if self.community is not None:
self.stacked_pages.removeWidget(self.page_node)
self.step = step_add_peers
self.setWindowTitle(self.tr("Configure community {0}").format(self.community.currency))
else:
self.step = self._step_init
self.setWindowTitle(self.tr("Add a community"))
self.step.display_page()
def next(self):
if self.step.next_step is not None:
if self.step.is_valid():
self.step.process_next()
self.step = self.step.next_step
next_index = self.stacked_pages.currentIndex() + 1
self.stacked_pages.setCurrentIndex(next_index)
self.step.display_page()
else:
self.add_community_and_close()
def previous(self):
if self.step.previous_step is not None:
self.step = self.step.previous_step
previous_index = self.stacked_pages.currentIndex() - 1
self.stacked_pages.setCurrentIndex(previous_index)
self.step.display_page()
async def start_add_node(self):
"""
Add node slot
"""
server = self.lineedit_add_address.text()
port = self.spinbox_add_port.value()
try:
node = await Node.from_address(self.community.currency, server, port, session=self.community.network.session)
self.community.add_node(node)
except Exception as e:
await QAsyncMessageBox.critical(self, self.tr("Error"),
str(e))
self.tree_peers.setModel(PeeringTreeModel(self.community))
def add_node(self):
asyncio.ensure_future(self.start_add_node())
def remove_node(self):
"""
Remove node slot
"""
logging.debug("Remove node")
index = self.sender().data()
self.community.remove_node(index)
self.tree_peers.setModel(PeeringTreeModel(self.community))
@property
def nb_steps(self):
s = self.step
nb_steps = 1
while s.next_step != None:
s = s.next_step
nb_steps = nb_steps + 1
return nb_steps
def showContextMenu(self, point):
if self.stacked_pages.currentIndex() == self.nb_steps - 1:
menu = QMenu()
index = self.tree_peers.indexAt(point)
action = menu.addAction(self.tr("Delete"), self.remove_node)
action.setData(index.row())
if self.community is not None:
if len(self.nodes) == 1:
action.setEnabled(False)
menu.exec_(QCursor.pos())
def async_exec(self):
future = asyncio.Future()
self.finished.connect(lambda r: future.set_result(r))
self.open()
return future
def add_community_and_close(self):
if self.community not in self.account.communities:
self.account.add_community(self.community)
self.accept()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment