Skip to content

Commit

Permalink
banner
Browse files Browse the repository at this point in the history
print -> logger.debug
signature debug logs removed
  • Loading branch information
habanoz committed Jun 8, 2019
1 parent 55a8e90 commit 337ba6c
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 77 deletions.
6 changes: 6 additions & 0 deletions banner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_____ ______ ______
|_ _|| ___ \| _ \
| | | |_/ /| | | |
| | | / | | | |
| | | |\ \ | |/ /
\_/ \_| \_||___/
6 changes: 3 additions & 3 deletions src/cli/wallet_client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def parse_get_manager_for_contract_response(self, response):
break

if self.verbose:
print("Manager address is : {}".format(manager))
logger.debug("Manager address is : {}".format(manager))

return manager

Expand Down Expand Up @@ -194,7 +194,7 @@ def parse_list_known_addresses_response(self, response):
dict[pkh] = {"alias": alias, "sk": sk_known}

if self.verbose:
print("known addresses: {}".format(dict))
logger.debug("known addresses: {}".format(dict))

return dict

Expand All @@ -206,5 +206,5 @@ def parse_list_known_contracts_response(self, response):
alias, pkh = line.split(":", maxsplit=1)
dict[alias.strip()] = pkh.strip()
if self.verbose:
print("known contracts: {}".format(dict))
logger.debug("known contracts: {}".format(dict))
return dict
19 changes: 14 additions & 5 deletions src/launch_common.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
from time import sleep

from log_config import main_logger

LINER = "--------------------------------------------"
logger = main_logger

def print_banner(args, script_name):
with open("./banner.txt", "rt") as file:
print(file.read())
print(LINER, flush=True)
print("Copyright Huseyin ABANOZ 2019")
print("[email protected]")
print("Please leave copyright information")
print(LINER,flush=True)

sleep(0.1)

logger.info("Tezos Reward Distributor" + script_name + " is Starting")
logger.info(LINER)
logger.info("Copyright Huseyin ABANOZ 2019")
logger.info("[email protected]")
logger.info("Please leave copyright information")
logger.info(LINER)

if args.dry_run:
logger.info(LINER)
logger.info("DRY RUN MODE")
logger.info(LINER)

Expand Down
19 changes: 8 additions & 11 deletions src/pay/batch_payer.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import configparser
import os
from random import randint
from subprocess import TimeoutExpired
from time import sleep

import base58
import os

from Constants import PaymentStatus
from NetworkConfiguration import BLOCK_TIME_IN_SEC
from log_config import main_logger
from util.client_utils import check_response
from util.rpc_utils import parse_json_response
from random import randint
from time import sleep

ZERO_THRESHOLD = 2e-3

Expand Down Expand Up @@ -291,8 +290,8 @@ def attempt_single_batch(self, payment_records, op_counter, verbose=None, dry_ru

# sign the operations
bytes = parse_json_response(forge_command_response, verbose=verbose)
signed_bytes = self.wllt_clnt_mngr.sign(bytes, self.manager_alias,verbose_override=True)
logger.debug("Signed bytes '{}'".format(signed_bytes))
signed_bytes = self.wllt_clnt_mngr.sign(bytes, self.manager_alias)

# pre-apply operations
logger.debug("Preapplying the operations")
preapply_json = PREAPPLY_JSON.replace('%BRANCH%', branch).replace("%CONTENT%", contents_string).replace("%PROTOCOL%", protocol).replace("%SIGNATURE%", signed_bytes)
Expand All @@ -301,13 +300,11 @@ def attempt_single_batch(self, payment_records, op_counter, verbose=None, dry_ru
#if verbose: print("--> preapply_command_str is |{}|".format(preapply_command_str))

result, preapply_command_response = self.wllt_clnt_mngr.send_request(preapply_command_str)

logger.debug("Error in preapply, request '{}'".format(preapply_command_str))
logger.debug("---")
logger.debug("Error in preapply, response '{}'".format(preapply_command_response))

if not result:
logger.error("Error in preapply operation")
logger.debug("Error in preapply, request '{}'".format(preapply_command_str))
logger.debug("---")
logger.debug("Error in preapply, response '{}'".format(preapply_command_response))

return PaymentStatus.FAIL, ""

Expand Down
2 changes: 1 addition & 1 deletion src/stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def main():
print("Stopping reward distributer")
print("Stopping reward distributor")

stop()

Expand Down
54 changes: 0 additions & 54 deletions src/util/base58.py

This file was deleted.

7 changes: 6 additions & 1 deletion src/util/client_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import os
import re

from log_config import main_logger

DOCKER_CLIENT_EXE = "%network%.sh"
DOCKER_CLIENT_EXE_SUFFIX = " client"
REGULAR_CLIENT_EXE = "tezos-client"

logger = main_logger

def get_client_path(search_paths, docker=None, network_name=None, verbose=None):
client_exe = REGULAR_CLIENT_EXE
if docker:
Expand All @@ -14,7 +18,8 @@ def get_client_path(search_paths, docker=None, network_name=None, verbose=None):
client_path = os.path.join(expanded_path, client_exe)
if os.path.isfile(client_path):
return client_path + DOCKER_CLIENT_EXE_SUFFIX if docker else client_path
if verbose: print("Not found {}".format(client_path))

logger.debug("Not found {}".format(client_path))

raise Exception("Client executable not found. Review --executable_dirs, --docker and --network parameters")

Expand Down
7 changes: 5 additions & 2 deletions src/util/rpc_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import json

from log_config import main_logger

logger = main_logger

def extract_json_part(input, verbose= None):

if verbose:
print("->will parse json response_str is '{}'".format(input))
logger.debug("->will parse json response_str is '{}'".format(input))

# because of disclaimer header; find beginning of response
idx = input.find("{")
Expand All @@ -19,7 +22,7 @@ def extract_json_part(input, verbose= None):
extracted_json_part = input[idx:].strip()

if verbose:
print("<-parsed json response_str is '{}'".format(extracted_json_part))
logger.debug("<-parsed json response_str is '{}'".format(extracted_json_part))

return extracted_json_part

Expand Down

0 comments on commit 337ba6c

Please sign in to comment.