Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
* examples update
* import accounts.yaml
  • Loading branch information
WizardsOrb committed Nov 14, 2019
1 parent cf7a795 commit 2564539
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,6 +12,7 @@ accounts.db
*.id
/pools
config/*.yaml
config/*.json
casper/*.yaml
config/accounts
backup.txt
Expand Down
13 changes: 9 additions & 4 deletions __main__.py
Expand Up @@ -27,18 +27,23 @@
exec(open("config/__main__.py").read(), globals())
print("\n\nSTARTING CASPER")

_USER_PWD = getpass.getpass("Enter your Password: ")

settings = parse_yaml("config/settings.yaml", file=True)

if "userpwd" in settings:
# saving password in settings file is only thought for dev mode
# use on your own risk
_USER_PWD = settings["userpwd"]
else:
_USER_PWD = getpass.getpass("Enter your Password: ")


if "cryptomodule" in settings:
_DEFAULT_CRYPTO = settings["cryptomodule"]
else:
_DEFAULT_CRYPTO = input("ENTER CRYPT MODULE (Fernet, PyCrypto, RAW): ")
if _DEFAULT_CRYPTO is "RAW":
_DEFAULT_CRYPTO = None

print(yaml.dump(settings))

casper = CasperCore(settings, USER_PWD=_USER_PWD, CRYPTO_MOD=_DEFAULT_CRYPTO)
analyze = JAnalyze(settings)

Expand Down
26 changes: 16 additions & 10 deletions examples/example.py
@@ -1,20 +1,26 @@
import pprint, json

import sys
import subprocess, time, pprint, os, getpass, json, sys
os.environ["PYTHONIOENCODING"] = "utf-8"
sys.path.append(".")

from casper import CasperCore
from casper.utils import verify_password
USER_PWD = input("Enter your password\n")
from casper.utils import verify_password, parse_yaml, MyYAML
yaml = MyYAML()

if os.path.exists("config/settings.yaml") is False:
exec(open("config/__main__.py").read(), globals())
print("\n\nSTARTING CASPER")

if verify_password(USER_PWD) is False:
print("PASSWORD IS NOT STRONG ENOUGH")
settings = parse_yaml("config/settings.yaml", file=True)

with open('settings.json', 'r') as json_file:
settings = json.load(json_file)
if "userpwd" in settings:
# saving password in settings file is only thought for dev mode
# use on your own risk
_USER_PWD = settings["userpwd"]
else:
_USER_PWD = getpass.getpass("Enter your Password: ")


casper = CasperCore(settings, USER_PWD)
casper = CasperCore(settings, _USER_PWD)
# imagine a button would trigger this function
def create_and_insert_acct():
_sk, _pk, _ak = casper.cli.create_acct()
Expand Down

0 comments on commit 2564539

Please sign in to comment.