Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RobotError: Fix __repr__()/__str__() issue. #23

Merged
merged 2 commits into from
Jun 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions hetzner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
class RobotError(Exception):
def __init__(self, message, status=None):
self.message = message
formattedMessage = message if status is None else "{0} ({1})".format(message, status)
super(Exception, self).__init__(formattedMessage)
self.status = status

def __str__(self):
if self.status is None:
return self.message
else:
return "{0} ({1})".format(self.message, self.status)


class ManualReboot(Exception):
pass
Expand Down
2 changes: 1 addition & 1 deletion hetzner/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def login(self, user=None, passwd=None, force=False):
if self.user.startswith("#ws+"):
raise WebRobotError("The user {0} is a dedicated web service user "
"and cannot be used for scraping the web user "
"interface.")
"interface.".format(self.user))

# This is primarily for getting a first session cookie.
response = self.request('/login', xhr=False)
Expand Down