forked from Azure/azure-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improves logging and adds support for logging.code() calls
Implements storage account list command.
- Loading branch information
Showing
9 changed files
with
165 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import time | ||
_import_time = time.perf_counter() | ||
|
||
import logging | ||
import sys | ||
|
||
import azure.cli.main | ||
from azure.cli._logging import logging | ||
|
||
try: | ||
sys.exit(azure.cli.main.main(sys.argv[1:])) | ||
finally: | ||
# Note: script time includes idle time | ||
logging.info('Script time: %8.3fms', 1000 * (time.perf_counter() - _import_time)) | ||
# Note: script time includes idle and network time | ||
logging.info('Execution time: %8.3fms', 1000 * (time.perf_counter() - _import_time)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,38 @@ | ||
import logging | ||
import types | ||
|
||
try: | ||
from importlib import import_module | ||
except ImportError: | ||
def import_module(mod): | ||
m = __import__(mod) | ||
for b in mod.split('.'): | ||
m = gettatr(m, b) | ||
return m | ||
class TableOutput(object): | ||
def __enter__(self): | ||
self._rows = [{}] | ||
self._columns = {} | ||
self._column_order = [] | ||
return self | ||
|
||
def __exit__(self, ex_type, ex_value, ex_tb): | ||
if ex_type: | ||
return | ||
if len(self._rows) == 1: | ||
return | ||
|
||
cols = [(c, self._columns[c]) for c in self._column_order] | ||
print(' | '.join(c.center(w) for c, w in cols)) | ||
print('-|-'.join('-' * w for c, w in cols)) | ||
for r in self._rows[:-1]: | ||
print(' | '.join(r[c].ljust(w) for c, w in cols)) | ||
print() | ||
|
||
@property | ||
def any_rows(self): | ||
return len(self._rows) > 1 | ||
|
||
def cell(self, name, value): | ||
n = str(name) | ||
v = str(value) | ||
max_width = self._columns.get(n) | ||
if max_width is None: | ||
self._column_order.append(n) | ||
max_width = len(n) | ||
self._rows[-1][n] = v | ||
self._columns[n] = max(max_width, len(v)) | ||
|
||
def end_row(self): | ||
self._rows.append({}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters