Skip to content
Snippets Groups Projects
Commit f7b3ebd0 authored by Robert Habermann's avatar Robert Habermann
Browse files

update cli and change lib to satisfy tests

parent 1f2b31e8
No related branches found
No related tags found
No related merge requests found
......@@ -19,12 +19,12 @@ def load_config(config_file):
"""
try:
if not oct(stat.S_IMODE(os.stat(config_file).st_mode)) == "0600":
raise Exception("Permissions to %s too open. Should be 0600!" % config_file)
except OSError:
# non existent file can not be checked for permissions; that's fine -> pass
pass
if not os.path.isfile(config_file):
click.secho("No config file found at: %s" % config_file, fg="yellow")
return
if not oct(stat.S_IMODE(os.stat(config_file).st_mode)) == "0600":
raise Exception("Permissions to %s too open. Should be 0600!" % config_file)
try:
with click.open_file(config_file) as f:
......@@ -41,7 +41,7 @@ def load_config(config_file):
except IOError:
# no config file in default location; that's fine -> continue
click.secho("No config file found at: %s" % config_file, fg="yellow")
click.secho("No valid file found at: %s (I/O Error)" % config_file, fg="yellow")
except ValueError as err:
click.secho("Does not look like a valid config file: %s" % config_file, fg="yellow")
raise Exception("Does not look like a valid config file: %s" % err)
......
......@@ -99,10 +99,12 @@ class Article(object):
def __init__(self, dct):
for key, value in dct.items():
"""
try:
logger.debug("Parse Article: {0} --> {1}".format(key, value))
except UnicodeEncodeError:
logger.warn("Parse Article: Unicode error for Value of Key {0}".format(key))
"""
self.__dict__ = dct
def __repr__(self):
......@@ -183,14 +185,7 @@ class Attachment(object):
Returns:
"""
b64_content = (
"IyBjb250ZW50IG9mIHNldHVwLmNmZwpbcHl0ZXN0XQpub3JlY3Vyc2VkaXJzID0gL"
"mdpdAphZGRvcHRzID0gLS1kb2N0ZXN0LW1vZHVsZXMKClttZXRhZGF0YV0KZGVzY3"
"JpcHRpb24tZmlsZSA9IFJFQURNRS5tZCAgIyBUaGlzIHRlbGxzIFB5UEkgd2hlcmU"
"geW91ciBSRUFETUUgZmlsZSBpcy4K"
)
return Attachment(b64_content, "text/plain", "dümmy.txt")
return Attachment("YmFyCg==", "text/plain", "dümmy.txt")
class AttachmentList(object):
......@@ -250,7 +245,7 @@ class DynamicField(object):
def __init__(self, name=None, value=None, dct=None):
if dct:
if name or value:
raise Exception("Please provider either \"dct\" or \"name and value\"")
raise Exception("Please provide either \"dct\" or \"name and value\"")
self.name = dct["Name"]
self.value = dct["Value"]
......@@ -259,7 +254,7 @@ class DynamicField(object):
self.name = name
self.value = value
else:
raise Exception("Please provider either \"dct\" or \"name and value\"")
raise Exception("Please provide either \"dct\" or \"name and value\"")
def __repr__(self):
return "<{0}: {1} --> {2} >".format(self.__class__.__name__, self.name, self.value)
......@@ -319,6 +314,7 @@ class DynamicFieldList(object):
Returns:
"""
self.dynamic_field_list.append(dynamic_field)
def to_dct(self):
......@@ -349,11 +345,12 @@ class Ticket(object):
def __init__(self, dct):
for key, value in dct.items():
"""
try:
logger.debug("Parse Ticket: {0} --> {1}".format(key, value))
except UnicodeEncodeError:
logger.warn("Parse Ticket: Unicode error for Value of Key {0}".format(key))
"""
if isinstance(value, dict):
dct[key] = Ticket(value)
self.__dict__ = dct
......@@ -1172,7 +1169,7 @@ class Client(object):
Returns:
bool True
"""
if self.operation == "SessionCreate":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment