Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/v2019.0426'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Apr 26, 2019
2 parents 10c3a14 + 7917e96 commit f31f2fe
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 51 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

[![Build Status](https://secure.travis-ci.org/AndreMiras/EtherollApp.png?branch=develop)](http://travis-ci.org/AndreMiras/EtherollApp)

<a href="https://github.com/AndreMiras/EtherollApp/releases/download/v20190418/etheroll-2019.0418-debug.apk"><img src="https://www.scottishchildrenslottery.com/export/system/modules/com.assense.gaming.stv.template/resources/images/google-play-store.svg" width="200"></a>
<a href="https://f-droid.org/en/packages/com.github.andremiras.etheroll">
<img src="https://f-droid.org/badge/get-it-on.png" height="75">
</a>
<a href="https://github.com/AndreMiras/EtherollApp/releases/download/v2019.0426/etheroll-2019.0426-debug.apk">
<img src="https://www.livenettv.to/img/landing-page-1/google-play.png" height="75">
</a>

Provably fair dice game running on the [Ethereum blockchain](https://etheroll.com/#/smart-contract).
Built with Python, [Kivy](https://github.com/kivy/kivy) and love.
Expand Down
2 changes: 1 addition & 1 deletion buildozer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ requirements =
requests==2.20.0,
requests-cache==0.4.13,
rlp==1.0.3,
setuptools,
setuptools==40.9.0,
toolz==0.9.0,
urllib3==1.24.1,
web3==4.8.1
Expand Down
47 changes: 7 additions & 40 deletions docs/Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,24 @@ This is documenting the release process.

Make sure the CHANGELOG.md is up to date and follows the http://keepachangelog.com guidelines.
Start the release with git flow:
```
git flow release start vYYYYMMDD
```sh
git flow release start vYYYY.MMDD
```
Now update the [CHANGELOG.md](/src/CHANGELOG.md) `[Unreleased]` section to match the new release version.
Also update the `__version__` string of the [version.py](/src/version.py) file. Then commit and finish release.
Also update the `__version__` and `__version_code__` values from the [version.py](/src/version.py) file.
Optionally already update the direct download link from the [README.md](/README.md).
```
git commit -a -m "vYYYYMMDD"
Then commit and finish release.
```sh
git commit -a -m "vYYYY.MMDD"
git flow release finish
```
Push everything, make sure tags are also pushed:
```
```sh
git push
git push origin master:master
git push --tags
```

## Android

Useful links:

* https://developer.android.com/studio/publish/app-signing.html
* https://github.com/kivy/kivy/wiki/Creating-a-Release-APK

### Fields

* my-project - The directory for your project
* my-new-key - The name of the key you generate
* my-alias - A short alias name for the key

### Commands
Prepare the environment variables:
```
export P4A_RELEASE_KEYSTORE=~/.android/<my-alias>.keystore
export P4A_RELEASE_KEYSTORE_PASSWD=android
export P4A_RELEASE_KEYALIAS_PASSWD=android
export P4A_RELEASE_KEYALIAS=<my-alias>
```
Generate a keystore if not yet generated:
```
keytool -genkey -v -keystore ~/.android/<my-new-key>.keystore -alias <my-alias> -keyalg RSA -keysize 2048 -validity 10000
```
Run buildozer:
```
buildozer android release
```

### Play Store

<https://play.google.com/apps/publish/>

## GitHub

Got to GitHub [Release/Tags](https://github.com/AndreMiras/EtherollApp/tags), click "Add release notes" for the tag just created.
Expand Down
7 changes: 7 additions & 0 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Change Log


## [v2019.0426]

- Support F-Droid auto updates, refs #132
- Keystore directory and permissions, refs #133, #134


## [v20190418]

- Pull minimum bet from contract, refs #129
- Fix permission issue on settings, refs #131
- Available on the F-Droid market, refs #36


## [v20190217]
Expand Down
1 change: 1 addition & 0 deletions src/ethereum_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class AccountUtils:
def __init__(self, keystore_dir):
self.keystore_dir = keystore_dir
self._accounts = None
os.makedirs(keystore_dir, exist_ok=True)

def get_account_list(self):
"""
Expand Down
11 changes: 8 additions & 3 deletions src/etheroll/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ def account_utils(self):
from etheroll.store import Store
if self._account_utils is None:
keystore_dir = Store.get_keystore_path()
self._account_utils = AccountUtils(keystore_dir=keystore_dir)
# would try to create the keystore directory if doesn't exist,
# hence we need to make sure we have permissions
if self.check_request_write_permission():
self._account_utils = AccountUtils(keystore_dir=keystore_dir)
return self._account_utils

def preload_account_utils(self, dt):
Expand Down Expand Up @@ -419,12 +422,14 @@ def check_request_write_permission():
Android runtime storage permission check.
"""
if platform != "android":
return
return True
from android.permissions import (
Permission, request_permission, check_permission)
permission = Permission.WRITE_EXTERNAL_STORAGE
if not check_permission(permission):
had_permission = check_permission(permission)
if not had_permission:
request_permission(permission)
return had_permission

@staticmethod
def on_permission_error(exception):
Expand Down
6 changes: 4 additions & 2 deletions src/etheroll/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ def get_store():
controller.check_request_write_permission()
try:
store = Store.get_store()
except PermissionError as exception:
controller.on_permission_error(exception)
except (PermissionError, OSError):
# PermissionError -> e.g. Android runtime permission
# OSError -> e.g. directory doesn't exist
# fails silently, setting will simply not be stored on disk
store = {}
return store

Expand Down
13 changes: 11 additions & 2 deletions src/service/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ def __init__(self, osc_server_port=None):
"""
Set `osc_server_port` to enable UI synchronization with service.
"""
keystore_dir = self.get_keystore_path()
self.account_utils = AccountUtils(keystore_dir=keystore_dir)
self._pyetheroll = None
self._account_utils = None
# per address cached merged logs, used to compare with next pulls
self.merged_logs = {}
self.last_roll_activity = None
Expand All @@ -65,6 +64,16 @@ def run(self):
# service decided to die naturally after no roll activity
self.set_auto_restart_service(False)

@property
def account_utils(self):
"""
Gets or creates the AccountUtils object so it loads lazily.
"""
if self._account_utils is None:
keystore_dir = self.get_keystore_path()
self._account_utils = AccountUtils(keystore_dir=keystore_dir)
return self._account_utils

@staticmethod
def set_auto_restart_service(restart=True):
"""
Expand Down
19 changes: 18 additions & 1 deletion src/tests/test_ethereum_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import shutil
import unittest
from tempfile import mkdtemp
from tempfile import TemporaryDirectory, mkdtemp
from unittest import mock

from ethereum_utils import AccountUtils
Expand Down Expand Up @@ -79,6 +79,23 @@ def test_get_account_list_error(self):
self.assertEqual(
self.account_utils.get_account_list()[0].address, account.address)

def test_get_account_list_no_dir(self):
"""
The keystore directory should be created if it doesn't exist, refs:
https://github.com/AndreMiras/PyWallet/issues/133
"""
# nominal case when the directory already exists
with TemporaryDirectory() as keystore_dir:
self.assertTrue(os.path.isdir(keystore_dir))
account_utils = AccountUtils(keystore_dir)
self.assertEqual(account_utils.get_account_list(), [])
# when the directory doesn't exist it should also be created
self.assertFalse(os.path.isdir(keystore_dir))
account_utils = AccountUtils(keystore_dir)
self.assertTrue(os.path.isdir(keystore_dir))
self.assertEqual(account_utils.get_account_list(), [])
shutil.rmtree(keystore_dir, ignore_errors=True)

def test_deleted_account_dir(self):
"""
The deleted_account_dir() helper method should be working
Expand Down
8 changes: 7 additions & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
__version__ = '2019.0418'
__version__ = '2019.0426'
# The `__version_code__` is used for the F-Droid auto update and should match
# the `versionCode` from the `build.gradle` file located in:
# `.buildozer/android/platform/build/dists/etheroll/`
# The auto update method used is the `HTTP`, see:
# https://f-droid.org/en/docs/Build_Metadata_Reference/#UpdateCheckMode
__version_code__ = 202326

0 comments on commit f31f2fe

Please sign in to comment.