Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
5111c4cb
Commit
5111c4cb
authored
10 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Better handling of connection failures
parent
ea493de2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cutecoin/core/app.py
+2
-3
2 additions, 3 deletions
src/cutecoin/core/app.py
src/cutecoin/gui/currency_tab.py
+9
-3
9 additions, 3 deletions
src/cutecoin/gui/currency_tab.py
src/cutecoin/gui/mainwindow.py
+11
-5
11 additions, 5 deletions
src/cutecoin/gui/mainwindow.py
with
22 additions
and
11 deletions
src/cutecoin/core/app.py
+
2
−
3
View file @
5111c4cb
...
...
@@ -63,7 +63,6 @@ class Application(object):
if
self
.
current_account
is
not
None
:
self
.
save_cache
(
self
.
current_account
)
self
.
current_account
=
account
self
.
load_cache
(
account
)
def
load
(
self
):
if
(
os
.
path
.
exists
(
config
.
parameters
[
'
data
'
])
...
...
@@ -71,7 +70,6 @@ class Application(object):
logging
.
debug
(
"
Loading data...
"
)
with
open
(
config
.
parameters
[
'
data
'
],
'
r
'
)
as
json_data
:
data
=
json
.
load
(
json_data
)
json_data
.
close
()
if
'
default_account
'
in
data
.
keys
():
self
.
default_account
=
data
[
'
default_account
'
]
for
account_name
in
data
[
'
local_accounts
'
]:
...
...
@@ -83,6 +81,7 @@ class Application(object):
with
open
(
account_path
,
'
r
'
)
as
json_data
:
data
=
json
.
load
(
json_data
)
account
=
Account
.
load
(
data
)
self
.
load_cache
(
account
)
self
.
accounts
[
account_name
]
=
account
def
load_cache
(
self
,
account
):
...
...
@@ -92,7 +91,7 @@ class Application(object):
if
os
.
path
.
exists
(
wallet_path
):
with
open
(
wallet_path
,
'
r
'
)
as
json_data
:
data
=
json
.
load
(
json_data
)
wallet
.
load_caches
(
data
)
wallet
.
load_caches
(
data
)
for
community
in
account
.
communities
:
wallet
.
refresh_cache
(
community
)
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/gui/currency_tab.py
+
9
−
3
View file @
5111c4cb
...
...
@@ -49,11 +49,10 @@ class BlockchainWatcher(QObject):
except
NoPeerAvailable
:
return
except
requests
.
exceptions
.
RequestException
as
e
:
QMessageBox
.
critical
(
self
,
"
:(
"
,
str
(
e
),
QMessageBox
.
Ok
)
self
.
connection_error
.
emit
(
str
(
e
))
new_block_mined
=
pyqtSignal
(
int
)
connection_error
=
pyqtSignal
(
str
)
class
CurrencyTabWidget
(
QWidget
,
Ui_CurrencyTabWidget
):
...
...
@@ -78,6 +77,7 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
self
.
bc_watcher
=
BlockchainWatcher
(
self
.
app
.
current_account
,
community
)
self
.
bc_watcher
.
new_block_mined
.
connect
(
self
.
refresh_block
)
self
.
bc_watcher
.
connection_error
.
connect
(
self
.
display_error
)
self
.
watcher_thread
=
QThread
()
self
.
bc_watcher
.
moveToThread
(
self
.
watcher_thread
)
...
...
@@ -107,6 +107,12 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
self
.
status_label
.
setText
(
"
Connected : Block {0}
"
.
format
(
block_number
))
@pyqtSlot
(
str
)
def
display_error
(
self
,
error
):
QMessageBox
.
critical
(
self
,
"
:(
"
,
error
,
QMessageBox
.
Ok
)
@pyqtSlot
(
int
)
def
refresh_block
(
self
,
block_number
):
if
self
.
list_wallets
.
model
():
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/gui/mainwindow.py
+
11
−
5
View file @
5111c4cb
...
...
@@ -28,6 +28,7 @@ class Loader(QObject):
self
.
account_name
=
""
loaded
=
pyqtSignal
()
connection_error
=
pyqtSignal
(
str
)
def
set_account_name
(
self
,
name
):
self
.
account_name
=
name
...
...
@@ -38,9 +39,9 @@ class Loader(QObject):
try
:
self
.
app
.
change_current_account
(
self
.
app
.
get_account
(
self
.
account_name
))
except
requests
.
exceptions
.
RequestException
as
e
:
QMessageBox
.
critical
(
self
,
"
:(
"
,
str
(
e
),
QMessageBox
.
Ok
)
self
.
connection_error
.
emit
(
str
(
e
))
self
.
loaded
.
emit
()
self
.
loaded
.
emit
()
...
...
@@ -75,6 +76,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
loader
.
moveToThread
(
self
.
loader_thread
)
self
.
loader
.
loaded
.
connect
(
self
.
loader_finished
)
self
.
loader
.
loaded
.
connect
(
self
.
loader_thread
.
quit
)
self
.
loader
.
connection_error
.
connect
(
self
.
display_error
)
self
.
loader_thread
.
started
.
connect
(
self
.
loader
.
load
)
self
.
setWindowTitle
(
"
CuteCoin {0}
"
.
format
(
__version__
))
self
.
refresh
()
...
...
@@ -89,9 +91,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
refresh
()
self
.
busybar
.
hide
()
@pyqtSlot
(
str
)
def
display_error
(
self
,
error
):
QMessageBox
.
critical
(
self
,
"
:(
"
,
error
,
QMessageBox
.
Ok
)
def
action_change_account
(
self
,
account_name
):
if
self
.
app
.
current_account
:
self
.
app
.
save_cache
(
self
.
app
.
current_account
)
self
.
busybar
.
show
()
self
.
status_label
.
setText
(
"
Loading account {0}
"
.
format
(
account_name
))
self
.
loader
.
set_account_name
(
account_name
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment