Skip to content

Commit 6f55f46

Browse files
committed
Updates
1 parent d7d10d6 commit 6f55f46

File tree

11 files changed

+72
-75
lines changed

11 files changed

+72
-75
lines changed

MANIFEST.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
graft cryptolio/templates
2+
graft cryptolio/static
3+
include cryptolio/schema.sql

cryptolio/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from cryptolio.cryptolio import app

cryptolio/cli.py

-40
This file was deleted.

cryptolio/cryptolio.py

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import os
2+
import sqlite3
3+
from flask import Flask, request, session, g, redirect, url_for, abort, \
4+
render_template, flash
5+
6+
app = Flask(__name__) # create the application instance :)
7+
app.config.from_object(__name__) # load config from this file
8+
9+
# Load default config and override config from an environment variable
10+
app.config.update(dict(
11+
DATABASE=os.path.join(app.root_path, 'cryptolio.db'),
12+
SECRET_KEY='development_key',
13+
USERNAME='admin',
14+
PASSWORD='default'
15+
))
16+
17+
app.config.from_envvar('CRYPTOLIO_SETTINGS', silent=True)
18+
19+
def connect_db():
20+
"""Connects to the specific database."""
21+
rv = sqlite3.connect(app.config['DATABASE'])
22+
rv.row_factory = sqlite3.Row
23+
return rv
24+
25+
def get_db():
26+
"""Opens a new database connection if there is none yet for the
27+
current application context.
28+
"""
29+
if not hasattr(g, 'sqlite_db'):
30+
g.sqlite_db = connect_db()
31+
return g.sqlite_db
32+
33+
@app.teardown_appcontext
34+
def close_db(error):
35+
"""Closes the database again at the end of the request."""
36+
if hasattr(g, 'sqlite_db'):
37+
g.sqlite_db.close()
38+
39+
def init_db():
40+
db = get_db()
41+
with app.open_resource('schema.sql', mode='r') as f:
42+
db.cursor().executescript(f.read())
43+
db.commit()
44+
45+
@app.cli.command('initdb')
46+
def initdb_command():
47+
"""Initializes the database."""
48+
init_db()
49+
print('Initialized the database.')

cryptolio/schema.sql

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
drop table if exists accounts;
2+
create table accounts (
3+
id integer primary key autoincrement,
4+
username text not null,
5+
password text not null
6+
);
7+
8+
drop table if exists apis;
9+
create table apis (
10+
id integer primary key autoincrement,
11+
account_id integer,
12+
exchange text not null,
13+
key text not null,
14+
secret text not null,
15+
phrase text not null
16+
);

cryptolio/static/.KEEP

Whitespace-only changes.

cryptolio/templates/.KEEP

Whitespace-only changes.

cryptolio/test/.KEEP

Whitespace-only changes.

cryptolio/test/cli_test.py

-31
This file was deleted.

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
future>=0.16
22
PyYAML>=3.10
33

4+
flask>=0.12
5+
46
BitstampClient>=2.2.0
57
geminipy>=0.0.3
68
gdax>=1.0.6

setup.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@
2222
description='Cryptocurrency portfolio manager and simulator',
2323
keywords='cryptocurrency portfolio manager simulator bitcoin btc ethereum eth litecoin ltc',
2424
long_description=README,
25-
package_data={'': ['README.rst']},
25+
include_package_data=True,
2626
install_requires=INSTALL_REQUIRES,
2727
tests_require=TEST_REQUIRES,
2828
test_suite='cryptolio/test',
29-
entry_points={
30-
'console_scripts': ['cryptolio=cryptolio.cli:run_cli'],
31-
},
3229
classifiers=[
3330
'Programming Language :: Python :: 2.7',
3431
'Programming Language :: Python :: 3',

0 commit comments

Comments
 (0)