Skip to content

Commit 40bc48b

Browse files
Restyled by autopep8
1 parent 7b22496 commit 40bc48b

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

run_example_service.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ def main():
3232
help="start the daemon with SSL")
3333
args = parser.parse_args()
3434
root_path = pathlib.Path(__file__).absolute().parent
35-
35+
3636
# All services modules go here
3737
service_modules = ["service.example_service"]
38-
38+
3939
# Call for all the services listed in service_modules
4040
all_p = start_all_services(root_path,
4141
service_modules,
4242
args.run_daemon,
4343
args.daemon_config,
4444
args.run_ssl)
45-
45+
4646
# Continuous checking all subprocess
4747
try:
4848
while True:
@@ -77,7 +77,7 @@ def start_service(cwd, service_module, run_daemon, daemon_config, run_ssl):
7777
Starts SNET Daemon ("snetd") and the python module of the service
7878
at the passed gRPC port.
7979
"""
80-
80+
8181
def add_ssl_configs(conf):
8282
"""Add SSL keys to snetd.config.json"""
8383
with open(conf, "r") as f:
@@ -86,7 +86,7 @@ def add_ssl_configs(conf):
8686
snetd_configs["ssl_key"] = "/opt/singnet/.certs/privkey.pem"
8787
with open(conf, "w") as f:
8888
json.dump(snetd_configs, f, sort_keys=True, indent=4)
89-
89+
9090
all_p = []
9191
if run_daemon:
9292
if daemon_config:
@@ -102,7 +102,7 @@ def add_ssl_configs(conf):
102102
sys.executable,
103103
"-m", service_module,
104104
"--grpc-port", str(grpc_port)],
105-
cwd=str(cwd))
105+
cwd=str(cwd))
106106
all_p.append(p)
107107
return all_p
108108

service/example_service.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454

5555
# Create a class to be added to the gRPC server
5656
# derived from the protobuf codes.
57+
58+
5759
class CalculatorServicer(grpc_bt_grpc.CalculatorServicer):
5860
def __init__(self):
5961
self.a = 0
@@ -74,7 +76,8 @@ def add(self, request, context):
7476
self.result = Result()
7577

7678
self.result.value = self.a + self.b
77-
_LOGGER.debug("add({},{})={}".format(self.a, self.b, self.result.value))
79+
_LOGGER.debug("add({},{})={}".format(
80+
self.a, self.b, self.result.value))
7881
return self.result
7982

8083
def sub(self, request, context):
@@ -83,7 +86,8 @@ def sub(self, request, context):
8386

8487
self.result = Result()
8588
self.result.value = self.a - self.b
86-
_LOGGER.debug("sub({},{})={}".format(self.a, self.b, self.result.value))
89+
_LOGGER.debug("sub({},{})={}".format(
90+
self.a, self.b, self.result.value))
8791
return self.result
8892

8993
def mul(self, request, context):
@@ -92,7 +96,8 @@ def mul(self, request, context):
9296

9397
self.result = Result()
9498
self.result.value = self.a * self.b
95-
_LOGGER.debug("mul({},{})={}".format(self.a, self.b, self.result.value))
99+
_LOGGER.debug("mul({},{})={}".format(
100+
self.a, self.b, self.result.value))
96101
return self.result
97102

98103
def div(self, request, context):
@@ -101,7 +106,8 @@ def div(self, request, context):
101106

102107
self.result = Result()
103108
self.result.value = self.a / self.b
104-
_LOGGER.debug("div({},{})={}".format(self.a, self.b, self.result.value))
109+
_LOGGER.debug("div({},{})={}".format(
110+
self.a, self.b, self.result.value))
105111
return self.result
106112

107113

@@ -145,6 +151,7 @@ def reserve_port(grpc_port=7777):
145151
finally:
146152
sock.close()
147153

154+
148155
def main():
149156
""" Runs the gRPC server to communicate with the SNET Daemon. """
150157
parser = argparse.ArgumentParser(prog=__file__)

test_example_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
endpoint = "localhost:{}".format(
2323
registry["example_service"]["grpc"])
2424

25-
grpc_method = input("Method (add|sub|mul|div): ") if not test_flag else "mul"
25+
grpc_method = input(
26+
"Method (add|sub|mul|div): ") if not test_flag else "mul"
2627
a = float(input("Number 1: ") if not test_flag else "12")
2728
b = float(input("Number 2: ") if not test_flag else "7")
2829

0 commit comments

Comments
 (0)