Revision 6069b53b
b/kamaki/cli/__init__.py | ||
---|---|---|
429 | 429 |
else: |
430 | 430 |
run_shell(exe, parser) |
431 | 431 |
except CLIError as err: |
432 |
_print_error_message(err) |
|
432 | 433 |
if _debug: |
433 | 434 |
raise err |
434 |
_print_error_message(err) |
|
435 | 435 |
exit(1) |
436 |
except Exception as err: |
|
436 |
except Exception as er: |
|
437 |
print('Unknown Error: %s' % er) |
|
437 | 438 |
if _debug: |
438 |
raise err |
|
439 |
print('Unknown Error: %s' % err) |
|
439 |
raise |
|
440 |
exit(1) |
b/kamaki/cli/commands/__init__.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A.command |
33 | 33 |
|
34 |
import logging |
|
35 |
|
|
36 |
sendlog = logging.getLogger('clients.send') |
|
37 |
recvlog = logging.getLogger('clients.recv') |
|
38 |
|
|
34 | 39 |
|
35 | 40 |
class _command_init(object): |
36 | 41 |
def __init__(self, arguments={}): |
b/kamaki/cli/commands/pithos_cli.py | ||
---|---|---|
673 | 673 |
except IOError as err: |
674 | 674 |
progress_bar.finish() |
675 | 675 |
hash_bar.finish() |
676 |
raise CLIError(
|
|
676 |
raiseCLIError(err,
|
|
677 | 677 |
message='Failed to read form file %s' % local_path, |
678 |
importance=2, |
|
679 |
details=unicode(err)) |
|
678 |
importance=2) |
|
680 | 679 |
print 'Upload completed' |
681 | 680 |
|
682 | 681 |
|
b/kamaki/cli/errors.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
from json import loads |
|
34 |
import logging |
|
35 |
|
|
36 |
sendlog = logging.getLogger('clients.send') |
|
37 |
recvlog = logging.getLogger('clients.recv') |
|
35 | 38 |
|
36 | 39 |
|
37 | 40 |
class CLIError(Exception): |
... | ... | |
42 | 45 |
@importance of the output for the user |
43 | 46 |
Suggested values: 0, 1, 2, 3 |
44 | 47 |
""" |
48 |
message += '' if message and message[-1] == '\n' else '\n' |
|
45 | 49 |
super(CLIError, self).__init__(message) |
46 | 50 |
self.details = details if isinstance(details, list)\ |
47 | 51 |
else [] if details is None else ['%s' % details] |
... | ... | |
73 | 77 |
super(CLICmdSpecError, self).__init__(message, details, importance) |
74 | 78 |
|
75 | 79 |
|
76 |
def raiseCLIError(err, importance=0): |
|
77 |
message = '%s' % err |
|
78 |
if err.status: |
|
79 |
message = '(%s) %s' % (err.status, err) |
|
80 |
def raiseCLIError(err, message='', importance=0, details=[]): |
|
81 |
from traceback import format_stack |
|
82 |
recvlog.debug('\n'.join(['%s' % type(err)] + format_stack())) |
|
83 |
|
|
84 |
origerr = '%s' % err |
|
85 |
origerr = origerr if origerr else '%s' % type(err) |
|
86 |
|
|
87 |
if message: |
|
88 |
details.append(origerr) |
|
89 |
else: |
|
90 |
message = origerr |
|
91 |
|
|
92 |
try: |
|
93 |
status = err.status |
|
94 |
except AttributeError: |
|
95 |
status = None |
|
96 |
|
|
97 |
try: |
|
98 |
details.append(err.details) |
|
99 |
except AttributeError: |
|
100 |
pass |
|
101 |
|
|
102 |
if status: |
|
103 |
message = '(%s) %s' % (err.status, message) |
|
80 | 104 |
try: |
81 | 105 |
status = int(err.status) |
82 | 106 |
except ValueError: |
83 |
raise CLIError(message, err.details, importance)
|
|
107 |
raise CLIError(message, details, importance) |
|
84 | 108 |
importance = status // 100 |
85 |
raise CLIError(message, err.details, importance) |
|
109 |
raise CLIError(message, details, importance) |
b/kamaki/clients/__init__.py | ||
---|---|---|
97 | 97 |
print('______\n%s\n_______' % e) |
98 | 98 |
self._exception = e |
99 | 99 |
|
100 |
|
|
100 | 101 |
class Client(object): |
101 | 102 |
POOL_SIZE = 7 |
102 | 103 |
|
b/kamaki/clients/pithos.py | ||
---|---|---|
39 | 39 |
|
40 | 40 |
from binascii import hexlify |
41 | 41 |
|
42 |
from kamaki.clients import SilentEvent |
|
42 |
from kamaki.clients import SilentEvent, sendlog
|
|
43 | 43 |
from kamaki.clients.pithos_rest_api import PithosRestAPI |
44 | 44 |
from kamaki.clients.storage import ClientError |
45 | 45 |
from kamaki.clients.utils import path4url, filter_in |
... | ... | |
353 | 353 |
try: |
354 | 354 |
self._upload_missing_blocks(missing, hmap, f, upload_cb=upload_cb) |
355 | 355 |
except KeyboardInterrupt: |
356 |
print('- - - wait for threads to finish')
|
|
356 |
sendlog.info('- - - wait for threads to finish')
|
|
357 | 357 |
for thread in activethreads(): |
358 | 358 |
thread.join() |
359 | 359 |
raise |
Also available in: Unified diff