Revert "black: re-format"
This reverts commit 5731818de0ce446ceaafc7e75ae39da1b69942ae.
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
Change-Id: Ie61cdc8c7f2825b0d9d66be87a6a3a058de2b372
diff --git a/bin/obmc_ser_num b/bin/obmc_ser_num
index 9f207b1..8d86099 100755
--- a/bin/obmc_ser_num
+++ b/bin/obmc_ser_num
@@ -4,14 +4,14 @@
This program will get the system serial number from an OBMC machine and print it to stdout.
"""
-import os
-import sys
-
-import requests
from gen_arg import *
from gen_print import *
from gen_valid import *
+import sys
+import os
+import requests
+
save_path_0 = sys.path[0]
del sys.path[0]
@@ -21,35 +21,33 @@
logging.captureWarnings(True)
parser = argparse.ArgumentParser(
- usage="%(prog)s [OPTIONS]",
+ usage='%(prog)s [OPTIONS]',
description="%(prog)s will get the system serial number from an OBMC"
+ " machine and print it to stdout as follows:\n\n"
+ "mch_ser_num:<ser num>",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
- prefix_chars="-+",
-)
+ prefix_chars='-+')
parser.add_argument(
- "--openbmc_username",
+ '--openbmc_username',
default="root",
- help="The username for communicating with the OpenBMC machine.",
-)
+ help='The username for communicating with the OpenBMC machine.')
parser.add_argument(
- "--openbmc_password",
+ '--openbmc_password',
default="0penBmc",
- help="The password for communicating with the OpenBMC machine.",
-)
+ help='The password for communicating with the OpenBMC machine.')
parser.add_argument(
- "openbmc_host", help="The host name or IP address of the OpenBMC machine."
-)
+ 'openbmc_host',
+ help='The host name or IP address of the OpenBMC machine.')
# Populate stock_list with options we want.
stock_list = [("test_mode", 0), ("quiet", 1)]
-def exit_function(signal_number=0, frame=None):
+def exit_function(signal_number=0,
+ frame=None):
r"""
Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
"""
@@ -60,7 +58,8 @@
qprint_pgm_footer()
-def signal_handler(signal_number, frame):
+def signal_handler(signal_number,
+ frame):
r"""
Handle signals. Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately
with return code 143 and without calling our exit_function.
@@ -97,6 +96,7 @@
def main():
+
if not gen_get_options(parser, stock_list):
return False
@@ -109,14 +109,12 @@
http_prefix = create_http_prefix(openbmc_host)
- command = http_prefix + "login"
+ command = http_prefix + 'login'
qprint_issuing(command)
- resp = session.post(
- command,
- json={"data": [openbmc_username, openbmc_password]},
- verify=False,
- )
- if resp.json()["status"] != "ok":
+ resp = session.post(command,
+ json={'data': [openbmc_username, openbmc_password]},
+ verify=False)
+ if resp.json()['status'] != 'ok':
json = resp.json()
print_error_report("http request failed:\n" + sprint_var(command))
raise Exception("Login failed.\n")
@@ -125,18 +123,15 @@
qprint_issuing(command)
resp = session.get(command, verify=False)
json = resp.json()
- if json["status"] != "ok":
+ if json['status'] != 'ok':
print_error_report("http request failed:\n" + sprint_var(command))
raise Exception("http request failed.\n")
try:
- mch_ser_num = json["data"]["SerialNumber"]
+ mch_ser_num = json['data']['SerialNumber']
except KeyError:
- print_error_report(
- "Failed to find 'SerialNumber' key in the"
- + " following data:\n"
- + sprint_var(json)
- )
+ print_error_report("Failed to find 'SerialNumber' key in the"
+ + " following data:\n" + sprint_var(json))
return False
print_var(mch_ser_num, 0, 0, 0)