From 0d44fe3bd9b12dbf0f1e4ee930d4414f88947230 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 8 Feb 2023 19:53:07 +0000 Subject: [PATCH 1/3] Restyled by autopep8 --- src/blockchain_lab/blockchain_lab.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/blockchain_lab/blockchain_lab.py b/src/blockchain_lab/blockchain_lab.py index 967b85b..ef8dcc7 100644 --- a/src/blockchain_lab/blockchain_lab.py +++ b/src/blockchain_lab/blockchain_lab.py @@ -29,7 +29,8 @@ def create_docker(self): os.system( "git clone https://github.com/Decentra-Network/Decentra-Network") - os.system("docker build -t ghcr.io/decentra-network/api:latest -f Decentra-Network/docker/local/api/Dockerfile .") + os.system( + "docker build -t ghcr.io/decentra-network/api:latest -f Decentra-Network/docker/local/api/Dockerfile .") os.system( f"python3 Decentra-Network/auto_builders/docker.py -nn {self.node_number} -scn {self.security_circle_number} -i -r -s" ) @@ -82,10 +83,13 @@ def status(self): the_message += str(requests.get("http://localhost:8000/status").text) print(str(requests.get("http://localhost:8000/status").text)) for i in range(self.node_number - 1): - the_message += "- " +str(requests.get(f"http://localhost:{8100 + i + 1}/status").text) + the_message += "- " + \ + str(requests.get( + f"http://localhost:{8100 + i + 1}/status").text) print("- " + str(requests.get(f"http://localhost:{8100 + i + 1}/status").text)) return the_message + @staticmethod def send_transaction(receiver, amount, data): requests.post( @@ -96,7 +100,7 @@ def send_transaction(receiver, amount, data): "data": data, "password": "123" }, - ) + ) time.sleep(55) result = requests.get( "http://localhost:8000/transactions/all").text @@ -281,7 +285,6 @@ def blockchain_lab_status(): nodenumber = args.nodenumber - blockchain_lab(node_number=nodenumber).status() From 3d66aeb668c3723d65b8f3b0bbc9138af87089d1 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 8 Feb 2023 19:53:08 +0000 Subject: [PATCH 2/3] Restyled by black --- src/blockchain_lab/blockchain_lab.py | 94 ++++++++++++---------------- 1 file changed, 41 insertions(+), 53 deletions(-) diff --git a/src/blockchain_lab/blockchain_lab.py b/src/blockchain_lab/blockchain_lab.py index ef8dcc7..8114a35 100644 --- a/src/blockchain_lab/blockchain_lab.py +++ b/src/blockchain_lab/blockchain_lab.py @@ -13,11 +13,7 @@ class blockchain_lab: - - def __init__(self, - node_number=3, - security_circle_number=1, - path=os.getcwd()): + def __init__(self, node_number=3, security_circle_number=1, path=os.getcwd()): self.node_number = node_number self.security_circle_number = security_circle_number self.old_path = os.getcwd() @@ -27,10 +23,10 @@ def create_docker(self): os.chdir(self.path) + os.system("git clone https://github.com/Decentra-Network/Decentra-Network") os.system( - "git clone https://github.com/Decentra-Network/Decentra-Network") - os.system( - "docker build -t ghcr.io/decentra-network/api:latest -f Decentra-Network/docker/local/api/Dockerfile .") + "docker build -t ghcr.io/decentra-network/api:latest -f Decentra-Network/docker/local/api/Dockerfile ." + ) os.system( f"python3 Decentra-Network/auto_builders/docker.py -nn {self.node_number} -scn {self.security_circle_number} -i -r -s" ) @@ -45,8 +41,7 @@ def create_local(self): print("Local builded lab only available on Linux") return - os.system( - "git clone https://github.com/Decentra-Network/Decentra-Network") + os.system("git clone https://github.com/Decentra-Network/Decentra-Network") os.system( f"python3 Decentra-Network/auto_builders/local.py -nn {self.node_number} -scn {self.security_circle_number} -i -r -s" ) @@ -83,27 +78,22 @@ def status(self): the_message += str(requests.get("http://localhost:8000/status").text) print(str(requests.get("http://localhost:8000/status").text)) for i in range(self.node_number - 1): - the_message += "- " + \ - str(requests.get( - f"http://localhost:{8100 + i + 1}/status").text) - print("- " + - str(requests.get(f"http://localhost:{8100 + i + 1}/status").text)) + the_message += "- " + str( + requests.get(f"http://localhost:{8100 + i + 1}/status").text + ) + print( + "- " + str(requests.get(f"http://localhost:{8100 + i + 1}/status").text) + ) return the_message @staticmethod def send_transaction(receiver, amount, data): requests.post( "http://localhost:8000/send/", - { - "to_user": receiver, - "amount": amount, - "data": data, - "password": "123" - }, + {"to_user": receiver, "amount": amount, "data": data, "password": "123"}, ) time.sleep(55) - result = requests.get( - "http://localhost:8000/transactions/all").text + result = requests.get("http://localhost:8000/transactions/all").text print("Result of the transaction: ") print(result) @@ -112,7 +102,8 @@ def send_transaction(receiver, amount, data): def blockchain_lab_create_docker(): parser = argparse.ArgumentParser( - description="Create blockchain lab with decentra-network-api docker.") + description="Create blockchain lab with decentra-network-api docker." + ) parser.add_argument( "-nn", @@ -144,14 +135,15 @@ def blockchain_lab_create_docker(): if args.path is not None: path = args.path - blockchain_lab(node_number=nodenumber, - security_circle_number=securitycirclenumber, - path=path).create_docker() + blockchain_lab( + node_number=nodenumber, security_circle_number=securitycirclenumber, path=path + ).create_docker() def blockchain_lab_create_local(): parser = argparse.ArgumentParser( - description="Create blockchain lab with local system.") + description="Create blockchain lab with local system." + ) parser.add_argument( "-nn", @@ -184,14 +176,15 @@ def blockchain_lab_create_local(): path = args.path - blockchain_lab(node_number=nodenumber, - security_circle_number=securitycirclenumber, - path=path).create_local() + blockchain_lab( + node_number=nodenumber, security_circle_number=securitycirclenumber, path=path + ).create_local() def blockchain_lab_delete_docker(): parser = argparse.ArgumentParser( - description="Delete blockchain lab with decentra-network-api docker.") + description="Delete blockchain lab with decentra-network-api docker." + ) parser.add_argument( "-nn", @@ -224,14 +217,15 @@ def blockchain_lab_delete_docker(): path = args.path - blockchain_lab(node_number=nodenumber, - security_circle_number=securitycirclenumber, - path=path).delete_docker() + blockchain_lab( + node_number=nodenumber, security_circle_number=securitycirclenumber, path=path + ).delete_docker() def blockchain_lab_delete_local(): parser = argparse.ArgumentParser( - description="Delete blockchain lab with local system.") + description="Delete blockchain lab with local system." + ) parser.add_argument( "-nn", @@ -264,14 +258,13 @@ def blockchain_lab_delete_local(): path = args.path - blockchain_lab(node_number=nodenumber, - security_circle_number=securitycirclenumber, - path=path).delete_local() + blockchain_lab( + node_number=nodenumber, security_circle_number=securitycirclenumber, path=path + ).delete_local() def blockchain_lab_status(): - parser = argparse.ArgumentParser( - description="Get the status of blockchain lab.") + parser = argparse.ArgumentParser(description="Get the status of blockchain lab.") parser.add_argument( "-nn", @@ -289,8 +282,7 @@ def blockchain_lab_status(): def blockchain_lab_send_transaction(): - parser = argparse.ArgumentParser( - description="A fully functional blockchain lab.") + parser = argparse.ArgumentParser(description="A fully functional blockchain lab.") parser.add_argument( "-r", @@ -299,16 +291,12 @@ def blockchain_lab_send_transaction(): type=str, help="Give the receiver adress", ) - parser.add_argument("-a", - "--amount", - default=5000, - type=str, - help="Give the amount") - parser.add_argument("-d", - "--data", - default="blockchain-lab", - type=str, - help="Give the data") + parser.add_argument( + "-a", "--amount", default=5000, type=str, help="Give the amount" + ) + parser.add_argument( + "-d", "--data", default="blockchain-lab", type=str, help="Give the data" + ) args = parser.parse_args() From 31ee463bdc0f870863630f2c1ff3cb2e9b4f690f Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 8 Feb 2023 19:53:19 +0000 Subject: [PATCH 3/3] Restyled by yapf --- src/blockchain_lab/blockchain_lab.py | 85 ++++++++++++++++------------ 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/src/blockchain_lab/blockchain_lab.py b/src/blockchain_lab/blockchain_lab.py index 8114a35..ee5c82c 100644 --- a/src/blockchain_lab/blockchain_lab.py +++ b/src/blockchain_lab/blockchain_lab.py @@ -13,7 +13,11 @@ class blockchain_lab: - def __init__(self, node_number=3, security_circle_number=1, path=os.getcwd()): + + def __init__(self, + node_number=3, + security_circle_number=1, + path=os.getcwd()): self.node_number = node_number self.security_circle_number = security_circle_number self.old_path = os.getcwd() @@ -23,7 +27,8 @@ def create_docker(self): os.chdir(self.path) - os.system("git clone https://github.com/Decentra-Network/Decentra-Network") + os.system( + "git clone https://github.com/Decentra-Network/Decentra-Network") os.system( "docker build -t ghcr.io/decentra-network/api:latest -f Decentra-Network/docker/local/api/Dockerfile ." ) @@ -41,7 +46,8 @@ def create_local(self): print("Local builded lab only available on Linux") return - os.system("git clone https://github.com/Decentra-Network/Decentra-Network") + os.system( + "git clone https://github.com/Decentra-Network/Decentra-Network") os.system( f"python3 Decentra-Network/auto_builders/local.py -nn {self.node_number} -scn {self.security_circle_number} -i -r -s" ) @@ -79,18 +85,21 @@ def status(self): print(str(requests.get("http://localhost:8000/status").text)) for i in range(self.node_number - 1): the_message += "- " + str( - requests.get(f"http://localhost:{8100 + i + 1}/status").text - ) - print( - "- " + str(requests.get(f"http://localhost:{8100 + i + 1}/status").text) - ) + requests.get(f"http://localhost:{8100 + i + 1}/status").text) + print("- " + str( + requests.get(f"http://localhost:{8100 + i + 1}/status").text)) return the_message @staticmethod def send_transaction(receiver, amount, data): requests.post( "http://localhost:8000/send/", - {"to_user": receiver, "amount": amount, "data": data, "password": "123"}, + { + "to_user": receiver, + "amount": amount, + "data": data, + "password": "123" + }, ) time.sleep(55) result = requests.get("http://localhost:8000/transactions/all").text @@ -102,8 +111,7 @@ def send_transaction(receiver, amount, data): def blockchain_lab_create_docker(): parser = argparse.ArgumentParser( - description="Create blockchain lab with decentra-network-api docker." - ) + description="Create blockchain lab with decentra-network-api docker.") parser.add_argument( "-nn", @@ -135,15 +143,14 @@ def blockchain_lab_create_docker(): if args.path is not None: path = args.path - blockchain_lab( - node_number=nodenumber, security_circle_number=securitycirclenumber, path=path - ).create_docker() + blockchain_lab(node_number=nodenumber, + security_circle_number=securitycirclenumber, + path=path).create_docker() def blockchain_lab_create_local(): parser = argparse.ArgumentParser( - description="Create blockchain lab with local system." - ) + description="Create blockchain lab with local system.") parser.add_argument( "-nn", @@ -176,15 +183,14 @@ def blockchain_lab_create_local(): path = args.path - blockchain_lab( - node_number=nodenumber, security_circle_number=securitycirclenumber, path=path - ).create_local() + blockchain_lab(node_number=nodenumber, + security_circle_number=securitycirclenumber, + path=path).create_local() def blockchain_lab_delete_docker(): parser = argparse.ArgumentParser( - description="Delete blockchain lab with decentra-network-api docker." - ) + description="Delete blockchain lab with decentra-network-api docker.") parser.add_argument( "-nn", @@ -217,15 +223,14 @@ def blockchain_lab_delete_docker(): path = args.path - blockchain_lab( - node_number=nodenumber, security_circle_number=securitycirclenumber, path=path - ).delete_docker() + blockchain_lab(node_number=nodenumber, + security_circle_number=securitycirclenumber, + path=path).delete_docker() def blockchain_lab_delete_local(): parser = argparse.ArgumentParser( - description="Delete blockchain lab with local system." - ) + description="Delete blockchain lab with local system.") parser.add_argument( "-nn", @@ -258,13 +263,14 @@ def blockchain_lab_delete_local(): path = args.path - blockchain_lab( - node_number=nodenumber, security_circle_number=securitycirclenumber, path=path - ).delete_local() + blockchain_lab(node_number=nodenumber, + security_circle_number=securitycirclenumber, + path=path).delete_local() def blockchain_lab_status(): - parser = argparse.ArgumentParser(description="Get the status of blockchain lab.") + parser = argparse.ArgumentParser( + description="Get the status of blockchain lab.") parser.add_argument( "-nn", @@ -282,7 +288,8 @@ def blockchain_lab_status(): def blockchain_lab_send_transaction(): - parser = argparse.ArgumentParser(description="A fully functional blockchain lab.") + parser = argparse.ArgumentParser( + description="A fully functional blockchain lab.") parser.add_argument( "-r", @@ -291,12 +298,16 @@ def blockchain_lab_send_transaction(): type=str, help="Give the receiver adress", ) - parser.add_argument( - "-a", "--amount", default=5000, type=str, help="Give the amount" - ) - parser.add_argument( - "-d", "--data", default="blockchain-lab", type=str, help="Give the data" - ) + parser.add_argument("-a", + "--amount", + default=5000, + type=str, + help="Give the amount") + parser.add_argument("-d", + "--data", + default="blockchain-lab", + type=str, + help="Give the data") args = parser.parse_args()