|
|
@@ -71,6 +71,13 @@ def make_attrs(*args): |
|
|
|
|
|
|
|
_httpxargs = dict(timeout=20) |
|
|
|
|
|
|
|
def output_board(brd): |
|
|
|
print('Name:\t%s' % brd.name) |
|
|
|
print('Class:\t%s' % brd.brdclass) |
|
|
|
print('Attributes:') |
|
|
|
for i in sorted(brd.attrs): |
|
|
|
print('\t%s\t%s' % (i, repr(brd.attrs[i]))) |
|
|
|
|
|
|
|
async def real_main(): |
|
|
|
baseurl = os.environ['BITELAB_URL'] |
|
|
|
authkey = os.environ['BITELAB_AUTH'] |
|
|
@@ -98,11 +105,8 @@ async def real_main(): |
|
|
|
check_res_code(res) |
|
|
|
|
|
|
|
brd = Board.parse_obj(res.json()) |
|
|
|
print('Name:\t%s' % brd.name) |
|
|
|
print('Class:\t%s' % brd.brdclass) |
|
|
|
print('Attributes:') |
|
|
|
for i in sorted(brd.attrs): |
|
|
|
print('\t%s\t%s' % (i, brd.attrs[i])) |
|
|
|
output_board(brd) |
|
|
|
|
|
|
|
elif sys.argv[1] == 'set': |
|
|
|
board_id = sys.argv[-1] |
|
|
|
res = await client.post('board/%s/attrs' % |
|
|
@@ -113,11 +117,8 @@ async def real_main(): |
|
|
|
check_res_code(res) |
|
|
|
|
|
|
|
brd = Board.parse_obj(res.json()) |
|
|
|
print('Name:\t%s' % brd.name) |
|
|
|
print('Class:\t%s' % brd.brdclass) |
|
|
|
print('Attributes:') |
|
|
|
for i in sorted(brd.attrs): |
|
|
|
print('\t%s\t%s' % (i, brd.attrs[i])) |
|
|
|
output_board(brd) |
|
|
|
|
|
|
|
finally: |
|
|
|
await client.aclose() |
|
|
|
|
|
|
@@ -218,7 +219,7 @@ class TestClient(unittest.TestCase): |
|
|
|
output = '''Name:\tcora-1 |
|
|
|
Class:\tcora-z7s |
|
|
|
Attributes: |
|
|
|
\tip\t172.20.20.5 |
|
|
|
\tip\t'172.20.20.5' |
|
|
|
\tpower\tFalse |
|
|
|
''' |
|
|
|
|
|
|
@@ -273,7 +274,7 @@ Attributes: |
|
|
|
output = '''Name:\tcora-1 |
|
|
|
Class:\tcora-z7s |
|
|
|
Attributes: |
|
|
|
\tip\t172.20.20.5 |
|
|
|
\tip\t'172.20.20.5' |
|
|
|
\tpower\tTrue |
|
|
|
''' |
|
|
|
|
|
|
|